home contribute faq download

FunctX XSLT Functions

functx:sequence-node-equal

Whether two sequences contain the same XML nodes, in the same order

Google
Webdatypic.com

Description

The functx:sequence-node-equal function returns a boolean value indicating whether the two arguments have the same nodes, in the same order. They are compared based on node identity, not their contents.

Arguments and Return Type

NameTypeDescription
$seq1 node()* the first sequence of nodes
$seq2 node()* the second sequence of nodes
return value xs:boolean

XSLT Function Declaration

See XQuery definition.
<xsl:function name="functx:sequence-node-equal" as="xs:boolean"
              xmlns:functx="http://www.functx.com">
  <xsl:param name="seq1" as="node()*"/>
  <xsl:param name="seq2" as="node()*"/>

  <xsl:sequence select="
  every $i in 1 to max((count($seq1),count($seq2)))
  satisfies $seq1[$i] is $seq2[$i]
 "/>

</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>
<xsl:variable name="anAuthor" as="item()*">
<author>
   <fName>Kate</fName>
   <lName>Jones</lName>
</author>
</xsl:variable>
XPath ExampleResultsExplanation
functx:sequence-node-equal(
     $in-xml/author/*, $in-xml/*/*)
true
functx:sequence-node-equal(
     $in-xml/author,
     ($in-xml/author[2],$in-xml/author[1]))
false
The order of the nodes is different.
functx:sequence-node-equal(
     $in-xml/author[1],$anAuthor)
false
Although the nodes have the same content, they are not the same node.

See Also

functx:sequence-deep-equalWhether two sequences have the same XML node content and/or values
functx:sequence-node-equal-any-orderWhether two sequences contain the same XML nodes, regardless of order

History

Published OnLast UpdatedContributor(s)
2006-06-272007-02-26Priscilla Walmsley, Datypic, pwalmsley@datypic.com, https://www.datypic.com
Datypic XSLT Services

Recommended Reading:

XQuery