Bug #1997
closedfor-each loops through empty collection
100%
Description
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 (9.4.0.7) 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>
Updated by O'Neil Delpratt about 10 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.
Updated by O'Neil Delpratt about 10 years ago
- Description updated (diff)
- Status changed from In Progress to Resolved
Updated by O'Neil Delpratt about 10 years ago
- Status changed from Resolved to Closed
- Found in version changed from 9.4 9.5 to 9.5
- Fixed in version set to 9.5.1.5
Bug fix applied in Saxon maintenance release 9.5.1.5
Please register to edit this issue