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

Find First Descendants That Match Predicate?

Subject: Find First Descendants That Match Predicate?
From: "Eliot Kimber ekimber@xxxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Mon, 24 Dec 2018 20:57:32 -0000
 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

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.