RE: [xsl] testing attributes

Subject: RE: [xsl] testing attributes
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Thu, 19 May 2005 14:42:17 +0100
> <xsl:when test="count(//course) &gt; 0">
> 
> Tha's a very expensive test it causes the whole document to 
> be searched
> to arbitray depth to count all the course elements and then 
> you throw it
> all away as you don't really need them. If you are lucky your 
> system (I
> think saxon does this) will spot this idiom and change it to
> <xsl:when test="//course">
> and stop the search when it finds the first course.

That optimization competes in this case with another optimization, which is
that if your stylesheet uses the expression //course then Saxon assumes
you're likely to use it more than once and saves the result just in case.
I'm not sure which one will win in this case without trying it out.

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

Current Thread