[xsl] selecting nodes based on a descendant property

Subject: [xsl] selecting nodes based on a descendant property
From: "Robert P. J. Day" <rpjday@xxxxxxxxxxxxxx>
Date: Tue, 11 Mar 2003 03:46:46 -0500 (EST)
  i'm working my way through john simpson's "xpath and xpointer"
book from o'reilly, and i have a question.

  as an exercise (p. 106-9 for those who have the book), simpson
starts by asking to find all "sign" elements that have a "part"
descendant whose name (that is, text() value) ends with "s".

  to get the latter, he starts with

  //part[substring(., string-length(.), 1) = "s"]

and to then select all "sign" ancestors of this node set, he appends

  //part[substring(., string-length(.), 1) = "s"]/ancestor::sign


  it seems that a much clearer way would be to use

  //sign[descendant::part[substring(., string-length(.), 1) = "s"]

i'm testing a variation of this on his sample file using "xpathtester",
and it *seems* to give me the same result, as well as being (to me
at least) more intuitive.

  does this really correspond to the same node set?  or is there
something subtle here i'm not seeing?

rday


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


Current Thread