position
XSLT/XPath Справочник: XSLT элементы, Функции EXSLT, Функции XPath, Оси XPath
Функция position возвращает число, равное позиции контекста из контекста оценки выражения.
Синтаксис
position()
Возвращаемое значение
Целое число, равное позиции контекста в контексте оценки выражения.
Примечания
- Обратите внимание, что позиция узла в контексте не нулевая. У первого узла позиция 1.
- Контекст определяется остальной частью пути.
<xsl:template match="//a[position() = 5]"> <!-- this template matches the fifth a element anywhere in the document. --> </xsl:template>
<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
Поддерживается.
© 2005–2022 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/XPath/Functions/position