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

Re: compare two lists of values question

Subject: Re: compare two lists of values question
From: Dimitre Novatchev <dnovatchev@xxxxxxxxx>
Date: Tue, 7 Aug 2001 21:09:27 -0700 (PDT)
compare two lists
Friedlander, Hal wrote:

> I need to compare two lists of values and display the value of any name
> element not in both lists.
> The xml is like this:
> <Merchants>
> <USMerchants>
> 	<name>store1</name>
> 	<name>store2</name>
> 	<name>store3</name>
> 	<name>store4</name>
> 	<name>store5</name>
> 	<name>store6</name>
> </USMerchants>
> <UKMerchant>
> 	<name>store1</name>
> 	<name>store2</name>
> 	<name>store3</name>
> 	<name>store4</name>
> 	<name>store5</name>
> 	<name>store99</name>
> </UKMerchant>
> </Merchants>

Hi Hal,

Assumng that a name cannot appear more than once in a list (which seems to be your
case), then a simple way to achieve the desired result is as follows:

<xsl:key name="kName" match="name" use="."/>

Using the above xsl:key, the following XPath expression returns a node-set of all
names that appear only once (and therefore only in one of the lists).

/Merchants/*/name[count(key('kName', .)) = 1]

Hope this helped.

Cheers,
Dimitre Novatchev.

__________________________________________________
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail
http://personal.mail.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.