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

XPath riddle

Subject: XPath riddle
From: Nicholas Giannadakis <ngiann@xxxxxxxxxx>
Date: Wed, 4 Jul 2001 21:19:39 +0300 (EET DST)
message encoding riddle
 Dear All,

 Can you tell what the XPath expression that:
 "selects all C elements that come after A and have a D parent" is.

 That is, there might be a schema, which declares the unwanted instances of C
 as integers, while
 the other C declared has some anonymous complexType.

 <?xml version="1.0" encoding="UTF-8"?>
 <A>
         <B>
                 <C/>                                            <!-- DO NOT select this -->
                 <D>
                         <!-- recursion is introduced here -->
                         <C>                                     <!-- select this -->
                                 <B>
                                         <C/>                    <!-- DO NOT select this -->>
                                         <D>
                                                 <C/>            <!-- select this -->
                                         </D>
                                 </B>
                         </C>
                 </D>
         </B>
 </A>

 /A//D/C (/A/descendant::D/C) would suffice, or, better, /A//B/D/C
 (/A/descendant::B/D/C). But this would not rule out the possibility of the
 B/D/C pattern appearing somewhere after A in another context. I cannot find
 any XPath feature that would handle recursion.

 <?xml version="1.0" encoding="UTF-8"?>
 <A>
         <B>
                 <F>
                         <B>
                                 <D>
                                         <C/>                    <!-- this would be selected incorrectly -->
                                 </D>
                         </B>
                 </F>
                 <D>
                         <!-- recursion is introduced here -->
                         <C>                                     <!-- select this -->
                                 <B>
                                         <C/>                    <!-- DO NOT select this -->
                                         <D>
                                                 <C/>            <!-- select this -->
                                         </D>
                                 </B>
                         </C>
                 </D>
         </B>
 </A>

 Using /A/B/D/C | /A/B/D/C//B/D/C would overcome this, but you can see how I
 could create another problematic example...
 How does one find one's way around this, using a generic XPath approach?
 I am not saying this is good XML design. To the contrary! ... it is legal,
 nonetheless ...any ideas?

 regards,

 nikolas/



 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread
  • XPath riddle
    • Nicholas Giannadakis - Wed, 4 Jul 2001 14:25:38 -0400 (EDT) <=

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.