RE: meaning of (salary, bonus)

Thanks Michael and everyone, that's helpful.

One additional question. I'm unclear about the concept of "document order"
and when that applies in a comma-constructed sequence. Are *all* nodes in
the sequence below in document order, or is the final node-sequence (before
applying the predicate) the result of concatenating all <salary/> nodes in
document order, followed separately by all <bonus/> nodes in document order?

>   (salary, bonus)[. > 0]

Howard

> -----Original Message-----
> From: www-ql-request@w3.org [mailto:www-ql-request@w3.org]On Behalf Of
> Kay, Michael
> Sent: Tuesday, January 07, 2003 7:00 AM
> To: Howard Katz; www-ql@w3.org
> Subject: RE: meaning of (salary, bonus)
> >
> >      (salary, bonus)
> >
> > with the following commentary: "This expression contains all
> > salary children of the context node followed by all bonus children"
> >
> > Can this expression be used outside a location path? I can
> > see returning this expression as a function result, but can
> > someone provide other examples of valid use? And in such a
> > case, what is the meaning of "context node"?
> >
>
> Sure, the expression can be used anywhere, for example
>
>   fn:average((salary, bonus))
>
> returns the average of this sequence - in this case it's actually the same
> as
>
>   fn:average(salary | bonus)
>
> Or you could write:
>
>   (salary, bonus)[. > 0]
>
> to exclude the values that are negative.
>
> In fact, writing the expression within a location path is one of the least
> useful places to use it, since the results of a path expression are always
> in document order. So person/(salary,bonus) actually returns the
> same result
> as person/(salary|bonus).
>
> The "context node" is exactly what it would be if you wrote the expression
> "salary" instead of "(salary, bonus)".
>
> Another common use case is when building a sequence recursively:
>
> <xsl:function name="reverse">
>   <xsl:param name="p"/>
>   <xsl:result select="if ($p)
>                       then (reverse($p[position()!=1]), $p[1])
>                       else ()"/>
> </xsl:function>
>
>
> Michael Kay
>

Received on Tuesday, 7 January 2003 14:01:18 UTC