RE: Variable references in path expressions

That reminds of a recent conference paper I reviewed that was writing
/$a/$b/$c all the time as XPath expressions. It took me a while to
understand that they actually meant it would parameterize the path
expression....

Best regards
Michael

> -----Original Message-----
> From: www-ql-request@w3.org [mailto:www-ql-request@w3.org] On Behalf
Of
> Michael Kay
> Sent: Thursday, April 28, 2005 3:07 AM
> To: 'martin'
> Cc: 'TAN Kuan Hui'; 'Charles Brooking'; www-ql@w3.org
> Subject: RE: Variable references in path expressions
> 
> 
> >
> > I might be mistaken, but I think he wants to do this:
> >  > let $a := (<a/>,<b/>,<c/>)
> >  > let $b := (xs:QName("b"), xs:QName("c"))
> >  > return $a/$b
> > .. would lead to $a being filtered by $b's QNames on the
> > child axis, so
> > the result would be <b/>,<c/> (e.g. what you would get by
> > $a/element($b)). I've noticed that some people tend to understand
> > Variable references in XQuery PathSteps this way.
> 
> Yes, it's common enough for people to think that a variable holds a
> fragment
> of an XPath expression that's treated as a macro and handled using
textual
> substitution. You see this a lot with people trying to write <xsl:sort
> select="$sortkey"/> in XSLT. They've probably used other languages
such as
> shell scripts that use $ to introduce a macro variable.
> 
> But I didn't recognize that particular error here!
> 
> Michael Kay
> http://www.saxonica.com/
> 
> 

Received on Thursday, 28 April 2005 19:01:24 UTC