Thanks for reporting this. I have registered it at
 
https://sourceforge.net/tracker2/?func=detail&aid=2315436&group_id=29872&atid=397617
 
and a patch is in Subversion.
 
Michael Kay
http://www.saxonica.com/


From: Rademacher, Gunther [mailto:Gunther.Rademacher@softwareag.com]
Sent: 18 November 2008 21:17
To: Mailing list for the SAXON XSLT and XQuery processor
Subject: [saxon] NPE while compiling XQuery

The reason for finding this was a bug in my XQuery coding. While searching
for it, I came across a NullPointerException. I tried to reduce it to a minimum
query, and the smallest reproduction I could find is:

    let $t := text{<e>0</e>/data((+., @a))} return max($t)
  
Interestingly, the exception does not show up when the query is fired from
the command line via net.sf.saxon.Query. I do however get it when submitting
it to Kernow, or to this Java code:

    import java.io.PrintWriter;
    import javax.xml.transform.stream.StreamResult;
    import net.sf.saxon.Configuration;
    import net.sf.saxon.query.DynamicQueryContext;
    import net.sf.saxon.query.StaticQueryContext;
    import net.sf.saxon.query.XQueryExpression;   
    public class XQuery
    {
      public static void main(String[] args) throws Exception
      {
        Configuration c = new Configuration();
        StaticQueryContext s = new StaticQueryContext(c);
        XQueryExpression e = s.compileQuery(args[0]);
        DynamicQueryContext d = new DynamicQueryContext(c);
        StreamResult r = new StreamResult(System.out);
        e.run(d, r, null);
      }
    }

This occurs with Saxon 9.1.0.2/3J and Java 1.5 or 1.6.

Best regards
Gunther


java.lang.NullPointerException
        at net.sf.saxon.expr.Expression.getExecutable(Expression.java:728)
        at net.sf.saxon.expr.SingletonAtomizer.getItemType(SingletonAtomizer.java:176)
        at net.sf.saxon.expr.UntypedAtomicConverter.getItemType(UntypedAtomicConverter.java:66)
        at net.sf.saxon.expr.ArithmeticExpression.getItemType(ArithmeticExpression.java:255)
        at net.sf.saxon.instruct.Block.getItemType(Block.java:274)
        at net.sf.saxon.expr.Atomizer.computeSingleValued(Atomizer.java:95)
        at net.sf.saxon.expr.Atomizer.<init>(Atomizer.java:37)
        at net.sf.saxon.expr.Atomizer.copy(Atomizer.java:155)
        at net.sf.saxon.expr.AtomicMappingExpression.copy(AtomicMappingExpression.java:56)
        at net.sf.saxon.instruct.QuerySimpleContentConstructor.copy(QuerySimpleContentConstructor.java:55)
        at net.sf.saxon.instruct.ValueOf.copy(ValueOf.java:159)
        at net.sf.saxon.expr.PromotionOffer.accept(PromotionOffer.java:234)
        at net.sf.saxon.expr.VariableReference.promote(VariableReference.java:376)
        at net.sf.saxon.expr.Expression.doPromotion(Expression.java:755)
        at net.sf.saxon.expr.UnaryExpression.promote(UnaryExpression.java:104)
        at net.sf.saxon.expr.Expression.doPromotion(Expression.java:755)
        at net.sf.saxon.expr.FunctionCall.promote(FunctionCall.java:207)
        at net.sf.saxon.expr.Expression.doPromotion(Expression.java:755)
        at net.sf.saxon.expr.LetExpression.replaceVariable(LetExpression.java:510)
        at net.sf.saxon.expr.LetExpression.optimize(LetExpression.java:208)
        at net.sf.saxon.query.XQueryExpression.<init>(XQueryExpression.java:77)
        at net.sf.saxon.query.QueryParser.makeXQueryExpression(QueryParser.java:121)
        at net.sf.saxon.query.StaticQueryContext.compileQuery(StaticQueryContext.java:343)


Software AG – Sitz/Registered office: Uhlandstraße 12, 64297 Darmstadt, Germany, – Registergericht/Commercial register: Darmstadt HRB 1562 - Vorstand/ Management Board: Karl-Heinz Streibich (Vorsitzender/Chairman), David Broadbent, Mark Edwards, Holger Friedrich, Dr. Peter Kürpick, Arnd Zinnhardt; - Aufsichtsratsvorsitzender/ Chairman of the Supervisory Board: Frank F. Beelitz - http://www.softwareag.com