- From: Howard Katz <howardk@fatdog.com>
- Date: Tue, 7 Jan 2003 20:37:05 -0800
- To: "Mary Fernandez" <mff@research.att.com>
- Cc: "Michael Kay" <Michael.Kay@softwareag.com>, <www-ql@w3.org>
What happens in the case of a mixed sequence such as (salary, 3, bonus)[. > 0 ] Is the ordering implementation-dependent? Howard > -----Original Message----- > From: www-ql-request@w3.org [mailto:www-ql-request@w3.org]On Behalf Of > Mary Fernandez > Sent: Tuesday, January 07, 2003 6:55 PM > To: Howard Katz > Cc: Michael Kay; www-ql@w3.org > Subject: RE: meaning of (salary, bonus) > > In the *sequence* expression: > > (salary, bonus) > > all salary elements will precede all bonus elements. > > In the *path* expression: > > (salary, bonus)[. > 0] > > the resulting salary and bonus elements whose content is greater > than zero will be in document order. This is because > path expressions always yield sequences of nodes in document order > whereas sequence expressions yield sequences of nodes in input order. > > On Tue, 2003-01-07 at 13:59, Howard Katz wrote: > > > > 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 > > > > > > -- > Mary Fernandez, Principal Technical Staff Member > AT&T Labs - Research, 180 Park Ave., Room E243, Florham Park, NJ > 07932-0971 > phone: 973-360-8679, fax: 973-360-8187 > mff@research.att.com, http://www.research.att.com/~mff > >
Received on Tuesday, 7 January 2003 23:39:22 UTC