Bug #6026


Unexpected function call triggers cardinality check and error

Added by Johan Gheys 11 months ago. Updated 10 months ago.

Start date:
Due date:
% Done:


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


We are running tests to switch from Saxon-EE 11.5 to 12.2. In one of our transformations (see attachment), we now get the following error message:

Type error at char 66 in expression in xsl:attribute/@select on line 143 column 168 of complete-node.xslt:
  XPTY0004  An empty sequence is not allowed as the third argument of local:normalDrivingDirection()
at function local:lineSectionTrackRef on line 125 column 67 of complete-node.xslt:
     Focus: absent
     Local variables
        $macro-trackEdge = ()
        $nodeByLocation = <micro:nodeByLocation>
        $node = <micro:border>
     invoked by function call at jar:file:int-batch-DEV-SNAPSHOT.jar!/validities/complete-node.xslt#438
at function local:transform-to-export-border on line 427 column 74 of complete-node.xslt:
        Context item: map{(:size 7:)}
        Context position: 1
     Local variables
        $params = map{(:size 7:)}
        $node = <micro:border>
        $validFromDate = "2023-04-17"
        $validToDate = "2078-12-31"
        $nodeByLocation = <micro:nodeByLocation>
        $gigRef = <micro:gigRef>
     invoked by function call at jar:file:int-batch-DEV-SNAPSHOT.jar!/validities/complete-node.xslt#46
  In template rule with match="element(Q{}border)" on line 44 of complete-node.xslt
     invoked by xsl:next-match at jar:file:int-batch-DEV-SNAPSHOT.jar!/validities/complete-node.xslt#40
  In template rule with match="*[fn:exists(...)]" on line 38 of complete-node.xslt
     invoked by xsl:apply-templates at jar:file:int-batch-DEV-SNAPSHOT.jar!/validities/complete-node.xslt#521
  In template rule with match="*" on line 519 of complete-node.xslt
     invoked by xsl:apply-templates at jar:file:int-batch-DEV-SNAPSHOT.jar!/validities/complete-node.xslt#34
  In template rule with match="element(Q{}nodes)" on line 31 of complete-node.xslt
     invoked by built-in template rule (text-only)
Error in xsl:sequence/@select on line 29 column 45 of batch.xslt:
  FOER0000  Error signalled by application call on error()
at template xsl:initial-template on line 11 column 56 of batch.xslt:
     Focus: absent
     Local variables
        $vv:v0 = false()
        $startTime = xs:dateTimeStamp("2023-05-09T16:50:24.967+02:00")
Error signalled by application call on error()

whereas with version 11.5 this went smoothly.

It is strange that local:normalDrivingDirection() is called because the sequence over which the for loop iterates is clearly empty:

     Local variables
        $macro-trackEdge = ()

The function call triggers a cardinality check and therefore the above error.


complete-node.xslt (29.1 KB) complete-node.xslt Johan Gheys, 2023-05-09 19:42 (23.7 KB) Johan Gheys, 2023-05-13 11:01

Related issues

Is duplicate of Saxon - Bug #6022: Eager evaluation prematurely throws exception in analyze-string/non-matching-string.ClosedMichael Kay2023-05-08

Actions #1

Updated by Michael Kay 11 months ago

I strongly suspect that this is the same bug as #6022, where an expression that is loop-lifted out of a loop (together with the type-check on its value) is being eagerly evaluated when it should be lazily evaluated.

I can verify this fairly easily if you can send me an executable repro - i.e. if you supply the missing stylesheet modules and a sample source document that demonstrates the problem.

Actions #2

Updated by Johan Gheys 11 months ago

Indeed, the symptoms are very similar. I have uploaded a test set with minimal data and significantly simplified xslt's (I certainly don't want to claim the code is minimal, but it is a good compromise between effort and result).

Actions #3

Updated by Michael Kay 10 months ago

  • Status changed from New to Duplicate

Sorry about the delay in responding.

I have confirmed that this is a duplicate of bug #6022 (the bug can be reproduced if I revert the patch for 6022).

Actions #4

Updated by Michael Kay 10 months ago

  • Is duplicate of Bug #6022: Eager evaluation prematurely throws exception in analyze-string/non-matching-string. added
Actions #5

Updated by Johan Gheys 10 months ago

No problem Michael, I'm glad the issue will be fixed in the next release.

Please register to edit this issue

Also available in: Atom PDF