Bug #6249
closedInternal error reported: xsl:evaluate/@context-item expression is present, but evaluates to empty sequence
100%
Description
Reported by email on support@s...
I am not able to pinpoint the cause of an error I am getting running a transform (Internal error evaluating template rule at line 320 in module file:/C:/temp/saxon/preprocess.xsl)
I've attached a zip file that contains the source file and the XSLT. The source file is 1138869155744808.xml and the main stylesheet is formulary_preprocess.xsl. When I run the transform in Oxygen I get the same error as when it runs in our application.
If I set a breakpoint at line 1639 in file 1138869155744808.xml, it will run to that point. From there I can click step-into until I get to line 60 in preprocess.xsl. I click two more times and I get the error message (Internal error evaluating template rule at line 45 in module file:/C:/temp/saxon/preprocess.xsl).
The English version of this document works just fine, so I am wondering if the error has something to do with the Chinese characters in this document.
Updated by Michael Kay about 1 year ago
Reproduced on 12.x development branch. Stack trace is:
error evaluating function fn:match at line 812 in module file:/Users/mike/bugs/2023/6249-Boughton/saxon/preprocess.xsl at net.sf.saxon.expr.instruct.UserFunction.call(UserFunction.java:714) at net.sf.saxon.expr.UserFunctionCall$UserFunctionCallElaborator.lambda$elaborateForPull$0(UserFunctionCall.java:746) at net.sf.saxon.expr.elab.PullElaborator.lambda$elaborateForBoolean$2(PullElaborator.java:65) at net.sf.saxon.functions.NotFn$NotFnElaborator.lambda$elaborateForBoolean$0(NotFn.java:129) at net.sf.saxon.expr.instruct.Choose$ChooseExprElaborator.lambda$elaborateForPush$10(Choose.java:1168) at net.sf.saxon.expr.instruct.Choose$ChooseExprElaborator.lambda$elaborateForPush$12(Choose.java:1179) at net.sf.saxon.expr.instruct.NamedTemplate.expand(NamedTemplate.java:247) at net.sf.saxon.expr.instruct.CallTemplate$CallTemplatePackage.processLeavingTail(CallTemplate.java:515) at net.sf.saxon.trans.Mode.applyTemplates(Mode.java:476) at net.sf.saxon.expr.instruct.ApplyTemplates$ApplyTemplatesElaborator.lambda$elaborateForPush$1(ApplyTemplates.java:650) at net.sf.saxon.expr.instruct.Block$BlockElaborator.lambda$elaborateForPush$4(Block.java:895) at net.sf.saxon.expr.instruct.Copy$CopyElaborator.lambda$elaborateForPush$0(Copy.java:589) at net.sf.saxon.expr.instruct.Block$BlockElaborator.lambda$elaborateForPush$1(Block.java:853) at net.sf.saxon.expr.instruct.TemplateRule.applyLeavingTail(TemplateRule.java:376) at net.sf.saxon.trans.Mode.handleRuleNotNull(Mode.java:587) at net.sf.saxon.trans.Mode.applyTemplates(Mode.java:521) at net.sf.saxon.expr.instruct.ApplyTemplates$ApplyTemplatesElaborator.lambda$elaborateForPush$1(ApplyTemplates.java:650) at net.sf.saxon.expr.instruct.Copy$CopyElaborator.lambda$elaborateForPush$0(Copy.java:589) at net.sf.saxon.expr.instruct.TemplateRule.applyLeavingTail(TemplateRule.java:376) at net.sf.saxon.trans.Mode.handleRuleNotNull(Mode.java:587) at net.sf.saxon.trans.Mode.applyTemplates(Mode.java:521) at net.sf.saxon.expr.instruct.ApplyTemplates$ApplyTemplatesPackage.processLeavingTail(ApplyTemplates.java:548) at net.sf.saxon.trans.Mode.applyTemplates(Mode.java:476) at net.sf.saxon.expr.instruct.ApplyTemplates$ApplyTemplatesPackage.processLeavingTail(ApplyTemplates.java:548) at net.sf.saxon.trans.Mode.applyTemplates(Mode.java:476) at net.sf.saxon.expr.instruct.ApplyTemplates$ApplyTemplatesPackage.processLeavingTail(ApplyTemplates.java:548) at net.sf.saxon.trans.Mode.applyTemplates(Mode.java:476) at net.sf.saxon.expr.instruct.ApplyTemplates$ApplyTemplatesElaborator.lambda$elaborateForPush$1(ApplyTemplates.java:650) at net.sf.saxon.expr.instruct.Choose$ChooseExprElaborator.lambda$elaborateForPush$11(Choose.java:1174) at net.sf.saxon.expr.instruct.Block$BlockElaborator.lambda$elaborateForPush$1(Block.java:853) at net.sf.saxon.expr.LetExpression$LetExprElaborator.lambda$elaborateForPush$6(LetExpression.java:942) at net.sf.saxon.expr.instruct.Block$BlockElaborator.lambda$elaborateForPush$4(Block.java:895) at net.sf.saxon.expr.instruct.FixedElement$FixedElementElaborator.lambda$elaborateForPush$0(FixedElement.java:640) at net.sf.saxon.expr.instruct.Choose$ChooseExprElaborator.lambda$elaborateForPush$11(Choose.java:1173) at net.sf.saxon.expr.instruct.Block$BlockElaborator.lambda$elaborateForPush$3(Block.java:885) at net.sf.saxon.expr.instruct.NamedTemplate.expand(NamedTemplate.java:247) at net.sf.saxon.expr.instruct.CallTemplate$CallTemplatePackage.processLeavingTail(CallTemplate.java:515) at net.sf.saxon.trans.Mode.applyTemplates(Mode.java:476) at net.sf.saxon.expr.instruct.ApplyTemplates$ApplyTemplatesPackage.processLeavingTail(ApplyTemplates.java:548) at net.sf.saxon.trans.Mode.applyTemplates(Mode.java:476) at net.sf.saxon.expr.instruct.ApplyTemplates$ApplyTemplatesPackage.processLeavingTail(ApplyTemplates.java:548) at net.sf.saxon.trans.Mode.applyTemplates(Mode.java:476) at net.sf.saxon.expr.instruct.ApplyTemplates$ApplyTemplatesPackage.processLeavingTail(ApplyTemplates.java:548) at net.sf.saxon.trans.Mode.applyTemplates(Mode.java:476) at net.sf.saxon.expr.instruct.ApplyTemplates$ApplyTemplatesElaborator.lambda$elaborateForPush$1(ApplyTemplates.java:650) at net.sf.saxon.expr.instruct.Block$BlockElaborator.lambda$elaborateForPush$3(Block.java:885) at net.sf.saxon.expr.instruct.Copy$CopyElaborator.lambda$elaborateForPush$0(Copy.java:589) at net.sf.saxon.expr.instruct.Choose$ChooseExprElaborator.lambda$elaborateForPush$11(Choose.java:1173) at net.sf.saxon.expr.instruct.TemplateRule.applyLeavingTail(TemplateRule.java:376) at net.sf.saxon.trans.Mode.handleRuleNotNull(Mode.java:587) at net.sf.saxon.trans.Mode.applyTemplates(Mode.java:521) at net.sf.saxon.expr.instruct.ApplyTemplates$ApplyTemplatesPackage.processLeavingTail(ApplyTemplates.java:548) at net.sf.saxon.trans.Mode.applyTemplates(Mode.java:476) at net.sf.saxon.trans.XsltController.applyTemplates(XsltController.java:688) at net.sf.saxon.s9api.AbstractXsltTransformer.applyTemplatesToSource(AbstractXsltTransformer.java:440) at net.sf.saxon.s9api.Xslt30Transformer.applyTemplates(Xslt30Transformer.java:306) at net.sf.saxon.Transform.processFile(Transform.java:1431) at net.sf.saxon.Transform.doTransform(Transform.java:917) at net.sf.saxon.Transform.main(Transform.java:83) Caused by: java.lang.RuntimeException: Internal error evaluating function fn:get at line 137 in module file:/Users/mike/bugs/2023/6249-Boughton/saxon/table-lookup.xsl at net.sf.saxon.expr.instruct.UserFunction.call(UserFunction.java:714) at net.sf.saxon.expr.UserFunctionCall$UserFunctionCallElaborator.lambda$elaborateForPull$1(UserFunctionCall.java:758) at net.sf.saxon.expr.Atomizer$AtomizerElaborator.lambda$elaborateForPull$0(Atomizer.java:677) at net.sf.saxon.expr.AtomicSequenceConverter$AtomicSequenceConverterElaborator.lambda$elaborateForPull$0(AtomicSequenceConverter.java:536) at net.sf.saxon.expr.elab.EagerPullEvaluator.evaluate(EagerPullEvaluator.java:37) at net.sf.saxon.expr.UserFunctionCall.evaluateArguments(UserFunctionCall.java:616) at net.sf.saxon.expr.UserFunctionCall$UserFunctionCallElaborator.lambda$elaborateForPull$1(UserFunctionCall.java:756) at net.sf.saxon.expr.UserFunctionCall.iterate(UserFunctionCall.java:547) at net.sf.saxon.expr.instruct.EvaluateInstr$EvaluateInstrElaborator.lambda$elaborateForPull$4(EvaluateInstr.java:690) at net.sf.saxon.expr.elab.EagerPullEvaluator.evaluate(EagerPullEvaluator.java:37) at net.sf.saxon.expr.TryCatch$TryCatchElaborator.lambda$elaborateForPull$2(TryCatch.java:403) at net.sf.saxon.expr.Atomizer$AtomizerElaborator.lambda$elaborateForPull$0(Atomizer.java:677) at net.sf.saxon.expr.UntypedSequenceConverter$UntypedSequenceConverterElaborator.lambda$elaborateForPull$0(UntypedSequenceConverter.java:304) at net.sf.saxon.expr.CardinalityChecker$CardinalityCheckerElaborator.lambda$elaborateForPull$0(CardinalityChecker.java:502) at net.sf.saxon.expr.ItemChecker$ItemCheckerElaborator.lambda$elaborateForPull$0(ItemChecker.java:445) at net.sf.saxon.expr.instruct.Block$BlockElaborator$BlockIterator.getNthChildIterator(Block.java:832) at net.sf.saxon.expr.instruct.AbstractBlockIterator.next(AbstractBlockIterator.java:66) at net.sf.saxon.expr.CardinalityCheckingIterator.(CardinalityCheckingIterator.java:55) at net.sf.saxon.expr.CardinalityChecker.checkCardinality(CardinalityChecker.java:257) at net.sf.saxon.expr.CardinalityChecker$CardinalityCheckerElaborator.lambda$elaborateForPull$0(CardinalityChecker.java:502) at net.sf.saxon.expr.elab.EagerPullEvaluator.evaluate(EagerPullEvaluator.java:37) at net.sf.saxon.expr.instruct.Choose$EagerChooseEvaluator.evaluate(Choose.java:1248) at net.sf.saxon.expr.LetExpression$EagerLocalVariableEvaluator.evaluate(LetExpression.java:1004) at net.sf.saxon.expr.instruct.UserFunction.call(UserFunction.java:704) ... 58 more Caused by: java.lang.NullPointerException at net.sf.saxon.expr.AxisExpression$AxisExpressionElaborator.lambda$elaborateForPull$1(AxisExpression.java:1278) at net.sf.saxon.expr.FilterExpression$FilterExprElaborator.lambda$elaborateForPull$0(FilterExpression.java:1277) at net.sf.saxon.expr.SlashExpression$SlashExprElaborator.lambda$elaborateForPull$1(SlashExpression.java:1118) at net.sf.saxon.functions.Exists$ExistsFnElaborator.lambda$elaborateForBoolean$0(Exists.java:110) at net.sf.saxon.expr.elab.BooleanElaborator.lambda$elaborateForPull$0(BooleanElaborator.java:25) at net.sf.saxon.expr.FunctionCall.iterate(FunctionCall.java:624) at net.sf.saxon.expr.instruct.EvaluateInstr$EvaluateInstrElaborator.lambda$elaborateForPull$4(EvaluateInstr.java:690) at net.sf.saxon.expr.elab.EagerPullEvaluator.evaluate(EagerPullEvaluator.java:37) at net.sf.saxon.expr.TryCatch$TryCatchElaborator.lambda$elaborateForPull$2(TryCatch.java:403) at net.sf.saxon.expr.Atomizer$AtomizerElaborator.lambda$elaborateForPull$0(Atomizer.java:677) at net.sf.saxon.expr.UntypedSequenceConverter$UntypedSequenceConverterElaborator.lambda$elaborateForPull$0(UntypedSequenceConverter.java:304) at net.sf.saxon.expr.CardinalityChecker$CardinalityCheckerElaborator.lambda$elaborateForPull$0(CardinalityChecker.java:502) at net.sf.saxon.expr.ItemChecker$ItemCheckerElaborator.lambda$elaborateForPull$0(ItemChecker.java:445) at net.sf.saxon.expr.elab.EagerPullEvaluator.evaluate(EagerPullEvaluator.java:37) at net.sf.saxon.expr.LetExpression$LetExprElaborator.lambda$setAllVariables$0(LetExpression.java:839) at net.sf.saxon.expr.LetExpression$LetExprElaborator.lambda$elaborateForPull$5(LetExpression.java:925) at net.sf.saxon.expr.instruct.Block$BlockElaborator$BlockIterator.getNthChildIterator(Block.java:832) at net.sf.saxon.expr.instruct.AbstractBlockIterator.next(AbstractBlockIterator.java:66) at net.sf.saxon.value.SequenceExtent.from(SequenceExtent.java:48) at net.sf.saxon.om.SequenceTool.toGroundedValue(SequenceTool.java:55) at net.sf.saxon.expr.elab.EagerPullEvaluator.evaluate(EagerPullEvaluator.java:37) at net.sf.saxon.expr.TailCallLoop.tailCallDifferentFunction(TailCallLoop.java:156) at net.sf.saxon.expr.TailCallLoop.access$200(TailCallLoop.java:28) at net.sf.saxon.expr.TailCallLoop$TailCallLoopElaborator.lambda$elaborateForPull$0(TailCallLoop.java:218) at net.sf.saxon.value.MemoClosure.makeSequence(MemoClosure.java:85) at net.sf.saxon.value.MemoClosure.iterate(MemoClosure.java:76) at net.sf.saxon.expr.UserFunctionCall$UserFunctionCallElaborator.lambda$elaborateForPull$0(UserFunctionCall.java:746) at net.sf.saxon.expr.AdjacentTextNodeMerger$AdjacentTextNodeMergerElaborator.lambda$elaborateForPull$0(AdjacentTextNodeMerger.java:273) at net.sf.saxon.expr.Atomizer$AtomizerElaborator.lambda$elaborateForPull$0(Atomizer.java:677) at net.sf.saxon.expr.AtomicSequenceConverter$AtomicSequenceConverterElaborator.lambda$elaborateForPull$0(AtomicSequenceConverter.java:536) at net.sf.saxon.expr.elab.LazyPullEvaluator.evaluate(LazyPullEvaluator.java:39) at net.sf.saxon.expr.SystemFunctionCall$SystemFunctionCallElaborator.lambda$elaborateForItem$6(SystemFunctionCall.java:663) at net.sf.saxon.expr.instruct.ValueOf$ValueOfElaborator.lambda$elaborateForItem$3(ValueOf.java:438) at net.sf.saxon.expr.elab.SimpleNodePushElaborator.lambda$elaborateForPull$0(SimpleNodePushElaborator.java:34) at net.sf.saxon.expr.instruct.Choose$ChooseExprElaborator.lambda$elaborateForPull$0(Choose.java:1071) at net.sf.saxon.expr.LetExpression$LetExprElaborator.lambda$elaborateForPull$5(LetExpression.java:927) at net.sf.saxon.value.SingletonClosure.asItem(SingletonClosure.java:104) at net.sf.saxon.value.SingletonClosure.iterate(SingletonClosure.java:64) at net.sf.saxon.expr.UserFunctionCall$UserFunctionCallElaborator.lambda$elaborateForPull$0(UserFunctionCall.java:746) at net.sf.saxon.expr.AdjacentTextNodeMerger$AdjacentTextNodeMergerElaborator.lambda$elaborateForPull$0(AdjacentTextNodeMerger.java:273) at net.sf.saxon.expr.Atomizer$AtomizerElaborator.lambda$elaborateForPull$0(Atomizer.java:677) at net.sf.saxon.expr.AtomicSequenceConverter$AtomicSequenceConverterElaborator.lambda$elaborateForPull$0(AtomicSequenceConverter.java:536) at net.sf.saxon.expr.elab.LazyPullEvaluator.evaluate(LazyPullEvaluator.java:39) at net.sf.saxon.expr.SystemFunctionCall$SystemFunctionCallElaborator.lambda$elaborateForItem$6(SystemFunctionCall.java:663) at net.sf.saxon.expr.instruct.ValueOf$ValueOfElaborator.lambda$elaborateForItem$3(ValueOf.java:438) at net.sf.saxon.expr.elab.OptionalItemEvaluator.evaluate(OptionalItemEvaluator.java:41) at net.sf.saxon.expr.instruct.Choose$EagerChooseEvaluator.evaluate(Choose.java:1248) at net.sf.saxon.expr.elab.LearningEvaluator.evaluate(LearningEvaluator.java:59) at net.sf.saxon.expr.instruct.UserFunction.call(UserFunction.java:704) ... 81 more java.lang.RuntimeException: Internal error evaluating template rule at line 407 in module file:/Users/mike/bugs/2023/6249-Boughton/saxon/preprocess.xsl at net.sf.saxon.expr.instruct.TemplateRule.applyLeavingTail(TemplateRule.java:386) at net.sf.saxon.trans.Mode.handleRuleNotNull(Mode.java:587) at net.sf.saxon.trans.Mode.applyTemplates(Mode.java:521) at net.sf.saxon.expr.instruct.ApplyTemplates$ApplyTemplatesElaborator.lambda$elaborateForPush$1(ApplyTemplates.java:650) at net.sf.saxon.expr.instruct.Copy$CopyElaborator.lambda$elaborateForPush$0(Copy.java:589) at net.sf.saxon.expr.instruct.TemplateRule.applyLeavingTail(TemplateRule.java:376) at net.sf.saxon.trans.Mode.handleRuleNotNull(Mode.java:587) at net.sf.saxon.trans.Mode.applyTemplates(Mode.java:521) at net.sf.saxon.expr.instruct.ApplyTemplates$ApplyTemplatesPackage.processLeavingTail(ApplyTemplates.java:548) at net.sf.saxon.trans.Mode.applyTemplates(Mode.java:476) at net.sf.saxon.expr.instruct.ApplyTemplates$ApplyTemplatesPackage.processLeavingTail(ApplyTemplates.java:548) at net.sf.saxon.trans.Mode.applyTemplates(Mode.java:476) at net.sf.saxon.expr.instruct.ApplyTemplates$ApplyTemplatesPackage.processLeavingTail(ApplyTemplates.java:548) at net.sf.saxon.trans.Mode.applyTemplates(Mode.java:476) at net.sf.saxon.expr.instruct.ApplyTemplates$ApplyTemplatesElaborator.lambda$elaborateForPush$1(ApplyTemplates.java:650) at net.sf.saxon.expr.instruct.Choose$ChooseExprElaborator.lambda$elaborateForPush$11(Choose.java:1174) at net.sf.saxon.expr.instruct.Block$BlockElaborator.lambda$elaborateForPush$1(Block.java:853) at net.sf.saxon.expr.LetExpression$LetExprElaborator.lambda$elaborateForPush$6(LetExpression.java:942) at net.sf.saxon.expr.instruct.Block$BlockElaborator.lambda$elaborateForPush$4(Block.java:895) at net.sf.saxon.expr.instruct.FixedElement$FixedElementElaborator.lambda$elaborateForPush$0(FixedElement.java:640) at net.sf.saxon.expr.instruct.Choose$ChooseExprElaborator.lambda$elaborateForPush$11(Choose.java:1173) at net.sf.saxon.expr.instruct.Block$BlockElaborator.lambda$elaborateForPush$3(Block.java:885) at net.sf.saxon.expr.instruct.NamedTemplate.expand(NamedTemplate.java:247) at net.sf.saxon.expr.instruct.CallTemplate$CallTemplatePackage.processLeavingTail(CallTemplate.java:515) at net.sf.saxon.trans.Mode.applyTemplates(Mode.java:476) at net.sf.saxon.expr.instruct.ApplyTemplates$ApplyTemplatesPackage.processLeavingTail(ApplyTemplates.java:548) at net.sf.saxon.trans.Mode.applyTemplates(Mode.java:476) at net.sf.saxon.expr.instruct.ApplyTemplates$ApplyTemplatesPackage.processLeavingTail(ApplyTemplates.java:548) at net.sf.saxon.trans.Mode.applyTemplates(Mode.java:476) at net.sf.saxon.expr.instruct.ApplyTemplates$ApplyTemplatesPackage.processLeavingTail(ApplyTemplates.java:548) at net.sf.saxon.trans.Mode.applyTemplates(Mode.java:476) at net.sf.saxon.expr.instruct.ApplyTemplates$ApplyTemplatesElaborator.lambda$elaborateForPush$1(ApplyTemplates.java:650) at net.sf.saxon.expr.instruct.Block$BlockElaborator.lambda$elaborateForPush$3(Block.java:885) at net.sf.saxon.expr.instruct.Copy$CopyElaborator.lambda$elaborateForPush$0(Copy.java:589) at net.sf.saxon.expr.instruct.Choose$ChooseExprElaborator.lambda$elaborateForPush$11(Choose.java:1173) at net.sf.saxon.expr.instruct.TemplateRule.applyLeavingTail(TemplateRule.java:376) at net.sf.saxon.trans.Mode.handleRuleNotNull(Mode.java:587) at net.sf.saxon.trans.Mode.applyTemplates(Mode.java:521) at net.sf.saxon.expr.instruct.ApplyTemplates$ApplyTemplatesPackage.processLeavingTail(ApplyTemplates.java:548) at net.sf.saxon.trans.Mode.applyTemplates(Mode.java:476) at net.sf.saxon.trans.XsltController.applyTemplates(XsltController.java:688) at net.sf.saxon.s9api.AbstractXsltTransformer.applyTemplatesToSource(AbstractXsltTransformer.java:440) at net.sf.saxon.s9api.Xslt30Transformer.applyTemplates(Xslt30Transformer.java:306) at net.sf.saxon.Transform.processFile(Transform.java:1431) at net.sf.saxon.Transform.doTransform(Transform.java:917) at net.sf.saxon.Transform.main(Transform.java:83) Caused by: java.lang.RuntimeException: Internal error evaluating function fn:match at line 812 in module file:/Users/mike/bugs/2023/6249-Boughton/saxon/preprocess.xsl at net.sf.saxon.expr.instruct.UserFunction.call(UserFunction.java:714) at net.sf.saxon.expr.UserFunctionCall$UserFunctionCallElaborator.lambda$elaborateForPull$0(UserFunctionCall.java:746) at net.sf.saxon.expr.elab.PullElaborator.lambda$elaborateForBoolean$2(PullElaborator.java:65) at net.sf.saxon.functions.NotFn$NotFnElaborator.lambda$elaborateForBoolean$0(NotFn.java:129) at net.sf.saxon.expr.instruct.Choose$ChooseExprElaborator.lambda$elaborateForPush$10(Choose.java:1168) at net.sf.saxon.expr.instruct.Choose$ChooseExprElaborator.lambda$elaborateForPush$12(Choose.java:1179) at net.sf.saxon.expr.instruct.NamedTemplate.expand(NamedTemplate.java:247) at net.sf.saxon.expr.instruct.CallTemplate$CallTemplatePackage.processLeavingTail(CallTemplate.java:515) at net.sf.saxon.trans.Mode.applyTemplates(Mode.java:476) at net.sf.saxon.expr.instruct.ApplyTemplates$ApplyTemplatesElaborator.lambda$elaborateForPush$1(ApplyTemplates.java:650) at net.sf.saxon.expr.instruct.Block$BlockElaborator.lambda$elaborateForPush$4(Block.java:895) at net.sf.saxon.expr.instruct.Copy$CopyElaborator.lambda$elaborateForPush$0(Copy.java:589) at net.sf.saxon.expr.instruct.Block$BlockElaborator.lambda$elaborateForPush$1(Block.java:853) at net.sf.saxon.expr.instruct.TemplateRule.applyLeavingTail(TemplateRule.java:376) ... 45 more Caused by: java.lang.RuntimeException: Internal error evaluating function fn:get at line 137 in module file:/Users/mike/bugs/2023/6249-Boughton/saxon/table-lookup.xsl at net.sf.saxon.expr.instruct.UserFunction.call(UserFunction.java:714) at net.sf.saxon.expr.UserFunctionCall$UserFunctionCallElaborator.lambda$elaborateForPull$1(UserFunctionCall.java:758) at net.sf.saxon.expr.Atomizer$AtomizerElaborator.lambda$elaborateForPull$0(Atomizer.java:677) at net.sf.saxon.expr.AtomicSequenceConverter$AtomicSequenceConverterElaborator.lambda$elaborateForPull$0(AtomicSequenceConverter.java:536) at net.sf.saxon.expr.elab.EagerPullEvaluator.evaluate(EagerPullEvaluator.java:37) at net.sf.saxon.expr.UserFunctionCall.evaluateArguments(UserFunctionCall.java:616) at net.sf.saxon.expr.UserFunctionCall$UserFunctionCallElaborator.lambda$elaborateForPull$1(UserFunctionCall.java:756) at net.sf.saxon.expr.UserFunctionCall.iterate(UserFunctionCall.java:547) at net.sf.saxon.expr.instruct.EvaluateInstr$EvaluateInstrElaborator.lambda$elaborateForPull$4(EvaluateInstr.java:690) at net.sf.saxon.expr.elab.EagerPullEvaluator.evaluate(EagerPullEvaluator.java:37) at net.sf.saxon.expr.TryCatch$TryCatchElaborator.lambda$elaborateForPull$2(TryCatch.java:403) at net.sf.saxon.expr.Atomizer$AtomizerElaborator.lambda$elaborateForPull$0(Atomizer.java:677) at net.sf.saxon.expr.UntypedSequenceConverter$UntypedSequenceConverterElaborator.lambda$elaborateForPull$0(UntypedSequenceConverter.java:304) at net.sf.saxon.expr.CardinalityChecker$CardinalityCheckerElaborator.lambda$elaborateForPull$0(CardinalityChecker.java:502) at net.sf.saxon.expr.ItemChecker$ItemCheckerElaborator.lambda$elaborateForPull$0(ItemChecker.java:445) at net.sf.saxon.expr.instruct.Block$BlockElaborator$BlockIterator.getNthChildIterator(Block.java:832) at net.sf.saxon.expr.instruct.AbstractBlockIterator.next(AbstractBlockIterator.java:66) at net.sf.saxon.expr.CardinalityCheckingIterator.(CardinalityCheckingIterator.java:55) at net.sf.saxon.expr.CardinalityChecker.checkCardinality(CardinalityChecker.java:257) at net.sf.saxon.expr.CardinalityChecker$CardinalityCheckerElaborator.lambda$elaborateForPull$0(CardinalityChecker.java:502) at net.sf.saxon.expr.elab.EagerPullEvaluator.evaluate(EagerPullEvaluator.java:37) at net.sf.saxon.expr.instruct.Choose$EagerChooseEvaluator.evaluate(Choose.java:1248) at net.sf.saxon.expr.LetExpression$EagerLocalVariableEvaluator.evaluate(LetExpression.java:1004) at net.sf.saxon.expr.instruct.UserFunction.call(UserFunction.java:704) ... 58 more Caused by: java.lang.NullPointerException at net.sf.saxon.expr.AxisExpression$AxisExpressionElaborator.lambda$elaborateForPull$1(AxisExpression.java:1278) at net.sf.saxon.expr.FilterExpression$FilterExprElaborator.lambda$elaborateForPull$0(FilterExpression.java:1277) at net.sf.saxon.expr.SlashExpression$SlashExprElaborator.lambda$elaborateForPull$1(SlashExpression.java:1118) at net.sf.saxon.functions.Exists$ExistsFnElaborator.lambda$elaborateForBoolean$0(Exists.java:110) at net.sf.saxon.expr.elab.BooleanElaborator.lambda$elaborateForPull$0(BooleanElaborator.java:25) at net.sf.saxon.expr.FunctionCall.iterate(FunctionCall.java:624) at net.sf.saxon.expr.instruct.EvaluateInstr$EvaluateInstrElaborator.lambda$elaborateForPull$4(EvaluateInstr.java:690) at net.sf.saxon.expr.elab.EagerPullEvaluator.evaluate(EagerPullEvaluator.java:37) at net.sf.saxon.expr.TryCatch$TryCatchElaborator.lambda$elaborateForPull$2(TryCatch.java:403) at net.sf.saxon.expr.Atomizer$AtomizerElaborator.lambda$elaborateForPull$0(Atomizer.java:677) at net.sf.saxon.expr.UntypedSequenceConverter$UntypedSequenceConverterElaborator.lambda$elaborateForPull$0(UntypedSequenceConverter.java:304) at net.sf.saxon.expr.CardinalityChecker$CardinalityCheckerElaborator.lambda$elaborateForPull$0(CardinalityChecker.java:502) at net.sf.saxon.expr.ItemChecker$ItemCheckerElaborator.lambda$elaborateForPull$0(ItemChecker.java:445) at net.sf.saxon.expr.elab.EagerPullEvaluator.evaluate(EagerPullEvaluator.java:37) at net.sf.saxon.expr.LetExpression$LetExprElaborator.lambda$setAllVariables$0(LetExpression.java:839) at net.sf.saxon.expr.LetExpression$LetExprElaborator.lambda$elaborateForPull$5(LetExpression.java:925) at net.sf.saxon.expr.instruct.Block$BlockElaborator$BlockIterator.getNthChildIterator(Block.java:832) at net.sf.saxon.expr.instruct.AbstractBlockIterator.next(AbstractBlockIterator.java:66) at net.sf.saxon.value.SequenceExtent.from(SequenceExtent.java:48) at net.sf.saxon.om.SequenceTool.toGroundedValue(SequenceTool.java:55) at net.sf.saxon.expr.elab.EagerPullEvaluator.evaluate(EagerPullEvaluator.java:37) at net.sf.saxon.expr.TailCallLoop.tailCallDifferentFunction(TailCallLoop.java:156) at net.sf.saxon.expr.TailCallLoop.access$200(TailCallLoop.java:28) at net.sf.saxon.expr.TailCallLoop$TailCallLoopElaborator.lambda$elaborateForPull$0(TailCallLoop.java:218) at net.sf.saxon.value.MemoClosure.makeSequence(MemoClosure.java:85) at net.sf.saxon.value.MemoClosure.iterate(MemoClosure.java:76) at net.sf.saxon.expr.UserFunctionCall$UserFunctionCallElaborator.lambda$elaborateForPull$0(UserFunctionCall.java:746) at net.sf.saxon.expr.AdjacentTextNodeMerger$AdjacentTextNodeMergerElaborator.lambda$elaborateForPull$0(AdjacentTextNodeMerger.java:273) at net.sf.saxon.expr.Atomizer$AtomizerElaborator.lambda$elaborateForPull$0(Atomizer.java:677) at net.sf.saxon.expr.AtomicSequenceConverter$AtomicSequenceConverterElaborator.lambda$elaborateForPull$0(AtomicSequenceConverter.java:536) at net.sf.saxon.expr.elab.LazyPullEvaluator.evaluate(LazyPullEvaluator.java:39) at net.sf.saxon.expr.SystemFunctionCall$SystemFunctionCallElaborator.lambda$elaborateForItem$6(SystemFunctionCall.java:663) at net.sf.saxon.expr.instruct.ValueOf$ValueOfElaborator.lambda$elaborateForItem$3(ValueOf.java:438) at net.sf.saxon.expr.elab.SimpleNodePushElaborator.lambda$elaborateForPull$0(SimpleNodePushElaborator.java:34) at net.sf.saxon.expr.instruct.Choose$ChooseExprElaborator.lambda$elaborateForPull$0(Choose.java:1071) at net.sf.saxon.expr.LetExpression$LetExprElaborator.lambda$elaborateForPull$5(LetExpression.java:927) at net.sf.saxon.value.SingletonClosure.asItem(SingletonClosure.java:104) at net.sf.saxon.value.SingletonClosure.iterate(SingletonClosure.java:64) at net.sf.saxon.expr.UserFunctionCall$UserFunctionCallElaborator.lambda$elaborateForPull$0(UserFunctionCall.java:746) at net.sf.saxon.expr.AdjacentTextNodeMerger$AdjacentTextNodeMergerElaborator.lambda$elaborateForPull$0(AdjacentTextNodeMerger.java:273) at net.sf.saxon.expr.Atomizer$AtomizerElaborator.lambda$elaborateForPull$0(Atomizer.java:677) at net.sf.saxon.expr.AtomicSequenceConverter$AtomicSequenceConverterElaborator.lambda$elaborateForPull$0(AtomicSequenceConverter.java:536) at net.sf.saxon.expr.elab.LazyPullEvaluator.evaluate(LazyPullEvaluator.java:39) at net.sf.saxon.expr.SystemFunctionCall$SystemFunctionCallElaborator.lambda$elaborateForItem$6(SystemFunctionCall.java:663) at net.sf.saxon.expr.instruct.ValueOf$ValueOfElaborator.lambda$elaborateForItem$3(ValueOf.java:438) at net.sf.saxon.expr.elab.OptionalItemEvaluator.evaluate(OptionalItemEvaluator.java:41) at net.sf.saxon.expr.instruct.Choose$EagerChooseEvaluator.evaluate(Choose.java:1248) at net.sf.saxon.expr.elab.LearningEvaluator.evaluate(LearningEvaluator.java:59) at net.sf.saxon.expr.instruct.UserFunction.call(UserFunction.java:704) ... 81 more java.lang.RuntimeException: Internal error evaluating template rule at line 59 in module file:/Users/mike/bugs/2023/6249-Boughton/saxon/preprocess.xsl at net.sf.saxon.expr.instruct.TemplateRule.applyLeavingTail(TemplateRule.java:386) at net.sf.saxon.trans.Mode.handleRuleNotNull(Mode.java:587) at net.sf.saxon.trans.Mode.applyTemplates(Mode.java:521) at net.sf.saxon.expr.instruct.ApplyTemplates$ApplyTemplatesPackage.processLeavingTail(ApplyTemplates.java:548) at net.sf.saxon.trans.Mode.applyTemplates(Mode.java:476) at net.sf.saxon.expr.instruct.ApplyTemplates$ApplyTemplatesPackage.processLeavingTail(ApplyTemplates.java:548) at net.sf.saxon.trans.Mode.applyTemplates(Mode.java:476) at net.sf.saxon.expr.instruct.ApplyTemplates$ApplyTemplatesPackage.processLeavingTail(ApplyTemplates.java:548) at net.sf.saxon.trans.Mode.applyTemplates(Mode.java:476) at net.sf.saxon.expr.instruct.ApplyTemplates$ApplyTemplatesElaborator.lambda$elaborateForPush$1(ApplyTemplates.java:650) at net.sf.saxon.expr.instruct.Choose$ChooseExprElaborator.lambda$elaborateForPush$11(Choose.java:1174) at net.sf.saxon.expr.instruct.Block$BlockElaborator.lambda$elaborateForPush$1(Block.java:853) at net.sf.saxon.expr.LetExpression$LetExprElaborator.lambda$elaborateForPush$6(LetExpression.java:942) at net.sf.saxon.expr.instruct.Block$BlockElaborator.lambda$elaborateForPush$4(Block.java:895) at net.sf.saxon.expr.instruct.FixedElement$FixedElementElaborator.lambda$elaborateForPush$0(FixedElement.java:640) at net.sf.saxon.expr.instruct.Choose$ChooseExprElaborator.lambda$elaborateForPush$11(Choose.java:1173) at net.sf.saxon.expr.instruct.Block$BlockElaborator.lambda$elaborateForPush$3(Block.java:885) at net.sf.saxon.expr.instruct.NamedTemplate.expand(NamedTemplate.java:247) at net.sf.saxon.expr.instruct.CallTemplate$CallTemplatePackage.processLeavingTail(CallTemplate.java:515) at net.sf.saxon.trans.Mode.applyTemplates(Mode.java:476) at net.sf.saxon.expr.instruct.ApplyTemplates$ApplyTemplatesPackage.processLeavingTail(ApplyTemplates.java:548) at net.sf.saxon.trans.Mode.applyTemplates(Mode.java:476) at net.sf.saxon.expr.instruct.ApplyTemplates$ApplyTemplatesPackage.processLeavingTail(ApplyTemplates.java:548) at net.sf.saxon.trans.Mode.applyTemplates(Mode.java:476) at net.sf.saxon.expr.instruct.ApplyTemplates$ApplyTemplatesPackage.processLeavingTail(ApplyTemplates.java:548) at net.sf.saxon.trans.Mode.applyTemplates(Mode.java:476) at net.sf.saxon.expr.instruct.ApplyTemplates$ApplyTemplatesElaborator.lambda$elaborateForPush$1(ApplyTemplates.java:650) at net.sf.saxon.expr.instruct.Block$BlockElaborator.lambda$elaborateForPush$3(Block.java:885) at net.sf.saxon.expr.instruct.Copy$CopyElaborator.lambda$elaborateForPush$0(Copy.java:589) at net.sf.saxon.expr.instruct.Choose$ChooseExprElaborator.lambda$elaborateForPush$11(Choose.java:1173) at net.sf.saxon.expr.instruct.TemplateRule.applyLeavingTail(TemplateRule.java:376) at net.sf.saxon.trans.Mode.handleRuleNotNull(Mode.java:587) at net.sf.saxon.trans.Mode.applyTemplates(Mode.java:521) at net.sf.saxon.expr.instruct.ApplyTemplates$ApplyTemplatesPackage.processLeavingTail(ApplyTemplates.java:548) at net.sf.saxon.trans.Mode.applyTemplates(Mode.java:476) at net.sf.saxon.trans.XsltController.applyTemplates(XsltController.java:688) at net.sf.saxon.s9api.AbstractXsltTransformer.applyTemplatesToSource(AbstractXsltTransformer.java:440) at net.sf.saxon.s9api.Xslt30Transformer.applyTemplates(Xslt30Transformer.java:306) at net.sf.saxon.Transform.processFile(Transform.java:1431) at net.sf.saxon.Transform.doTransform(Transform.java:917) at net.sf.saxon.Transform.main(Transform.java:83) Caused by: java.lang.RuntimeException: Internal error evaluating template rule at line 407 in module file:/Users/mike/bugs/2023/6249-Boughton/saxon/preprocess.xsl at net.sf.saxon.expr.instruct.TemplateRule.applyLeavingTail(TemplateRule.java:386) at net.sf.saxon.trans.Mode.handleRuleNotNull(Mode.java:587) at net.sf.saxon.trans.Mode.applyTemplates(Mode.java:521) at net.sf.saxon.expr.instruct.ApplyTemplates$ApplyTemplatesElaborator.lambda$elaborateForPush$1(ApplyTemplates.java:650) at net.sf.saxon.expr.instruct.Copy$CopyElaborator.lambda$elaborateForPush$0(Copy.java:589) at net.sf.saxon.expr.instruct.TemplateRule.applyLeavingTail(TemplateRule.java:376) ... 40 more Caused by: java.lang.RuntimeException: Internal error evaluating function fn:match at line 812 in module file:/Users/mike/bugs/2023/6249-Boughton/saxon/preprocess.xsl at net.sf.saxon.expr.instruct.UserFunction.call(UserFunction.java:714) at net.sf.saxon.expr.UserFunctionCall$UserFunctionCallElaborator.lambda$elaborateForPull$0(UserFunctionCall.java:746) at net.sf.saxon.expr.elab.PullElaborator.lambda$elaborateForBoolean$2(PullElaborator.java:65) at net.sf.saxon.functions.NotFn$NotFnElaborator.lambda$elaborateForBoolean$0(NotFn.java:129) at net.sf.saxon.expr.instruct.Choose$ChooseExprElaborator.lambda$elaborateForPush$10(Choose.java:1168) at net.sf.saxon.expr.instruct.Choose$ChooseExprElaborator.lambda$elaborateForPush$12(Choose.java:1179) at net.sf.saxon.expr.instruct.NamedTemplate.expand(NamedTemplate.java:247) at net.sf.saxon.expr.instruct.CallTemplate$CallTemplatePackage.processLeavingTail(CallTemplate.java:515) at net.sf.saxon.trans.Mode.applyTemplates(Mode.java:476) at net.sf.saxon.expr.instruct.ApplyTemplates$ApplyTemplatesElaborator.lambda$elaborateForPush$1(ApplyTemplates.java:650) at net.sf.saxon.expr.instruct.Block$BlockElaborator.lambda$elaborateForPush$4(Block.java:895) at net.sf.saxon.expr.instruct.Copy$CopyElaborator.lambda$elaborateForPush$0(Copy.java:589) at net.sf.saxon.expr.instruct.Block$BlockElaborator.lambda$elaborateForPush$1(Block.java:853) at net.sf.saxon.expr.instruct.TemplateRule.applyLeavingTail(TemplateRule.java:376) ... 45 more
Updated by Michael Kay about 1 year ago
The key part of this is:
at net.sf.saxon.expr.AxisExpression$AxisExpressionElaborator.lambda$elaborateForPull$1(AxisExpression.java:1278)
at net.sf.saxon.expr.FilterExpression$FilterExprElaborator.lambda$elaborateForPull$0(FilterExpression.java:1277)
at net.sf.saxon.expr.SlashExpression$SlashExprElaborator.lambda$elaborateForPull$1(SlashExpression.java:1118)
at net.sf.saxon.functions.Exists$ExistsFnElaborator.lambda$elaborateForBoolean$0(Exists.java:110)
at net.sf.saxon.expr.elab.BooleanElaborator.lambda$elaborateForPull$0(BooleanElaborator.java:25)
at net.sf.saxon.expr.FunctionCall.iterate(FunctionCall.java:624)
at net.sf.saxon.expr.instruct.EvaluateInstr$EvaluateInstrElaborator.lambda$elaborateForPull$4(EvaluateInstr.java:690)
at net.sf.saxon.expr.elab.EagerPullEvaluator.evaluate(EagerPullEvaluator.java:37)
which shows that (a) we're in an xsl:evaluate
instruction, (b) there is no context item, (c) we made a decision, based on static inferencing, that we didn't need to check whether there was a context item.
Updated by Michael Kay about 1 year ago
The dynamic expression being evaluated is
exists(brand[@id='1055623MUCSMUB_0285']/legal_disclaimer)
so it does indeed have a dependency on the context item.
The call on xsl:evaluate is on line 228 of table-lookup.xsl, and reads:
<xsl:evaluate xpath="'exists(' || $query || ')'" context-item="$xml.data"/>
The variable $xml.data
is defined as
<xsl:variable name="xml.data"/>
which means it should be a zero-length string. Ah! there's an overriding variable of the same name in preprocess.xsl
defined as
<xsl:variable name="xml.data" select="$doc/data"/>
and this (correctly, it seems) evaluates to an empty sequence.
The Saxon code at EvaluateInstr#623 seems to be assuming that if the @context-item
attribute is present, then there will be a context item, and it is setting the context item static type accordingly. This results in the XPDY0002 error not being properly detected, and a NullPointerException
being thrown instead.
Updated by Michael Kay about 1 year ago
- Subject changed from Saxon reports internal error to Internal error reported: xsl:evaluate/@context-item expression is present, but evaluates to empty sequence
- Category set to XSLT conformance
- Priority changed from Low to Normal
- Applies to branch 11, 12, trunk added
- Platforms .NET, Java added
Updated by Michael Kay about 1 year ago
- Status changed from New to In Progress
Resolved by changing the code in EvaluateInstr#624 so the context item static type has the "mayBeUndefined" flag set if the static type of the @context-item
expression permits the value to be an empty sequence.
All that remains is to add a test case.
Updated by Michael Kay about 1 year ago
- Applies to branch deleted (
11)
Note that the relevant code was added to fix bug #5626, and that 12.x has therefore deviated from 11.x in this area. The failure does not occur in 11.6.
Updated by Michael Kay about 1 year ago
So why don't the existing tests evaluate-024 and evaluate-025 detect this bug? It seems that the difference is that in those cases, the @context-item
expression is statically known to be an empty sequence, and this results in the evaluated expression failing statically rather than dynamically.
No, that's not enough.
It's also necessary that the expression being evaluated dynamically is complex enough to require a new XPathContext object to be created. That can be achieved by adding the predicate - a simple a/b/c path is not enough. I've now reproduced the failure in XSLT3 test case evaluate-025a.
Updated by Michael Kay about 1 year ago
- Status changed from In Progress to Resolved
- Fix Committed on Branch 12, trunk added
Updated by O'Neil Delpratt about 1 year ago
- Status changed from Resolved to Closed
- % Done changed from 0 to 100
- Fixed in Maintenance Release 12.4 added
Bug fix applied in the Saxon 12.4 maintenance release
Please register to edit this issue