You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by Daniel Barclay <Da...@digitalfocus.com> on 2001/04/09 19:27:28 UTC

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