Description
The functx:distinct-deep function compares nodes based on whether they are deep-equal, then returns only the first node with each distinct value. Two nodes are deep-equal if they have the same attributes with the same values, and all the same children, in the same order, that are themselves deep-equal.
Arguments and Return Type| Name | Type | Description |
$nodes |
node()* |
the sequence of nodes to test |
| return value |
node()* |
the distinct sequence of nodes |
XSLT Function Declaration| See XQuery definition. | | XSLT 2.0 Syntax: |
|---|
<xsl:function name="functx:distinct-deep" as="node()*"
xmlns:functx="http://www.functx.com" >
<xsl:param name="nodes" as="node()*"/>
<xsl:sequence select="
for $seq in (1 to count($nodes))
return $nodes[$seq][not(functx:is-node-in-sequence-deep-equal(
.,$nodes[position() < $seq]))]
"/>
</xsl:function>
|
Examples<xsl:variable name="in-xml" as="item()*"> | | <authors>
<author>
<fName>Kate</fName>
<lName>Jones</lName>
</author>
<author>
<fName>Kate</fName>
<lName>Jones</lName>
</author>
<author>
<fName>Kate</fName>
<lName>Doe</lName>
</author>
</authors> |
| </xsl:variable> |
| XSLT Example | Results |
|---|
functx:distinct-deep($in-xml//author)
|
<author>
<fName>Kate</fName>
<lName>Jones</lName>
</author>
<author>
<fName>Kate</fName>
<lName>Doe</lName>
</author>
|
functx:distinct-deep($in-xml//lName)
|
<lName>Jones</lName>
<lName>Doe</lName>
|
functx:distinct-deep($in-xml//fName)
|
<fName>Kate</fName>
|
Depends OnSee AlsoHistory |
|