Project

Profile

Help

Bug #5194

closed

"except" operator not working correctly within anonymous function body

Added by Martin Honnen almost 3 years ago. Updated over 2 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Category:
XPath conformance
Sprint/Milestone:
Start date:
2021-12-29
Due date:
% Done:

100%

Estimated time:
Legacy ID:
Applies to branch:
10, 11
Fix Committed on Branch:
10, trunk
Fixed in Maintenance Release:
Platforms:
.NET, Java

Description

Found by Dimitre on the XSL list:

Saxon 10.6 HE and SaxonCS give the result <?xml version="1.0" encoding="UTF-8"?><a/><c/><b/><b/>

for the code let $xml := parse-xml('<t><a/><b/><c/></t>'), $nodes := ($xml/*/a, $xml/*/c, $xml/*/b, $xml/*/b) return $nodes => fold-left((), function($all, $this) {$all, $this except $all})

e.g.

java -cp "C:\Program Files\Saxonica\SaxonHE10-6J\saxon-he-10.6.jar" net.sf.saxon.Query -qs:"let $xml := parse-xml('<t><a/><b/><c/></t>'), $nodes := ($xml/*/a, $xml/*/c, $xml/*/b, $xml/*/b) return $nodes => fold-left((), function($all, $this) {$all, $this except $all})"
<?xml version="1.0" encoding="UTF-8"?><a/><c/><b/><b/>

gives that result

Actions #1

Updated by Martin Honnen almost 3 years ago

Title should be "except not working correctly".

Actions #2

Updated by Michael Kay almost 3 years ago

  • Subject changed from exept not working correctly to "except" operator not working correctly within anonymous function body

The "except" operator relies on the operands being sorted into document order. To achieve this a DocumentOrder() operation is added to the operands during the simplify() phase of static processing. However, it appears that the simplify() processing is not propagating to the body of an anonymous function call.

(The simplify() processing phase does very little these days, and we should consider getting rid of it. The DocumentOrder() operation could equally well be added during the parsing phase. It is added unconditionally, and is then removed where possible during the type-checking phase.)

Actions #3

Updated by Michael Kay almost 3 years ago

Test case except-100 added to QT3.

Actions #4

Updated by Michael Kay almost 3 years ago

  • Status changed from New to In Progress
  • Fix Committed on Branch 10, trunk added

Patched VennExpression to add the document sorter in the constructor rather than the simplify() method.

But needs further review: either we should get rid of the simplify() method, or we should make sure it is called consistently.

Actions #5

Updated by Michael Kay almost 3 years ago

  • Status changed from In Progress to Resolved

Turns out this solution doesn't work. We can't add a DocumentSorter during parsing, because the constructor for a DocumentSorter requires access to static properties of the expression-to-be-sorted that aren't available at this stage. So it has to be added during the simplify() phase.

So I've instead changed the code for UserFunctionReference to propagate the simplify() method to the body of the referenced function (if it is anonymous). (An inline function call gets parsed as a UserFunctionReference pointing to a UserFunction that represents the inline function.)

Actions #6

Updated by O'Neil Delpratt almost 3 years ago

  • % Done changed from 0 to 100
  • Fixed in Maintenance Release 11.1 added

Bug fix applied in the Saxon 11.1 release.

Actions #7

Updated by O'Neil Delpratt almost 3 years ago

Leaving bug as resolved until fix applied to the Saxon 10 maintenance release.

Actions #8

Updated by Debbie Lockett over 2 years ago

  • Status changed from Resolved to Closed
  • Fixed in Maintenance Release 10.7 added
  • Fixed in Maintenance Release deleted (11.1)

Bug fix applied in the Saxon 10.7 maintenance release.

Actions #9

Updated by Debbie Lockett over 2 years ago

  • Fixed in Maintenance Release 11.1 added

Please register to edit this issue

Also available in: Atom PDF