XPath and Ranges

View: New views
2 Messages — Rating Filter:   Alert me  

XPath and Ranges

by David White-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Hello All,

Is it possible to use Xpath to select a range of nodes.

<chapter>
<title>X</title>
<para>
<para>
<title>Y</title>
</chapter>

I would like an Xpath statement that would select //title[1] THROUGH //title[2] and include all nodes between.  Is this possible?

I'm currently using XMLSpy professional but not having much luck finding a solution.

Thanks,

David White



Re: XPath and Ranges

by David Carlisle :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message



This is the wrong list (it is for formal comments on the xpath
specification, ratherthan on xpath expample problems), you want
xsl-list@...

but in xpath2

/chapter/(title[1]/(.,following-sibling::node()) except title[2]/(.,following-sibling::node())

is probably the most literal translation into xpath, but others are
possible eg

for $end in /chapter/title[2]
return
/chapter/(title[1]/(.,following-sibling::node()[. <<  $end],$end)

In XPath1 it's probably hard to do but in xpath1+xslt1 (so you can define
variables) then again it's possible.

David