Re: [xsl] Testing by counting or positional predicate

Subject: Re: [xsl] Testing by counting or positional predicate
From: Jeni Tennison <mail@xxxxxxxxxxxxxxxx>
Date: Thu, 11 Jan 2001 13:35:36 +0000
Hi Mike,

Thanks very much for your discussion.  I'll go back to the counting
method.

On the same kind of topic, there's the question of which of these is
more efficient:

  count($node-set) >= $length

or:

  $node-set[$length]

I guess that this will depend on when the node set is constructed: if
it's constructed in advance of the test, then the first is probably
better because it just tests two numbers as opposed to iterating over
the nodes, unless $length is very small in which case they're probably
roughly equivalent.

If the node set is constructed on the fly and it's relatively likely
that it's at least $length in length, then it's probably better to use
the second because it prevents having the whole node set constructed
before its length is tested.  If it's unlikely that the node set will
be of length $length, then they're probably roughly equivalent.

Would that be an accurate analysis?

Thanks,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/



 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread