Description
The functx:index-of-node function returns one or more integers representing the position of an XML node within a sequence of nodes. It is based entirely on node identity, not the value or content of the nodes.
Arguments and Return TypeName | Type | Description |
$nodes |
node()* |
the node sequence |
$nodeToFind |
node() |
the node to find in the sequence |
return value |
xs:integer* |
XSLT Function DeclarationSee XQuery definition. | <xsl:function name="functx:index-of-node" as="xs:integer*"
xmlns:functx="http://www.functx.com">
<xsl:param name="nodes" as="node()*"/>
<xsl:param name="nodeToFind" as="node()"/>
<xsl:sequence select="
for $seq in (1 to count($nodes))
return $seq[$nodes[$seq] is $nodeToFind]
"/>
</xsl:function>
|
Examples<xsl:variable name="in-xml" as="item()*"> | | <authors>
<author>
<fName>Kate</fName>
<lName>Jones</lName>
</author>
<author>
<fName>John</fName>
<lName>Doe</lName>
</author>
</authors> |
| </xsl:variable> |
XPath Example | Results |
---|
functx:index-of-node(
$in-xml/author,$in-xml/author[1]) |
1 |
functx:index-of-node(
$in-xml/author,$in-xml/author[2]) |
2 |
functx:index-of-node(
$in-xml/author,
$in-xml/author[lName='Doe']) |
2 |
See AlsoHistoryPublished On | Last Updated | Contributor(s) |
---|
2006-06-27 | 2007-02-26 | W3C XML Query Working Group, XQuery 1.0 and XPath 2.0 Functions and Operators, http://www.w3.org/TR/xpath-functions/(parameter names changed for clarity) |
|
Recommended Reading:
|