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

Re: processin each element not on a list

Subject: Re: processin each element not on a list
From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx>
Date: Sat, 5 Oct 2002 13:36:24 +0100
Re:  processin each element not on a list
Hi Dan,

> I have xml in substantially the following form:
>
> <root>
>  <choices>
>   <choice>A</choice>
>   <choice>B</choice>
>   <choice>C</choice>
>   <choice>D</choice>
>  </choices>
>  <items>
>   <item id="1">A</item>
>   <item id="2">X</item>
>   <item id="3">B</item>
>   <item id="4">C</item>
>   <item id="5">Y</item>
>   <item id="6">Z</item>
>  </item>
> </root>
>
> I need to process each item where its content is not one of the
> choice values. I need a very efficient solution since I have say
> up to 10,000 <items>s and perhaps 100 difference <choice>'s. 

OK, then I think you should set up a key on the choices so that, given
an item value, you can quickly see whether it's on the list of choices
by looking up the key:

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

Then, in order to select all the items whose content is *not* one of
the choice items, you can find those items that don't return a node
when you use the key to do the lookup:

  /root/items/item[not(key('choices', .))]

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.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.