|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: compare two lists of values question
Hal,
The following stylesheet should do the trick:
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text"/>
<xsl:key name="us_merchants" match="USMerchants/name" use="."/>
<xsl:key name="uk_merchants" match="UKMerchants/name" use="."/>
<xsl:template match="/">
<xsl:for-each select="/Merchants/*/name">
<xsl:if test="( key( 'us_merchants', . ) and
not( key( 'uk_merchants', . ) )
)
or
( key( 'uk_merchants', . ) and
not( key( 'us_merchants', . ) )
)">
<xsl:value-of select="."/>
<xsl:text> is not in both lists.
</xsl:text>
</xsl:if>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
Please note that I changed the name of the
UKMerchant element to "UKMerchants".
Hope this helps.
Bob
<sig name = 'Bob Lyons'
title = 'XML Consultant'
company = 'Unidex, Inc.'
phone = '+1-732-975-9877'
email = 'boblyons@xxxxxxxxxx'
url = 'http://www.unidex.com/'
product = 'XML Convert: transforms flat files to XML and vice versa' />
-----Original Message-----
I'm assuming this is kind of a novice level question.
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>
Using MSXML3 parser.
Thanks in advance,
Hal Friedlander
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








