Project

Profile

Help

arithmetic on xs:date results in NPE

Added by Anonymous almost 20 years ago

Legacy ID: #3012002 Legacy Poster: marcvc (marcvc)

Michael, might be that you're aware of it, but I could not find it in the "bugs" section. In certain scenarios (when evaluated at compile time?) arithmetic operations on xs:dates (probably also xs:time and xs:dateTime) results in a NPE. I believe this is new in Saxon 8.3 Query: xs:date("1996-04-14") - xs:date("1996-04-15") Results in: java.lang.NullPointerException at net.sf.saxon.value.DateTimeValue.getCurrentDateTime(DateTimeValue.java:34) at net.sf.saxon.functions.CurrentDateTime.getImplicitTimezone(CurrentDateTime.java:70) at net.sf.saxon.value.CalendarValue.subtract(CalendarValue.java:34) at net.sf.saxon.value.DateValue.subtract(DateValue.java:415) at net.sf.saxon.expr.ArithmeticExpression$DateDifference.evaluateItem(ArithmeticExpression.java:828) at net.sf.saxon.expr.ArithmeticExpression.evaluateItem(ArithmeticExpression.java:391) at net.sf.saxon.expr.ExpressionTool.eagerEvaluate(ExpressionTool.java:273) at net.sf.saxon.expr.BinaryExpression.analyze(BinaryExpression.java:60) at net.sf.saxon.expr.ArithmeticExpression.analyze(ArithmeticExpression.java:150) at net.sf.saxon.query.XQueryExpression.<init>(XQueryExpression.java:54) at net.sf.saxon.query.QueryParser.makeXQueryExpression(QueryParser.java:71) at net.sf.saxon.query.QueryProcessor.compileQuery(QueryProcessor.java:162) at net.sf.saxon.query.QueryProcessor.compileQuery(QueryProcessor.java:189) at net.sf.saxon.query.StaticQueryContext.compileQuery(StaticQueryContext.java:183) at net.sf.saxon.Query.doMain(Query.java:334) at net.sf.saxon.Query.main(Query.java:76) Thanks, Marc


Replies (1)

RE: arithmetic on xs:date results in NPE - Added by Anonymous almost 20 years ago

Legacy ID: #3012078 Legacy Poster: Michael Kay (mhkay)

Thanks for the report. I wasn't aware of this specific problem, but I was aware of a general design problem with expressions that need access to the implicit time zone even though they consist entirely of values. Saxon tracks the dependency of expressions on the context, but assumes that constant values have no such dependencies, which makes this kind of expression rather a challenge. There's already code in DateTimeValue.currentDateTime() that attempts to deal with the absence of a Controller and I'll patch it so it can also deal with the absence of an XPathContext. For a more radical fix I'll await the outcome of the round of discussions that's taking place (yet again) on the semantics of operations with and without timezones.

    (1-1/1)

    Please register to reply