1<?xml version="1.0"?> 2 3<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" 4xmlns:set="http://exslt.org/sets" > 5 6<!-- Test set:difference --> 7 8<xsl:variable name="i" select="//city[contains(@name,'i')]"/> 9<xsl:variable name="e" select="//city[contains(@name,'e')]"/> 10<xsl:variable name="B" select="//city[contains(@name,'B')]"/> 11 12<xsl:template match="/"> 13 <out> 14 Containing i and no e: 15 <xsl:for-each select="set:difference($i, $e)"> 16 <xsl:value-of select="@name"/>; 17 </xsl:for-each> 18 Containing e and no i: 19 <xsl:for-each select="set:difference($e, $i)"> 20 <xsl:value-of select="@name"/>; 21 </xsl:for-each> 22 Containing B and no i and no e: 23 <xsl:for-each select="set:difference(set:difference($B,$i),$e)"> 24 <xsl:value-of select="@name"/>; 25 </xsl:for-each> 26 27 <!-- test difference on empty sets --> 28 29 Containing i: 30 <xsl:for-each select="set:difference($i, /..)"> 31 <xsl:value-of select="@name"/>; 32 </xsl:for-each> 33 Containing B: 34 <xsl:for-each select="set:difference($B, /..)"> 35 <xsl:value-of select="@name"/>; 36 </xsl:for-each> 37 Empty set: 38 <xsl:for-each select="set:difference(/.., $i)"> 39 <xsl:value-of select="@name"/>; 40 </xsl:for-each> 41 </out> 42</xsl:template> 43 44 45 <!-- 46 * Licensed to the Apache Software Foundation (ASF) under one 47 * or more contributor license agreements. See the NOTICE file 48 * distributed with this work for additional information 49 * regarding copyright ownership. The ASF licenses this file 50 * to you under the Apache License, Version 2.0 (the "License"); 51 * you may not use this file except in compliance with the License. 52 * You may obtain a copy of the License at 53 * 54 * http://www.apache.org/licenses/LICENSE-2.0 55 * 56 * Unless required by applicable law or agreed to in writing, software 57 * distributed under the License is distributed on an "AS IS" BASIS, 58 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 59 * See the License for the specific language governing permissions and 60 * limitations under the License. 61 --> 62 63</xsl:stylesheet> 64