非常教程

Xslt & Xpath参考手册

XPath 函数 | XPath Functions

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>

定义

XPath 1.0 4.1

gecko支持

支持的。

Xslt & Xpath

XSLT 是扩展样式表转换语言 的外语缩写,这是一种对 XML(标准通用标记语言的子集)文档进行转化的语言,XSLT 中的 T 代表英语中的“转换”(Transformation)。它是 XSL(eXtensible Stylesheet Language)规范的一部分

Xslt & Xpath目录

1.其他杂项 | Miscellaneous
2.XPath 轴 | XPath Axes
3.XSLT元素 | XSLT Elements
4.XPath 函数 | XPath Functions
5.XPath 教程
6.XPath 实例
7.XPath 运算符
8.XPath 轴(Axes)
9.XPath 语法
10.XPath 节点
11.XPath 简介
12.XPath、XQuery 以及 XSLT 函数
13.XPath 总结