The following line of XSLT takes up to 1 second to execute:
<xsl:if test="$start/item[contains($templates,concat('!',@template,'!'))] != ''">
- $templates contains a string like "!rootfolder!folder!document!externalmenulink!"
- @template contains a string like "rootfolder"
- The number of items under $start is less than 10
One could imagine that this behavior was related to other elements stressing the server. But as the same four calls fails every time the error must be related to them in someway. They must have some common characteristics. I just have not been able to identify those!
But I did find out that modifying the test attribute to
<xsl:if test="count($start/item[contains($templates,concat('!',@template,'!'))]) != '0'">
...solved the problem! Every call now executes in less than a millisecond.
As the functionality is exactly the same I strongly recommend using the later even though the problem does not occur in general when using the other.