direct PI constructor and fn:data

Help
marcvc
2004-10-25
2012-10-08
  • marcvc

    marcvc - 2004-10-25

    Michael,

    there seems to be an issue with fn:data used in the name expression of a direct PI constructor.

    Consider the following query:
    processing-instruction {data('a')} {'b'}

    In Saxon 8.0:
    java.lang.IllegalStateException: Function data should have been resolved at compile-time

    In Saxon 8.1:
    java.lang.NullPointerException
    at net.sf.saxon.expr.TypeChecker.staticTypeCheck(TypeChecker.java:76)

    Thanks,
    Marc

     
    • Michael Kay

      Michael Kay - 2004-10-25

      Thanks for reporting this.

      There are two separate errors at play here.

      Firstly, net.sf.saxon.instruct.ProcessingInstruction lacks a simplify() method. This should read:

      public Expression simplify(StaticContext env) throws XPathException {
          name = name.simplify(env);
          return super.simplify(env);
      }
      

      This accounts for the symptoms observed in 8.0.

      Secondly, the type signature for the data() function is not set up correctly.

      In line 158 of StandardFunction.java, the line

          register("data", Data.class, 0, 1, 1, Type.ANY_ATOMIC_TYPE, StaticProperty.ALLOWS_ZERO_OR_MORE);
      

      should be changed to:

          e = register("data", Data.class, 0, 1, 1, Type.ANY_ATOMIC_TYPE, StaticProperty.ALLOWS_ZERO_OR_MORE);
      

      I don't think this error would ever show up in the absence of the other error: calls on data() should be simplified out (replaced by an internal atomization expression) before type checking takes place, which means the type signature of the function should never be accessed.

      Michael Kay
      http://www.saxonica.com/

       

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks