I need to transform XML file with XSL, which includes multiple imports. A simple transformation works fine (even with imports), but it’s not what I exactly want, because there is even more than 20 imported files for each transformation. (I am using javax.xml.transform
now, before I was using net.sf.saxon.s9api
.)
I have compiled XSLT with Oxygen XML Editor and got a SEF file. It should already include all the files and now I get the following error:
Error at package on line 2 column 321 of file.sef.xml:
XTSE0150: The supplied file does not appear to be a stylesheet
javax.xml.transform.TransformerConfigurationException: Failed to compile stylesheet. 1 error detected.
I think the problem is that it is trying to compile a compiled file, but how can I solve this?
Here is basic code that I have right now:
public String transform(File xslt, String xml) throws TransformerException {
TransformerFactory tFactory = TransformerFactory.newInstance("net.sf.saxon.TransformerFactoryImpl", null);
Transformer transformer = tFactory.newTransformer(new StreamSource(xslt));
final StringWriter writer = new StringWriter();
StreamResult standardResult = new StreamResult(writer);
transformer.transform(new StreamSource(new StringReader(xml)), standardResult);
return writer.toString();
}