Description
The functx:index-of-deep-equal-node function returns one or more integers representing the position of an XML node within a sequence of nodes. Rather than being based on node identity, it is based on the equality of the name and content of the nodes, as defined by the built-in fn:deep-equal function. If $nodes does not contain a match, the function returns the empty sequence.
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-deep-equal-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[deep-equal($nodes[$seq],$nodeToFind)]
"/>
</xsl:function>
|
Examples<xsl:variable name="in-xml" as="item()*"> | | <authors>
<author>
<fName/>
<lName>Smith</lName>
</author>
<author>
<fName>Kate</fName>
<lName>Jones</lName>
</author>
<author>
<fName>John</fName>
<lName>Doe</lName>
</author>
</authors> |
| </xsl:variable> | <xsl:variable name="anAuthor" as="item()*"> | | <author>
<fName>Kate</fName>
<lName>Jones</lName>
</author> |
| </xsl:variable> | <xsl:variable name="anotherAuthor" as="item()*"> | | <author>
<fName>John</fName>
<lName>Smith</lName>
</author> |
| </xsl:variable> |
XPath Example | Results |
---|
functx:index-of-deep-equal-node(
$in-xml/author,$anAuthor) |
2 |
functx:index-of-deep-equal-node(
$in-xml/author,$anotherAuthor) |
() |
functx:index-of-deep-equal-node(
$in-xml/author/lName,$anAuthor/lName) |
2 |
See AlsoHistory |
Recommended Reading:
|