W3C home > Mailing lists > Public > www-ql@w3.org > April to June 2005

Re: Variable references in path expressions

From: TAN Kuan Hui <kuanhui@xemantics.com>
Date: Fri, 29 Apr 2005 09:53:26 +0800
Message-ID: <005d01c54c5f$1b18ee70$6402a8c0@pinecone>
To: "Michael Kay" <mhk@mhk.me.uk>, "'martin'" <martin@x-hive.com>
Cc: "'Charles Brooking'" <charles.brooking@research.canon.com.au>, <www-ql@w3.org>

>
> >
> > 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!
>
No, I did not mean

return $a/eval($b)

Again, it is the way "/" interpretes its rhs operand and not the
presence of a sequence being re-interpreted as a set of
parsing tokens.

"  if $a/$b == $b if $a is a singleton  "

seems to imply,

let $a := (5),
$b := 1
return $a - $b

so $a - $b == $b if $a is a singleton ? Definitely not,
because "-" is aware of its operand.

I see "/" as a operator in this same context. No ?
Unreasonable expectation or intuition ?
Received on Friday, 29 April 2005 01:59:49 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 6 January 2015 20:17:17 UTC