Re: [xsl] Do xsl processors contain optimizer for conditions?

Subject: Re: [xsl] Do xsl processors contain optimizer for conditions?
From: Martin Honnen <Martin.Honnen@xxxxxx>
Date: Sat, 14 Nov 2009 18:20:25 +0100
cert21 wrote:
I know in many languages like Java and php when testing for multiple conditions
the engine is smart to return false when the first condition fails, so it does not even check
next conditions.
This saves some of the processing time.


I wonder if xsl engines follow the same logic, for example in test like this:

<xsl:when
test="( (string-length($mystring) > 30) and not(contains(substring($mystring, 1, 30), ' ') ) )">


If the string-length is < 30 then the second condition will not even be evaluated?

Technically it is a question about XPath expressions, if you look at the specification http://www.w3.org/TR/xpath#booleans then it clearly says for 'and' expressions:
"The right operand is not evaluated if the left operand evaluates to false."


And for 'or' expressions:
"The right operand is not evaluated if the left operand evaluates to true."


So it is not question about optimization, the language specification prescribes what to do.

--

	Martin Honnen
	http://msmvps.com/blogs/martin_honnen/

Current Thread