EXSLT - set:has-same-node - Use Case 1

Category: example
XML Definition: set.has-same-node.xml
Function or Template: function

Use Case

Source (view)

<doc>
   <city name="Paris"
         country="France"
         xmlns:x="one" />
   <city name="Madrid"
         country="Spain"
         xmlns:x="one" />
   <city name="Vienna"
         country="Austria"
         xmlns:x="one" />
   <city name="Barcelona"
         country="Spain"
         xmlns:x="one" />
   <city name="Salzburg"
         country="Austria"
         xmlns:x="one" />
   <city name="Bonn"
         country="Germany"
         xmlns:x="one" />
   <city name="Lyon"
         country="France"
         xmlns:x="one" />
   <city name="Hannover"
         country="Germany"
         xmlns:x="one" />
   <city name="Calais"
         country="France"
         xmlns:x="one" />
   <city name="Berlin"
         country="Germany"
         xmlns:x="one" />
</doc>

Stylesheet (view)

<!--  Test set:has-same-node  -->
<xsl:variable name="a1"
              select="//city[@name='Vienna' or @name='Salzburg']" />
<xsl:variable name="a2"
              select="//city[@country='Austria']" />
<xsl:template match="/">
   <out>

    Test has-same-node() between two intersecting sets:
          <xsl:if test="set:has-same-node($a1,$a2)">OK</xsl:if>
;
    Test has-same-node() between two non-intersecting sets:
          <xsl:if test="not(set:has-same-node($a1,//city/@name))">OK</xsl:if>
;
    Test has-same-node() between two identical sets of namespace nodes:
          <xsl:if test="set:has-same-node((//city[1])/namespace::*,(//city[1])/namespace::*)">OK</xsl:if>
;        
    Test has-same-node() between two disjoint sets of namespace nodes:
          <xsl:if test="not(set:has-same-node((//city[1])/namespace::*,(//city[2])/namespace::*))">OK</xsl:if>
;        
  
   </out>
</xsl:template>

Result (view)

<out xmlns:set="http://exslt.org/sets">
    Test has-same-node() between two intersecting sets:
    OK;
    Test has-same-node() between two non-intersecting sets:
    OK;
    Test has-same-node() between two identical sets of namespace nodes:
    OK;        
    Test has-same-node() between two disjoint sets of namespace nodes:
    OK;        
  </out>

Change History

Previous Version: ..NaN.html

VersionModifiedByDetails
12001-04-28Mike Kay

Tests functionality of set:has-same-node().

http://www.exslt.org/set/functions/has-same-node/set.has-same-node.use-case.1.html last modified 2001-04-28