Modules | Implementer Page: set.difference.html Function Syntaxnode-set set:difference(node-set, node-set) Template Syntax<xsl:call-template name="set:difference"> <xsl:with-param name="nodes1" select="node-set" /> <xsl:with-param name="nodes2" select="node-set" /> </xsl:call-template>
The
The Implementations
The following XSLT processors support
Implementations of ExamplesFunctionThe following example shows how to use the Source<doc> <city name="Paris" country="France" /> <city name="Madrid" country="Spain" /> <city name="Vienna" country="Austria" /> <city name="Barcelona" country="Spain" /> <city name="Salzburg" country="Austria" /> <city name="Bonn" country="Germany" /> <city name="Lyon" country="France" /> <city name="Hannover" country="Germany" /> <city name="Calais" country="France" /> <city name="Berlin" country="Germany" /> </doc> Stylesheet<!-- Test set:intersection, difference --> <xsl:variable name="i" select="//city[contains(@name,'i')]" /> <xsl:variable name="e" select="//city[contains(@name,'e')]" /> <xsl:template match="/"> <out> Containing i and e: <xsl:for-each select="set:intersection($i, $e)"> <xsl:value-of select="@name" /> ; </xsl:for-each> Containing i and no e: <xsl:for-each select="set:difference($i, $e)"> <xsl:value-of select="@name" /> ; </xsl:for-each> Containing e and no i: <xsl:for-each select="set:difference($e, $i)"> <xsl:value-of select="@name" /> ; </xsl:for-each> <!-- test intersection and difference on empty sets --> Containing i: <xsl:for-each select="set:difference($i, /..)"> <xsl:value-of select="@name" /> ; </xsl:for-each> Empty set: <xsl:for-each select="set:intersection($i, /..)"> <xsl:value-of select="@name" /> ; </xsl:for-each> Empty set: <xsl:for-each select="set:intersection(/.., $i)"> <xsl:value-of select="@name" /> ; </xsl:for-each> Empty set: <xsl:for-each select="set:difference(/.., $i)"> <xsl:value-of select="@name" /> ; </xsl:for-each> </out> </xsl:template> Result<out xmlns:set="http://exslt.org/sets"> Containing i and e: Vienna; Berlin; Containing i and no e: Paris; Madrid; Calais; Containing e and no i: Barcelona; Hannover; Containing i: Paris; Madrid; Vienna; Calais; Berlin; Empty set: Empty set: Empty set: </out> |
http://www.exslt.org/set/functions/difference/index.html last modified 2002-11-12