[xsl] Should "//ename[n]" mean "/descendant::ename"?

Subject: [xsl] Should "//ename[n]" mean "/descendant::ename"?
From: Mulberry Technologies List Owner <xsl-list-owner@xxxxxxxxxxxxxxxxxxxxxx>
Date: Tue, 18 Dec 2001 18:48:01 -0500
>Date: Tue, 18 Dec 2001 12:27:19 -0500
>To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
>From: Jonathan Robie <jwrobie@xxxxxxxxxxxxxx>
>Subject: Should "//ename[n]" mean "/descendant::ename"?

>I am playing around with some ideas that I would like some feedback on.
>Suppose XQuery and XPath 2.0 changed the meaning of "//" as follows:
>=> /descendant::ename[n]
>=> /descendant::*/attribute::aname[n]
>With this definition, "appendix//para[1]" would mean "the first paragraph
>in the appendix", rather than "the first paragraph in any element in the
>appendix". With the XPath 1.0 definition, you have to write
>"(appendix//para)[1]" to find the first paragraph in the appendix, and I
>find that I quite generally use parentheses any time that I combine "//"
>with subscripts.
>When asking what purpose the current definition serves, I have been told
>that "in the context of XSLT patterns, people use appendix//para[1] to
>format the first paragraph of every section within an appendix." This is
>the one usage I can think of where there would be compatibility issues. But
>this particular pattern does not really work - it applies not only to the
>first paragraph of every section, but also to the first paragraph of any
>table, editorial note, list...
>If you want it to apply to the first paragraph of every section, I think
>you should write:
>     appendix//section/para[1]
>I just looked through xmlspec.xsl and several other stylesheets, and could
>not find an instance where someone leverages // and [n] in the way outlined
>above. In my XQuery examples, on the other hand, virtually every query that
>uses // together with [n] requires parentheses in order to give the
>intended result. Also, some people have suggested that static typing is
>easier with the proposed definitions.
>So here are some questions:
>1. Is the proposed definition more intuitive?
>2. How many stylesheets would break under this definition?
>I am very interested in the feelings of the XSL community on these questions.

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

Current Thread