Applying XSLT v. 2 on XML

旧城冷巷雨未停 提交于 2019-12-20 04:35:17

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!