|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Find First Descendants That Match Predicate?
Using XPath 3:
o;?I have an XML structure where there are elements with titles (e.g.,
foo/title, bar/title) that may have an arbitrary of untitled wrappers around
them, e.g.:
<root>
<chapter><title>C1</chapter>
<wrapper>
<wrapper>
<section><title>S1</section>
</section>
</wrapper>
<section><title>S2</title>
<section><title>S3</title>
</section>
</section>
</wrapper>
Given a starting node, e.g., the root node (but could be any node in the
hierarchy) I need to find the first titled "child" nodes, so given the chapter
node I need to find S1 and S2 but not S3.
I need to do this in a single XPath expression (I'm using the expression to
get a list of nodes that are then being used elsewhere).
I can't figure out how to construct an expression so that it only returns the
descendants of the starting node that match the predicate (e.g. *[title]) and
that are the first such in a breadth-first evaluation.
I feel like there's an obvious solution that I'm just not seeing.
Thanks,
Eliot
--
Eliot Kimber
http://contrext.com
|
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
|

Cart








