Project

Profile

Help

Bug #1997

closed

for-each loops through empty collection

Added by O'Neil Delpratt about 10 years ago. Updated about 10 years ago.

Status:
Closed
Priority:
Normal
Category:
Internals
Sprint/Milestone:
-
Start date:
2014-02-04
Due date:
% Done:

100%

Estimated time:
Legacy ID:
Applies to branch:
Fix Committed on Branch:
Fixed in Maintenance Release:
Platforms:

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>
Actions #1

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.

Actions #2

Updated by O'Neil Delpratt about 10 years ago

  • Description updated (diff)
  • Status changed from In Progress to Resolved
Actions #3

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

Also available in: Atom PDF