如何在Java中使用XSLT 2.0和XSLT 3.0?

我可以在Java中使用XSLT 1.0,如下面的示例所示: –

copy.xml

    Gambardella, Matthew XML Developer's Guide Computer 44.95 2000-10-01 An in-depth look at creating applications with XML.   Ralls, Kim Midnight Rain Fantasy 5.95 2000-12-16 A former architect battles corporate zombies, an evil sorceress, and her own childhood to become queen of the world.   Corets, Eva Maeve Ascendant Fantasy 5.95 2000-11-17 After the collapse of a nanotechnology society in England, the young survivors lay the foundation for a new society.   

copy.xsl

         

Copy.java

 package com.data.transform; import javax.xml.transform.Transformer; import javax.xml.transform.TransformerFactory; import javax.xml.transform.stream.StreamResult; import javax.xml.transform.stream.StreamSource; public class Copy { public static void main(String args[]) throws Exception { StreamSource source = new StreamSource("copy.xml"); StreamSource stylesource = new StreamSource("copy.xsl"); TransformerFactory factory = TransformerFactory.newInstance(); Transformer transformer = factory.newTransformer(stylesource); StreamResult result = new StreamResult(System.out); transformer.transform(source, result); } } 

产量

   Gambardella, Matthew XML Developer's Guide Computer 44.95 2000-10-01 An in-depth look at creating applications with XML.   Ralls, Kim Midnight Rain Fantasy 5.95 2000-12-16 A former architect battles corporate zombies, an evil sorceress, and her own childhood to become queen of the world.   Corets, Eva Maeve Ascendant Fantasy 5.95 2000-11-17 After the collapse of a nanotechnology society in England, the young survivors lay the foundation for a new society.   

但是,现在我想在Java中使用XSLT 2.0和XSLT 3.0(如xsl:analyze-stringxsl:try等)中包含的一些东西。 我怎样才能做到这一点 ?

从Maven或Sourceforge获取Saxon 9 HE并将其放在类路径上,然后在9.8或XSLT 3.0支持之前对Saxon 9.x提供XSLT 2.0支持(流,高阶函数除外, xsl:evaluate ,模式感知,向后兼容性) )9.8。 要获得完整的XSLT 3.0支持,您需要从Saxonica下载Saxon 9 PE或EE ,并将其与您购买的许可证或您在类路径上请求的试用许可证放在一起。