问题
I had written an XSLT 2.0 version file and when it is applied to an XML file it gives me following error:
ERROR: 'Unsupported XSL element 'http://www.w3.org/1999/XSL/Transform:sequence''
This is the Java code:
TransformerFactory tFactory = TransformerFactory.newInstance();
Transformer transformer = tFactory.newTransformer(new StreamSource("Test.xslt"));
transformer.transform(new StreamSource("Old.xml"),new StreamResult(new
FileOutputStream("New.xml")));
Can someone help me out with this?
回答1:
The default XSLT processors in java do not yet support XSLT 2.0
. Check out here
You either need to stick with XSLT 1.0, or find a XSLT processor that supports XSLT 2.0
回答2:
Try adding this line to your code
System.setProperty(
"javax.xml.transform.TransformerFactory","net.sf.saxon.TransformerFactoryImpl");
Note: Also add corresponding JAR files for the Saxon parser than you will be good to go. You can refer this link for JAR file references. Hope this will help.
来源:https://stackoverflow.com/questions/14596521/applying-xslt-v-2-on-xml