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

Re: filtering elements by single xpath

Subject: Re: filtering elements by single xpath
From: "andrew welch" <andrew.j.welch@xxxxxxxxx>
Date: Wed, 5 Apr 2006 16:08:20 +0100
Re:  filtering elements by single xpath
On 4/5/06, Tomas Kolaci <kolaci@xxxxxxx> wrote:
>  Hi!
>
>  I'm using XSLT 1.1 and Saxon 6.5.3.
>
>  I have following XML structure:
>
> <root>
>    <body>
>       <item pos="1" name="n1"/>
>       <item pos="2" name="n2"/>
>       <item pos="3" name="n2"/>
>       <item pos="4" name="n3"/>
>       <item pos="5" name="n4"/>
>    </body>
>    <item-filter>
>       <allow-items with-name="n2"/>
>       <allow-items with-name="n4"/>
>    </item-filter>
> </root>
>
> and in template:
>
> <xsl:template match="body">
>    <xsl:variable
>      name="filtered-items"
>      select="item[/root/item-filter/allow-items[@with-name = ???/@name]"
>    />
>    ...
> </xsl:template>
>
> I'm trying to fill variable filtered-items with elements item with
"allowed"
> name (= there is an element /root/item-filter/allow-items with attribute
> @with-name containing same value as item's @name)*, but I don't know how to
> reach current item on ??? position in my select (function current() points
> to current body element).

use current()/item-filter/allow-items/@with-name

alternatively create a key

<xsl:key name="allowed-items" match="allow-items" use="@with-name"/>

and then check if the node exists in the key with that value

select="item[key('allowed-items', @name)]"

cheers
andrew

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

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

Buy Stylus Studio Now

Cast Your Vote

We need your help – Vote for DataDirect XML Products!

  • Best SOA or XML site

Winners and finalists announced at SOA World Conference in November.

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