Today, I've tried to upgrade our projects to Saxon 9.2. We have a rather big set of stylesheets grinding gigabytes of information. It's obvious that we expected at least the same performance from the new version.
But to my puzzlement a pipeline of transformations failed almost immediately with en error message:
XPTY0018: Cannot mix nodes and atomic values in the result of a path expression
We do agree with this statement in general, but what it had in common with our stylesheets? And how everything was working in 9.1?
To find the root of the problem I've created a minimal problem reproduction:
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:t="this" exclude-result-prefixes="xs t"> <!-- Entry point. --> <xsl:template match="/"> <xsl:variable name="p" as="element()"> <p l="1"/> </xsl:variable> <o l="{$p/t:d(.)}"/> </xsl:template> <xsl:function name="t:d" as="item()*"> <xsl:param name="p" as="element()"/> <xsl:apply-templates mode="p" select="$p"/> </xsl:function> <xsl:template match="*" mode="p"> <xsl:sequence select="concat('0', @l)"/> </xsl:template> </xsl:stylesheet>
Really simple, isn't it? The problem is in a new optimization of concat() function, introduced in version 9.2. It tries to eliminate string concatenation, and in certain cases emits its arguments directly into the output as text nodes, separating whole output with some stopper strings. The only problem is that no such optimization is allowed in this particular case (which is rather common, and surely legal, in our stylesheets); result of <xsl:template match="p" mode="p"> should not be a node, but of type xs:string.
concat()
<xsl:template match="p" mode="p">
xs:string
Saxon 9.2 is here already for 3 month, at lest! Thus, how come that such a bug was not discovered earlier?
Update: the fix is commited into the svn on the next day. That's promptly!
Remember Me
a@href@title, b, blockquote@cite, em, i, strike, strong, sub, super, u