Reputation: 1003
Within an XSL stylesheet, I'm trying to use the document() function with a relative path to an XML file. The XML file I'm trying to load is in the same folder as the stylesheet. The code in the backend is invoking the XSLT using transformer
Java Code
TransformerFactory tFactory = TransformerFactory.newInstance();
InputStream inXSL = getClass().getResourceAsStream("/input.xsl");
Transformer transformer = tFactory.newTransformer(new StreamSource(inXSL));
transformer.transform(new StreamSource(inXMLStream), new StreamResult(outStream));
XSL
<xsl:variable name="configXml" select="document('config.xml')" />
But for some reason it doesn't seem to load the file, it gives the following error, FODC0005: java.io.FileNotFoundException: D:\Applications\weblogic_domain\config.xml It seems like XSL is looking for the file in the WebLogic domain folder rather than the web applications path.
Upvotes: 1
Views: 1632
Reputation: 163352
Because you supply a StreamSource and don't set the systemId, the XSLT processor has no idea where the stylesheet was loaded from, so it cannot resolve the relative URI intelligently. Use the setSystemId() method on the StreamSource to set a base URI for the stylesheet.
Upvotes: 2