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();
}
Saxon 9.9 should accept a SEF file in pretty-well all places where it would accept a source stylesheet. In fact I have just confirmed that your code does accept a SEF file in 9.9. But the same isn't true of 9.8, so the first thing is to check the Saxon version.
There's also the possibility that there's some version incompatibility between the version of oXygen used to create the SEF file and the Saxon version that you're using to load and execute it.