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

Re: XPath for all of an element type prior to context

Subject: Re: XPath for all of an element type prior to context node?
From: Jeni Tennison <mail@xxxxxxxxxxxxxxxx>
Date: Thu, 1 Mar 2001 10:10:41 +0000
xpath get all element types
Hi Michael,

> When the context node is any of those with an id attribute, I want a way to
> get the list of resources nodes that occur:
>
> - before the context node; or
> - after the context node.

>From the source you posted, it looks as though the resource elements
aren't the ancestors or descendants of any of the nodes with id
attributes, so you should just be able to use:

  preceding::resource (to get those before the context node)
  following::resource (to get those after it)

If you're doing this a lot and have a long document, you may or may
not find it more efficient to use a couple of keys that index the
resource elements according to the nodes with id attributes that
they're before or after:

<xsl:key name="resources-before" match="resource"
         use="following::*/@id" />
<xsl:key name="resources-after" match="resource"
         use="preceding::*/@id" />

and then use:

  key('resources-before', @id) (to get those before the context node)
  key('resources-after', @id)  (to get those after it)
         
I hope that was what you were after,

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.