I have a set of import dependencies between XSL files and I would like to package them inside a jar file. If I refer to the main XSL through the packaging directory structure so that I can use getResourceAsStream() it fails to get the imported ones. Apparently set systemId does not work for XSL files as resources inside a Jar file. I am using XERCES/XALAN.
Rather than getting the resource as a stream, use
URL url = getClass().getResource(name); Source xsl = new StreamSource(url.toExternalForm()); Transformer xform = factory.newTransformer(xsl);
When you supply the system ID, relative references will be resolved with respect to it. When only the stream is provided, the processor has no idea where the data is coming from and can't resolve relative paths.