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

Re: selecting from sequences

Subject: Re: selecting from sequences
From: "Andrew Welch" <andrew.j.welch@xxxxxxxxx>
Date: Thu, 18 Dec 2008 16:08:18 +0000
Re:  selecting from sequences
> In my style sheet I make a selection of the elements and pass that to a
> template. In that template I can reference this sequence as $seq.
>
> Selecting from $seq appears to be not that easy, because I can't use axes.
> Axes have a document scope whereas I want to do something within the
> sequence.
> If for example $seq contains elements a, b, c, b, e:
>
> how do I select
> - everything before the first b
> - everything from the first b to the end
> - the position of the first b?
>
> As $seq[self::b][1]/preceding-sibling::* is not good because it possibly
> selects element outside the sequence, but are preceding-siblings in the
> document.

$seq[self::b][1]/preceding-sibling::* intersect $seq

would restrict the elements to those in the sequence

The alternative is to copy the nodes into a variable and use that
instead of a sequence, or course refactor your transform so that the
selection and processing aren't separate steps (usually they're not)


-- 
Andrew Welch
http://andrewjwelch.com
Kernow: http://kernowforsaxon.sf.net/

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.