Project

Profile

Help

Bug #6081

closed

Saxon 12 XQuery: Error codes not appearing

Added by A Galtman about 1 year ago. Updated about 1 year ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Diagnostics
Sprint/Milestone:
-
Start date:
2023-06-19
Due date:
% Done:

100%

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

Description

I'm seeing two situations in Saxon 12.0 through 12.2 where XQuery output does not include error codes as in earlier Saxon versions. I'm not certain whether the behavior change is a bug or intended. The earlier behavior to report error codes was useful for automated tests of downstream applications for situations that are supposed to produce errors.

Below are small, self-contained queries that reproduce the behavior of my original two situations. If you'd like me to log them separately, let me know. Thanks!

Case 1: Does not report user-defined error code

Query

xquery version "3.1";

declare namespace xs = "http://www.w3.org/2001/XMLSchema";

declare function local:fcn($result as item()*) as item()* {
$result
};

(: the query body :)
let $result as item()* := error(xs:QName('my-error-code'))
return local:fcn($result)

Outputs

java -cp "C:\Program Files\Saxonica\SaxonHE11.5J\saxon-he-11.5.jar" net.sf.saxon.Query  -q:repro-issue-error-code.xq
Error on line 10 column 43 of repro-issue-error-code.xq:
  my-error-code  Error signalled by application call on error()
<?xml version="1.0" encoding="UTF-8"?>Query failed with dynamic error: Error signalled by application call on error()


java -cp "C:\Program Files\Saxonica\SaxonHE12.0J\saxon-he-12.0.jar" net.sf.saxon.Query  -q:repro-issue-error-code.xq
<?xml version="1.0" encoding="UTF-8"?>net.sf.saxon.trans.UncheckedXPathException: Error signalled by application call on error()
        at net.sf.saxon.value.SingletonClosure.iterate(SingletonClosure.java:81)
        at net.sf.saxon.expr.LocalVariableReference$LocalVariableReferenceElaborator.lambda$elaborateForPush$1(LocalVariableReference.java:214)
        at net.sf.saxon.expr.instruct.UserFunction.process(UserFunction.java:712)
        at net.sf.saxon.expr.UserFunctionCall$UserFunctionCallElaborator.lambda$elaborateForPush$5(UserFunctionCall.java:846)
        at net.sf.saxon.query.XQueryExpression.processQuery(XQueryExpression.java:499)
        at net.sf.saxon.query.XQueryExpression.run(XQueryExpression.java:473)
        at net.sf.saxon.s9api.XQueryEvaluator.run(XQueryEvaluator.java:464)
        at net.sf.saxon.Query.runQuery(Query.java:975)
        at net.sf.saxon.Query.doQuery(Query.java:444)
        at net.sf.saxon.Query.main(Query.java:106)
Caused by: net.sf.saxon.functions.Error$UserDefinedXPathException: Error signalled by application call on error()
        at net.sf.saxon.functions.Error.error(Error.java:67)
        at net.sf.saxon.functions.Error.call(Error.java:121)
        at net.sf.saxon.expr.SystemFunctionCall$SystemFunctionCallElaborator.lambda$elaborateForPull$1(SystemFunctionCall.java:608)
        at net.sf.saxon.value.SingletonClosure.asItem(SingletonClosure.java:112)
        at net.sf.saxon.value.SingletonClosure.iterate(SingletonClosure.java:72)
        ... 9 more
Fatal error during query: net.sf.saxon.trans.UncheckedXPathException: Error signalled by application call on error()

Case 2: Does not include standard error code XPDY0002

Query

xquery version "3.1";

declare function local:fcn($result as item()*) as xs:boolean {
boolean($result = 1)
};

let $result as item()* := ( count(child::element()) )
return local:fcn($result)

Outputs

java -cp "C:\Program Files\Saxonica\SaxonHE11.5J\saxon-he-11.5.jar" net.sf.saxon.Query  -q:repro-issue-no-context-for-child.xq
Error on line 7 column 52 of repro-issue-no-context-for-child.xq:
  XPDY0002  The context item for axis step ./element() is absent
     invoked by function call at file:/C:/.../repro-issue-no-context-for-child.xq#9
<?xml version="1.0" encoding="UTF-8"?>Query failed with dynamic error: The context item for axis step ./element() is absent


java -cp "C:\Program Files\Saxonica\SaxonHE12.0J\saxon-he-12.0.jar" net.sf.saxon.Query  -q:repro-issue-no-context-for-child.xq
<?xml version="1.0" encoding="UTF-8"?>net.sf.saxon.trans.UncheckedXPathException: The context item is absent
        at net.sf.saxon.value.SingletonClosure.iterate(SingletonClosure.java:81)
        at net.sf.saxon.expr.LocalVariableReference$LocalVariableReferenceElaborator.lambda$elaborateForPull$0(LocalVariableReference.java:205)
        at net.sf.saxon.expr.Atomizer$AtomizerElaborator.lambda$elaborateForPull$0(Atomizer.java:678)
        at net.sf.saxon.expr.GeneralComparison$GeneralComparisonElaborator.lambda$elaborateForBoolean$1(GeneralComparison.java:845)
        at net.sf.saxon.expr.elab.BooleanElaborator.lambda$elaborateForPush$1(BooleanElaborator.java:32)
        at net.sf.saxon.expr.instruct.UserFunction.process(UserFunction.java:712)
        at net.sf.saxon.expr.UserFunctionCall$UserFunctionCallElaborator.lambda$elaborateForPush$5(UserFunctionCall.java:846)
        at net.sf.saxon.query.XQueryExpression.processQuery(XQueryExpression.java:499)
        at net.sf.saxon.query.XQueryExpression.run(XQueryExpression.java:473)
        at net.sf.saxon.s9api.XQueryEvaluator.run(XQueryEvaluator.java:464)
        at net.sf.saxon.Query.runQuery(Query.java:975)
        at net.sf.saxon.Query.doQuery(Query.java:444)
        at net.sf.saxon.Query.main(Query.java:106)
Caused by: net.sf.saxon.trans.XPathException: The context item is absent
        at net.sf.saxon.expr.Expression.dynamicError(Expression.java:1460)
        at net.sf.saxon.expr.ContextItemExpression.reportAbsentContext(ContextItemExpression.java:334)
        at net.sf.saxon.expr.ContextItemExpression$ContextItemElaborator.lambda$elaborateForItem$0(ContextItemExpression.java:395)
        at net.sf.saxon.expr.ItemChecker$ItemCheckerElaborator.lambda$elaborateForItem$1(ItemChecker.java:463)
        at net.sf.saxon.expr.SimpleStepExpression$SimpleStepExprElaborator.lambda$elaborateForPull$1(SimpleStepExpression.java:185)
        at net.sf.saxon.functions.Count$CountFnElaborator.lambda$elaborateForItem$0(Count.java:135)
        at net.sf.saxon.expr.elab.ItemElaborator.lambda$elaborateForPull$0(ItemElaborator.java:36)
        at net.sf.saxon.value.SingletonClosure.asItem(SingletonClosure.java:112)
        at net.sf.saxon.value.SingletonClosure.iterate(SingletonClosure.java:72)
        ... 12 more
Fatal error during query: net.sf.saxon.trans.UncheckedXPathException: The context item is absent

Please register to edit this issue

Also available in: Atom PDF