[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: "Tomas Kolaci" <kolaci@xxxxxxx>
Date: Wed, 5 Apr 2006 17:59:14 +0200
kolaci
> > 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

 Thanks andrew, but I don't know how I could use it (plus I think you have
missed that item-filter is not child of body but it's brother), could you
please write complete select for me?

> 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)]"

 Great, this works, thanks!

 But xsl:key must be top-element, what if I had following 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"/>
      <item-filter>
         <allow-items with-name="n2"/>
         <allow-items with-name="n4"/>
      </item-filter>
   </body>
   <body>
      <item pos="1" name="n2"/>
      <item pos="2" name="n3"/>
      <item pos="3" name="n5"/>
      <item-filter>
         <allow-items with-name="n3"/>
      </item-filter>
   </body>
</root>

and wanted to filter items of each body element by it's own item-filter?

> cheers
> andrew

 Br, Tomas

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.