Altova Mailing List Archives


RE: [xsl] filtering elements by single xpath

From: "Tomas Kolaci" <kolaci@------->
To:
Date: 4/5/2006 4:00:00 PM
> > 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

Disclaimer

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.