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 支援情況
支援。