You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by "Voytenko, Dimitry" <DV...@SECTORBASE.COM> on 2001/04/09 20:06:56 UTC
RE: Xalan doesn't seem to enforce XSLT grammar - am I missing som
ething?
Hi Tak Sze and Daniel,
I believe Daniel is right. Id can take expressions as parameters but it's
not case for patterns. XSLT 1.0/XPath 1.0 specifications say very neatly
about these cases. And id(1+2) is illegal as it doesn't conform to grammar
rules specified for patterns. So it shouldn't go that far to applying
string() function.
I didn't find any corrections in sepcification or additional restrictions
(as for match attribute in XSLT 1.1). So Daniel is right.
-----Original Message-----
From: Sze, Tak F [mailto:tak.f.sze@intel.com]
Sent: Monday, April 09, 2001 10:55
To: 'xalan-dev@xml.apache.org'
Subject: RE: Xalan doesn't seem to enforce XSLT grammar - am I missing som
ething?
Daniel,
The XPath description on the id function indicates the argument to
the id function can be a number:
"The id function selects elements by their unique ID (see [5.2.1 Unique
IDs]).
When the argument to id is of type node-set, then the result is the union of
the result of applying id to the string-value of each of the nodes in the
argument node-set. When the argument to id is of any other type, the
argument
is converted to a string as if by a call to the string function; the string
is
split into a whitespace-separated list of tokens (whitespace is any
sequence
of characters matching the production S); the result is a node-set
containing
the elements in the same document as the context node that have a unique ID
equal to any of the tokens in the list."
- Tak Sze
> -----Original Message-----
> From: Daniel Barclay [mailto:Daniel.Barclay@digitalfocus.com]
> Sent: Monday, April 09, 2001 10:27 AM
> Subject: Xalan doesn't seem to enforce XSLT grammar - am I missing
> something?
>
>
> Xalan doesn't seem to enforce the syntax given in the XSLT
> specification.
>
> Can someone tell me if I'm missing something?
>
> In my stylesheet, I have this instruction:
>
> <xsl:number count="id(1 + 2)" />
>
>
> In the XSLT specification, section 7.7, Numbering, defines
> that the count
> attribute of the xsl:number instruction is a pattern:
>
> The count attribute is a pattern that specifies what nodes
> should be counted
> at those levels. ...
>
> Section 5.2 says that a pattern must follow the syntax for Pattern,
> giving the syntax as:
>
> [1] Pattern ::= LocationPathPattern
> | Pattern '|'
> LocationPathPattern
>
> [2] LocationPathPattern ::= '/' RelativePathPattern?
> | IdKeyPattern (('/'
> | '//') RelativePathPattern)?
> | '//'? RelativePathPattern
>
> [3] IdKeyPattern ::= 'id' '(' Literal ')'
> | 'key' '(' Literal
> ',' Literal ')'
>
> ...
>
> My count string "id(1 + 2)" does not match the second form of Pattern
> (Pattern ::= Pattern '|' LocationPathPattern), so must match the first
> form, so it's a LocationPathPattern or is illegal.
>
> As a LocationPathPattern, the string "id(1 + 2)" does not
> match the first
> or third forms of LocationPathPattern, so it must be the
> second case, and
> must be an IdKeyPattern (or illegal).
>
> As an IdKeyPattern, the string "id(1 + 2)" does not match the
> second form,
> so it must be an IDKeyPattern of the first form, and the
> string "1 + 2"
> must be a Literal (or be illegal).
>
> The string clearly does _not_ match the production for
> Literal (from section
> 3.7):
>
> [29] Literal ::= '"' [^"]* '"'
> | "'" [^']* "'"
>
> Therefore, the instruction
>
> <xsl:number count="id(1 + 2)" />
>
> contains illegal syntax.
>
>
> So, my example contains illegal syntax, but Xalan doesn't
> detect and reject my
> example. Why not?
>
>
> Is there an error in my analysis?
>
> Is there an error in the XSLT specification?
>
> Is there a bug in Xalan?
>
> Does Xalan not attempt to report errors in the XSL?
>
>
> Thanks,
> Daniel
> --
> Daniel Barclay
> Digital Focus
> Daniel.Barclay@digitalfocus.com
>