[xquery-talk] VarRef

Michael Kay mhk at mhk.me.uk
Mon May 30 01:08:30 PDT 2005

> 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

More information about the talk mailing list