> > (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 KayReceived on Tuesday, 7 January 2003 10:00:01 GMT
This archive was generated by hypermail 2.2.0+W3C-0.50 : Saturday, 22 July 2006 00:10:18 GMT