[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: string set difference

Subject: Re: string set difference
From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx>
Date: Thu, 16 Dec 2010 13:17:02 -0500
Re:  string set difference
At 2010-12-16 20:06 +0200, Andriy Gerasika wrote:
Please help how to calculate set difference between string sequences in XSLT 2.0? (not node-sets)

This is simply the use of a predicate using "=" based on the principle of comparing sets of values.


I hope the example below helps.

. . . . . . . Ken

t:\ftemp>type andriy.xsl
<?xml version="1.0" encoding="US-ASCII"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns:xsd="http://www.w3.org/2001/XMLSchema"
                version="2.0">

<xsl:output method="text"/>

<xsl:template match="/">
  <xsl:variable name="s1" as="xsd:string*" select="'a','b','c','d','e','f'"/>
  <xsl:variable name="s2" as="xsd:string*" select="'c','d','e','f','g','h'"/>
  Difference: <xsl:value-of select="$s1[not(.=$s2)],$s2[not(.=$s1)]"/>
  Intersection: <xsl:value-of select="$s1[.=$s2]"/>
</xsl:template>

</xsl:stylesheet>

t:\ftemp>xslt2 andriy.xsl andriy.xsl

  Difference: a b g h
  Intersection: c d e f
t:\ftemp>




-- Contact us for world-wide XML consulting & instructor-led training Crane Softwrights Ltd. http://www.CraneSoftwrights.com/s/ G. Ken Holman mailto:gkholman@xxxxxxxxxxxxxxxxxxxx Legal business disclaimers: http://www.CraneSoftwrights.com/legal

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2011 All Rights Reserved.