home contribute faq download

FunctX XSLT Functions

functx:sequence-deep-equal

Whether two sequences have the same XML node content and/or values

Google
Webxsltfunctions.com

Description

The functx:sequence-deep-equal function returns a boolean value indicating whether the two sequences have the same content or values, in the same order. To compare items, it uses the built-in fn:deep-equal function. The argument sequences can contain nodes or atomic values or both. For nodes, it compares them based on their contents and attributes, not their node identity. For atomic values, it compares them based on their typed values.

Arguments and Return Type

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

XSLT Function Declaration

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

  <xsl:sequence select="
  every $i in 1 to max((count($seq1),count($seq2)))
  satisfies deep-equal($seq1[$i],$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 ExampleResults
functx:sequence-deep-equal(
     $in-xml/author/*, $in-xml/*/*)
true
functx:sequence-deep-equal(
     $in-xml/author[1], $anAuthor)
true
functx:sequence-deep-equal(
     (1,2,3), (1.0,2.0,3.0))
true

See Also

fn:deep-equalWhether two nodes have the same content and attributes
functx:sequence-node-equalWhether two sequences contain the same XML nodes, in the same order
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, http://www.datypic.com
Datypic XSLT Services

Recommended Reading:

XQuery