Results 1 to 2 of 2
  1. #1
    nsarun is offline Member
    Join Date
    Dec 2010
    Posts
    1
    Rep Power
    0

    Default Getting included resources while getting resource stream

    I am working on a JAXB-Webservices application. Here we have an XSLT that would format a huge XML response thus received. The base XSLT (BaseAsset.xslt) has the following line also

    <xsl:import href="./AssetUtility.xslt"/>

    I retreive the XSLT with the following java code.

    InputStream xsltStream = getClass().getClassLoader().getResourceAsStream(Ut il.replaceFileSeperator(fileName));
    xslStream = new StreamSource(xsltStream, (getClass().getClassLoader().getResource(Util.repl aceForwardSlash(fileName)).toExternalForm()));

    For all XSLTs that dont import other XSLTs, the application works perfectly. Only with XSLTs that include other XSLTs the getResource fails. returns null.

    I tried

    URL systemURL = getClass().getClassLoader().getResource(Util.repla ceForwardSlash(fileName));
    String SystemId = systemURL.toExternalForm();

    The systemURL is null for the cases with XSLTs that include other XSLTs.

    What is wrong with this? All I need to do is to be able to get the Stylesheet using getResource or getResourceAsStream.

    Indeed appreciate any insight into this.

    Thank you
    :)

  2. #2
    travishein's Avatar
    travishein is offline Senior Member
    Join Date
    Sep 2009
    Location
    Canada
    Posts
    684
    Rep Power
    5

    Default

    This might be a kind of clunky way to do it, but would you be able to pre-fetch the XSLT file(s) into a temporary folder and then invoke the xslt processor using the path to this temporary folder.

    *create a temporary folder.
    *use the getResource(class path prefix + fileName) to get the first xslt file name.
    *save the result xslt into this temporary folder.
    *quickly 'scan' over this xslt file, for each xslt:import= (some relative url)
    * perform a fetch with getResource(class path prefix + some relative url)
    * store that into the temporary folder
    * i guess this could even be recursive, scanning for includes of includes.
    * now, invoke the xslt operation using the xslt fileName
    * remove the temporary directory

Similar Threads

  1. JDBC code not included into JAR file??
    By friday in forum Advanced Java
    Replies: 1
    Last Post: 12-17-2010, 07:13 PM
  2. Replies: 0
    Last Post: 10-31-2010, 08:51 AM
  3. Included file throws error.
    By killerf2006 in forum New To Java
    Replies: 3
    Last Post: 08-20-2010, 11:18 AM
  4. Sending files though bluetooth (URL included) ???
    By agusCba in forum Sun Java Wireless Toolkit
    Replies: 2
    Last Post: 04-03-2010, 11:53 PM
  5. Resource File
    By dvlchd3 in forum Eclipse
    Replies: 2
    Last Post: 01-13-2010, 10:32 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •