for-each loops through empty collection
Bug reported by user at http://sourceforge.net/p/saxon/support-requests/66/
In the following example the output of $var564_resultof_filter[fn:exists($var565_cur/NonExistingElement)] is empty.
Therefore there is nothing to loop through. Although Saxon is evaluating the inner statement which fails on xs:dateTime function. $var565_cur/NonExistingElement is not available and fn:string will return an empty string.
The underneath exception: Invalid dateTime value "T12:00:00Z" (Non-numeric year component) is thrown.
Saxon (126.96.36.199) is evaluating code in a loop that not meant to be hit because there are no items in the collection.
<xsl:for-each select="$var564_resultof_filter[fn:exists($var565_cur/NonExistingElement)]"> <ElementToGenerateForEachItemInLoop> <xsl:sequence select="xs:string(xs:dateTime(fn:concat(fn:string($var565_cur/NonExistingElement), 'T12:00:00Z')))"/> </ElementToGenerateForEachItemInLoop> </xsl:for-each>
#1 Updated by O'Neil Delpratt over 3 years ago
The xsl:sequence in the loop is being pulled out into a variable since it is not dependent on the for-loop. The
policy should be to do lazy evaluation of the variable to where it is called in the loop, but this is not happening.
Bug fixed and committed to subversion. The fix was to set the evaluation mode of the expression which is being promoted to
MAKE_MEMO_CLOSURE in the optimize method of the ForEach class.
Please register to edit this issue