[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
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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|