position
position 函数返回一个数字,该数字等于表达式求值上下文中的上下文位置。
语法
position()
返回值
一个等于表达式求值上下文中的上下文位置的整数。
描述
-
请注意,节点在上下文中的位置不是从零开始的。第一个节点的位置是 1。
-
上下文由路径的其余部分确定。
xml<xsl:template match="//a[position() = 5]"> <!-- this template matches the fifth a element anywhere in the document. --> </xsl:template>xml<xsl:template match="//div[@class='foo']/bar[position() = 1]"> <!-- this template matches the first bar element that is a child of a div element with a class attribute equal to "foo" --> </xsl:template>
规范
Gecko 支持情况
支持。