我想用括号在xslt中重写xpath中的默认运算符优先级,但没有运气。例如:在xpath/xslt中使用圆括号
<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:exsl="http://exslt.org/common"
extension-element-prefixes="exsl"
version="1.0">
<xsl:output encoding="utf-8" standalone="yes"/>
<xsl:template match="/">
<xsl:apply-templates select="*"/>
</xsl:template>
<xsl:template match="@* | node()">
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
</xsl:template>
<!--these should work but don't-->
<xsl:template match="//(X|Y|Z)/AABBCC"/>
<xsl:template match="(book/author)[last()]"/>
</xsl:stylesheet>
的Visual Studio 2010不会编译该返回:
意外标记 '(' 在表达// - >(< - X | Y | Z)/ AABBCC 。
意外标记 '(' 在表达 - >(< - 书/作者)[最后()]
然而,第二个例子是从MSDN:
http://msdn.microsoft.com/en-us/library/ms256086.aspx只
,并多次提到说,你可以以这种方式使用括号:
http://saxon.sourceforge.net/saxon6.5.3/expressions.html
http://www.stylusstudio.com/xsllist/200207/post90450.html
http://www.mulberrytech.com/quickref/XSLT_1quickref-v2.pdf
这是一个XPath 1.0 VS 2.0的事情...或者是有我失踪的其他东西?如果它是一个xpath 2.0的东西,是否有一个很好的xpath 1.0方法来做同样的事情?
感谢Martin和Lars ......我现在明白 – user109078 2011-05-26 17:18:11