java 我使用的是哪个版本的 XPATH 和 XSLT?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7951879/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Which version of XPATH and XSLT am I using..?
提问by John
How to know which version of XPATH and XSLT am I using...?
如何知道我使用的是哪个版本的 XPATH 和 XSLT...?
Say I have installed JDK 1.7 then which version of XPATH and XSLT do I have..?
假设我已经安装了 JDK 1.7 那么我有哪个版本的 XPATH 和 XSLT..?
回答by Michael Kay
In XSLT, call system-property('xsl:version')
. It will return 1.0 or 2.0 depending on whether you are using a 1.0 or 2.0 processor.
在 XSLT 中,调用system-property('xsl:version')
. 它将返回 1.0 或 2.0,具体取决于您使用的是 1.0 还是 2.0 处理器。
In XPath, there's no direct equivalent. But a quick test is to call current-date()
with no arguments. If this succeeds, you have a 2.0 processor, if it fails, you have a 1.0 processor.
在 XPath 中,没有直接的等价物。但是一个快速的测试是current-date()
不带参数地调用。如果成功,您将拥有 2.0 处理器,如果失败,您将拥有 1.0 处理器。
Unless you take steps to install a 2.0 processor such as Saxon on your class path or in the endorsed library, the XSLT processor that the JDK gives you will (today) be a 1.0 processor.
除非您采取措施在类路径或认可的库中安装 2.0 处理器,例如 Saxon,否则 JDK 提供给您的 XSLT 处理器(今天)将是 1.0 处理器。
回答by Martin Honnen
Well if you use Java then you have a choice of XSLT and XPath processors. The one built-in in the JDK (I only know of 1.6 but I don't think it has changed in 1.7) is Apache Xalan which is an XSLT and XPath 1.0 processor. There however third party solutions like Saxon 9which support XSLT and XPath 2.0. And there are certainly additional XQuery 1.0 implementations for Java, as XPath 2.0 is a subset of XQuery 1.0, you have further choices if you are interested in XPath 2.0.
好吧,如果您使用 Java,那么您可以选择 XSLT 和 XPath 处理器。JDK 中内置的一个(我只知道 1.6,但我认为它在 1.7 中没有改变)是 Apache Xalan,它是一个 XSLT 和 XPath 1.0 处理器。然而,有像Saxon 9这样支持 XSLT 和 XPath 2.0 的第三方解决方案。并且肯定还有用于 Java 的其他 XQuery 1.0 实现,因为 XPath 2.0 是 XQuery 1.0 的子集,如果您对 XPath 2.0 感兴趣,您还有更多选择。
回答by Mark Butler
Try
尝试
java com.sun.org.apache.xalan.internal.xslt.EnvironmentCheck
For example for me this prints
例如对我来说这打印
#---- BEGIN writeEnvironmentReport($Revision: 1.10 $): Useful stuff found: ----
java.version=1.7.0_11
version.xalan2x=not-present
version.JAXP=1.4
java.ext.dirs=/usr/lib/jvm/java-7-oracle/jre/lib/ext:/usr/java/packages/lib/ext
version.SAX=2.0
version.crimson=not-present
java.class.path=.
version.ant=not-present
sun.boot.class.path=/usr/lib/jvm/java-7-oracle/jre/lib/resources.jar:/usr/lib/jvm/java-7-oracle/jre/lib/rt.jar:/usr/lib/jvm/java-7-oracle/jre/lib/sunrsasign.jar:/usr/lib/jvm/java-7-oracle/jre/lib/jsse.jar:/usr/lib/jvm/java-7-oracle/jre/lib/jce.jar:/usr/lib/jvm/java-7-oracle/jre/lib/charsets.jar:/usr/lib/jvm/java-7-oracle/jre/lib/jfr.jar:/usr/lib/jvm/java-7-oracle/jre/classes
version.DOM=3.0
version.xalan1=not-present
version.xalan2_2=Xalan Java 2.7.0
version.xerces2=Xerces-J 2.7.1
version.xerces1=not-present
#----- END writeEnvironmentReport: Useful properties found: -----
# YAHOO! Your environment seems to be OK.
回答by Apurva Singh
<xsl:comment>
XSLT Version = <xsl:copy-of select="system-property('xsl:version')"/>
XSLT Vendor = <xsl:copy-of select="system-property('xsl:vendor')"/>
XSLT Vendor URL = <xsl:copy-of select="system-property('xsl:vendor-url')"/>
</xsl:comment>