[xquery-talk] VarRef

Sijo Mathew sijo at atinav.com
Mon May 30 10:50:02 PDT 2005


I am new to the XQuery Specification. I am also having
similar confusions in different places in the grammar. One
main difference that I could see in the grammar specifications
of XML and that of XQuery was in the use of space.

XML grammar specifies the use of white spaces clearly by
using the white space nonterminal 'S'.

S   ::=   (#x20 | #x9 | #xD | #xA)+

But, it seeems that, XQuery spec is not using the same in
such situations.

>> Yes. The question keeps coming up. A lot of people think
>> this rule is strange, and I've never understood why.

You could have defined the non-terminal 'VarRef ' as below,

[84] VarRef    ::=    "$" S? VarName

which will definitely help to avoid similar questions.

regards
Sijo


----- Original Message ----- 
From: "Michael Kay" <mhk at mhk.me.uk>
To: "'Bob Foster'" <bob at objfac.com>; <talk at xquery.com>
Sent: Monday, May 30, 2005 4:38 AM
Subject: RE: [xquery-talk] VarRef


> >
> > The April 2005 XQuery spec has:
> >
> > [84] VarRef    ::=    "$" VarName
> >
> > This says that "$x" and "$   x" are equivalent VarRefs. Is
> > this intentional?
> >
>
> Yes. The question keeps coming up. A lot of people think this rule is
> strange, and I've never understood why. Spaces are allowed in "@xyz" and
in
> "true()" and "text()", so why shouldn't they be allowed in "$xyz"?
>
> Perhaps it's because in XQuery you declare a variable as "declare variable
> $xyz" so the "$" seems to be part of the name. In XSLT you write
> <xsl:variable name="xyz"> so the $ clearly isn't part of the variable
name,
> any more than "@" is part of an attribute name.
>
> The benefit of allowing spaces (and comments) here is not that users
> actually want to write spaces or comments here but that the grammar is
> simpler and more consistent if it allows them than if it prohibits them.
>
> Michael Kay
>
>
> _______________________________________________
> talk at xquery.com
> http://xquery.com/mailman/listinfo/talk



More information about the talk mailing list