Previous | Next | Indexes
Zvon > Tutorials > XSLT 2.0 Tutorial > Comparisons (2/6) >

Operator "=" and sequences

If a sequence is compared with a single item, the operator "=" returns True if the sequence contains the item. If two sequences are compared "true" is returned if sequences share at least one member.

XSLT

      <xsl:stylesheet
                  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                  version="2.0">
            <xsl:output  method="xml"
                        indent="yes"
                        omit-xml-declaration="yes"/>

            <xsl:template  match="/aaa">
                  <xxx>
                        <xsl:value-of  select="if ((1 to 5) = (5 to 13)) then 1 else 0"/>
                  </xxx>
                  <yyy>
                        <xsl:value-of  select="if (5 = (1 to 9)) then 1 else 0"/>
                  </yyy>
                  <zzz>
                        <xsl:value-of  select="if ((1,2,3) = (4,5,6)) then 1 else 0"/>
                  </zzz>
            </xsl:template>

      </xsl:stylesheet>
XML

      <aaa/>
Output

      <xxx>1</xxx>
      <yyy>1</yyy>
      <zzz>0</zzz>


Previous chapter: Stylesheet Functions
Next chapter: Conditional Expressions
Previous page: General Comparisons
Next page: Operator != and sequences