RE: [saxon] Strange things: xsl:sort with lang attribute

> 
> > > BTW, which node is the context node in this expression? Is it foo 
> > > or foo's parent or maybe something completely different?
> > 
> > This isn't clearly stated in the XSLT 1.0 spec. But the
> only logical
> > node to use as the context node (and the one that Saxon
> uses) is the
> > same one that is used for evaluating the select expression in the
> > <xsl:for-each>.
> 
> Then please add something in the XSLT 2.0 spec. I couldn't
> find something at first go.

It's spelled out in 12.2 (April draft): <quote>Those attributes of the
xsl:sort elements whose values are attribute value templates are evaluated
using the outer focus. If the element that contains the xsl:sort elements is
an xsl:sort-key declaration, then the outer focus is a singleton focus based
on the document node of the principal source document. Otherwise, the outer
focus is the focus used to evaluate the select attribute of the containing
instruction (for example, xsl:for-each or xsl:apply-templates).</quote>

> 
> To my mind it is a little bit odd that in
> <xsl:sort select="expr1" lang="{expr2}" />
> expr1 and expr2 refer to different context nodes.

It is indeed a bit odd, but logical given that these attributes are
parameters to the sort operation as a whole, not things that can vary for
each sort key.

I will add this to my list as a candidate 1.0 erratum, though I'm not sure
if and when we'll get round to publishing further errata.

Michael Kay

Received on Friday, 19 July 2002 08:15:27 UTC