如何用 ant 执行 XSLT 2.0? [英] How to execute XSLT 2.0 with ant?
问题描述
我正在尝试从 ant 文件运行 XSLT 转换.
我正在使用带有 saxon 9 解析器(支持 XSLT 2.0)的 XSLT 2.0 样式表.>
问题是 ant 似乎总是在调用 XSLT 1.0 解析器.
这是我的蚂蚁文件:
</xslt>
如果我直接调用它(没有蚂蚁),它就可以工作.
有什么想法吗?
问题在于,虽然将 Saxon 添加到类路径中,但默认的 JAXP 机制会确定使用哪个 TransformerFactory,并且它将使用默认值 Xalan.您要么需要:
- 将
javax.xml.transform.TransformerFactory
系统变量设置为net.sf.saxon.TransformerFactoryImpl
, - 将 saxon9.jar 添加到
CLASSPATH
系统变量,或 - 在
xslt
元素内使用<factory name="net.sf.saxon.TransformerFactoryImpl"/>
I'm trying to run an XSLT transformation from an ant file.
I'm using a XSLT 2.0 stylesheet with a saxon 9 parser (supporting XSLT 2.0).
The problem is that it seems that ant is always calling an XSLT 1.0 parser.
Here's my ant file :
<xslt style="stylesheet.xslt"
basedir="core/"
extension=".xml"
destdir="core/"
classpath="D:\\DevTools\\saxon\\bin\\saxon9.jar">
</xslt>
If I call it directly (without ant), it's working.
Any idea ?
The problem is that while Saxon is added to the classpath, the default JAXP mechanism to determine which TransformerFactory is used and it will use the default that is Xalan. You either need to:
- Set
javax.xml.transform.TransformerFactory
system variable tonet.sf.saxon.TransformerFactoryImpl
, - Add saxon9.jar to the
CLASSPATH
system variable, or - Use
<factory name="net.sf.saxon.TransformerFactoryImpl"/>
inside thexslt
element
这篇关于如何用 ant 执行 XSLT 2.0?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!