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

Re: how to select elements based on their children's n

Subject: Re: how to select elements based on their children's names?
From: "Dimitre Novatchev" <dnovatchev@xxxxxxxxx>
Date: Mon, 10 Mar 2003 22:42:52 +0100
xsl select any element
>   if i want to select all elements that have at least one, say,
> "book" child element, it seems i can do it this way:
>
>   //*[name(child::*) = "book"] long way
>   //*[name(*) = "book"] shorter way

These are both wrong -- they match all elements whose *first* child's name
is "book".

Elements, which have a child named "book", but it doesn't happen to be the
first child -- are not matched by these two expressions.

An expression satisfying your requirements is:

//*[book]

>
> 1) is this the easiest way to do it?

No, because it is not at all a way to do it -- see above.
>
> 2) why doesn't the following work as well?
>
>   //*[name(node()) = "book"]

See above -- in addition this might not return any node, if the first child
of any element happens to be one for which
name() is the empty string -- e.g. a text node.




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


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.