[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re: [xsl] Only child test

Subject: Re: [xsl] Only child test
From: David Carlisle <davidc@xxxxxxxxx>
Date: Thu, 10 Oct 2013 15:55:14 +0100

On 10/10/2013 15:34, Andre Cusson wrote:
Wouldn't "last() eq 1" or "last() gt 1" be both the fastest and

last() depends on the nodes that were selected, so it answers the question of whether 1 node was selected not if there are siblings.



then b has two siblings but if you go

<xsl:apply-templates select="b"/>

last() will be 1 in the template matching b but if you go

<xsl:apply-templates />

Then it will be 3.

Like most of the constructs whether it is fast or not depends on the system optimiser. Naively evaluating last() eq 1 would require knowing what last() is so if there are 100000 items in the list you would have to hold back evaluating any of them until you had processed that one and knew the number but as with not(*[2]) an optimiser can evaluate the boolean expression last() eq 1" as soon as it has seen two items, even if it does not know what value last() has,


Current Thread