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

Re: union and difference

Subject: Re: union and difference
From: Dan Diebolt <dandiebolt@xxxxxxxxx>
Date: Sun, 13 May 2001 06:17:25 -0700 (PDT)
select difference union
Your definitions for $set1 and $set2:

  <xsl:variable name="set1" select="set1"/> 
  <xsl:variable name="set2" select="set2"/> 

will always result in *disjoint* node-sets. $set1 contains the first
four <set1> nodes while $set2 contains the first four <set2> nodes.
Since a <set1> node is always distinct from a <set2> nodes, these two 
node-sets will never have any nodes in common.
Therefore, when you attempt set intersection with

  select="$set1[count(.|$set2)=count($set2)]"> 

you get an empty node-set and when you attempt set difference with

  select="$set1[count(.|$set2)!=count($set2)]"> 

you get all four nodes in $set1.

The situation is different when you use

  select="$set1[. = $set2]"
  select="$set1[not(. = $set2)]"

Here you are comparing the *text* values of the nodes in node-sets
$set1 and $set2. The first select statement returns the nodes in
$set1 (ie <set1> nodes) which have the same text value as nodes 
in node-set $set2. The second select statement returns the nodes 
in $set1 which do not have the same text value as nodes in node-set 
$set2. You might contrast these two select statements with the 
following:

  select="$set2[. = $set1]"
  select="$set2[not(. = $set1)]"

These statements while having similar set logic, return nodes in 
$set2 (ie <set2> nodes) not nodes in $set1 (ie <set1> nodes).

Finally, I am not sure I agree with another reply with regard
to merging of text nodes. I beleive the following definition of
$set1 will in fact have four distinct nodes:

  <xsl:variable name="set1" select="set1/text()"/>
  <xsl:value-of select="count($set1)"/>

Adjacent text nodes get merged on occassion but perhaps 
some could clarify precisely when this happens as I am not 
100% certain.

Regards,

Dan

__________________________________________________
Do You Yahoo!?
Yahoo! Auctions - buy the things you want at great prices
http://auctions.yahoo.com/

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


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-2013 All Rights Reserved.