RE: [xsl] xslt performance issue position() function used in predicate very slow

Subject: RE: [xsl] xslt performance issue position() function used in predicate very slow
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Sat, 26 Aug 2006 20:45:39 +0100
> > It's redundant in all those cases. It's not redundant in:
> 
> > ./(a,b)     (:because it causes sorting into document order:)
> 
>   I don't understand this one.  Could you please explain it a 
> little bit further?  It'd be perfect if you have a reference 
> within the CRs.
> 

XPath section 3.2 describes the effect of the "/" operator as follows:

Each operation E1/E2 is evaluated as follows: Expression E1 is evaluated,
and if the result is not a (possibly empty) sequence of nodes, a type error
is raised [err:XPTY0019]. Each node resulting from the evaluation of E1 then
serves in turn to provide an inner focus for an evaluation of E2, as
described in 2.1.2 Dynamic Context. The sequences resulting from all the
evaluations of E2 are combined as follows:

   1. If every evaluation of E2 returns a (possibly empty) sequence of
nodes, these sequences are combined, and duplicate nodes are eliminated
based on node identity. The resulting node sequence is returned in document
order.

So whereas the sequence (a,b) is not necessarily in document order, the
sequence ./(a,b) is, by virtue of the "/" operator. Equally you can force
sorting of a sequence S into document order by writing S/., or S|(). Or in
this particular case, of course, (a|b)

Michael Kay
http://www.saxonica.com/

Current Thread