xsl-list
[Top] [All Lists]

RE: select immediately following siblings with constraints?

2006-02-23 12:10:38
XPath gives 
no way to look along an axis up to a particular point and no further. 
(Well, actually I shouldn't say this categorically about XPath 2.0 
without giving it some good hard thought first, or inviting others to 
demonstrate a method. :-) 

Let's say you want all the nodes on a forwards axis X up to and excluding
the first one that satisfies condition PRED. Then you can write

for $stop in x::node()[PRED][1] return x::node()[.<<$stop]

substituting >> if it's a reverse axis. If you want to include the stop
node, 

return (x::node()[.<<$stop], $stop)

It's not vastly elegant - this is one of those things that could have been
done so much better with higher-order functions - but it's workable. It's
not too difficult to optimize, either, though Saxon doesn't attempt this
currently.

Michael K



--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--