xsl-list
[Top] [All Lists]

Re: Re: why is "(chapter//footnote)[1]" illegal?

2003-08-23 10:15:38
Because the first is illegal *pattern* (it is a legal XPath expression).

Patterns are a strict subset of XPath expressions.

Patterns were introduced (in my opinion) to allow for some optimization
opportunities as well as for sanity in the template matching and
instantiation process.

i can see why, *technically*, the above holds.  i guess my confusion
is more that it's just non-intuitive, particularly since (according to
kay, p. 355), the expression "($chapters//diagram)[1]" is legal.

so, we have

(chapter/para)[1] legal

Wrong!  This is not a legal match pattern

(chapter//footnote)[1] illegal
($chapters//diagram)[1] legal

while i'm sure all of this holds according to the acceptable rules
of patterns,

No, it doesn't hold -- see above.

it sure doesn't do any favors for those looking for
obviously intuitive rules for what's legal and what isn't.



Once again -- your problem is that you are comparing arbitrary XPath
expressions to *patterns*.

Such comparison can be very biased -- if someone was familiar with patterns
and just now learned about XPath expressions, he/she would probably ask why
some XPath expressions are legel.

Patterns are not at all the same as XPath expressions! They are a strictly
limited subset of the set of all possible XPath expressions.

So, the rules for patterns are not at all the same as the rules for XPath
expressions -- they have to eliminate a large class of XPath expressions,
which are not patterns.




=====
Cheers,

Dimitre Novatchev.
http://fxsl.sourceforge.net/ -- the home of FXSL



"Robert P. J. Day" <rpjday(_at_)mindspring(_dot_)com> wrote in message
news:Pine(_dot_)LNX(_dot_)4(_dot_)44(_dot_)0308231126040(_dot_)2185-100000(_at_)localhost(_dot_)localdomain(_dot_)(_dot_)(_dot_)
On Sat, 23 Aug 2003, Dimitre Novatchev wrote:


"Robert P. J. Day" <rpjday(_at_)mindspring(_dot_)com> wrote in message
news:Pine(_dot_)LNX(_dot_)4(_dot_)44(_dot_)0308230904470(_dot_)1866-100000(_at_)localhost(_dot_)localdomain(_dot_)(_dot_)(_dot_)

  boning up on my predicates and patterns, i'm reading
kay, p. 443, which states:

  "(chapter//footnote)[1] is not a valid pattern.  (Why not?
No good reason, it's just that the spec doesn't allow it."

It cannot be derived from the syntax of "Patterns" as specified in

http://www.w3.org/TR/xslt#patterns

If you remove the brackets you'll get a valid match pattern.


  but on p. 408, there is an explanation of the (apparently
acceptable) path expression "(chapter/para)[1]".

  so is it just the difference between using the child axis
and the descendant-or-self axis?  it's not obvious to me
why the first should be illegal while the second is legal.

Because the first is illegal *pattern* (it is a legal XPath expression).

Patterns are a strict subset of XPath expressions.

Patterns were introduced (in my opinion) to allow for some optimization
opportunities as well as for sanity in the template matching and
instantiation process.

i can see why, *technically*, the above holds.  i guess my confusion
is more that it's just non-intuitive, particularly since (according to
kay, p. 355), the expression "($chapters//diagram)[1]" is legal.

so, we have

(chapter/para)[1] legal
(chapter//footnote)[1] illegal
($chapters//diagram)[1] legal

while i'm sure all of this holds according to the acceptable rules
of patterns, it sure doesn't do any favors for those looking for
obviously intuitive rules for what's legal and what isn't.

rday


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






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



<Prev in Thread] Current Thread [Next in Thread>