Results 1 to 2 of 2
- 12-20-2010, 05:19 PM #1Member
- Join Date
- Dec 2010
- Rep Power
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
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.
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.
- 12-21-2010, 02:42 AM #2
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
- By friday in forum Advanced JavaReplies: 1Last Post: 12-17-2010, 08:13 PM
- By jeremycod in forum Advanced JavaReplies: 0Last Post: 10-31-2010, 09:51 AM
- By killerf2006 in forum New To JavaReplies: 3Last Post: 08-20-2010, 12:18 PM
- By agusCba in forum Sun Java Wireless ToolkitReplies: 2Last Post: 04-04-2010, 12:53 AM
- By dvlchd3 in forum EclipseReplies: 2Last Post: 01-13-2010, 11:32 AM