W3C home > Mailing lists > Public > xproc-dev@w3.org > March 2010

Re: Calabash NullPointerExceptions

From: Norman Walsh <ndw@nwalsh.com>
Date: Wed, 10 Mar 2010 11:13:52 -0500
To: Natan Cox <natan.cox@gmail.com>
CC: XProc Dev <xproc-dev@w3.org>
Message-ID: <m2r5ns888v.fsf@nwalsh.com>
Natan Cox <natan.cox@gmail.com> writes:
[...]
> I was having some trouble getting a certain XProc step to work.
> Mainly my fault because I did something like
>
>   <p:xquery >
>     <p:input port="query">
>       <p:inline>
>           &lt;html> &lt;body> &lt;ul> ... query here ... &lt;/ul> &lt;/body> &lt;/html>
>      </p:inline>
>     </p:input>
>     <p:input port="parameters" sequence="true">
>       <p:empty/>
>     </p:input>
>   </p:xquery>
>
> forgetting c:query in the p:inline.
>
> I get a NullPointerException on node.getBaseURI()
>
>             S9apiUtils.writeXdmValue(runtime, nodes, dest, node.getBaseURI());
>
> It would easier for me if in ReadableInline you would add after
>
>         // Find the document element so we can get the base URI
>         XdmNode node = null;
>         for (int pos = 0; pos < nodes.size() && node == null; pos++) {
>             if (((XdmNode) nodes.get(pos)).getNodeKind() == XdmNodeKind.ELEMENT) {
>                 node = (XdmNode) nodes.get(pos);
>             }
>         }
>
> another null check on node and report a nice contextualized message
> of what I did wrong.

I would, but I can't reproduce your error. This works for me:

<p:declare-step version='1.0' xmlns:p="http://www.w3.org/ns/xproc" name="main"
                xmlns:cx="http://xmlcalabash.com/ns/extensions"
                xmlns:c="http://www.w3.org/ns/xproc-step">

  <p:output port="result"/>

  <p:xquery >
    <p:input port="source"><p:empty/></p:input>
    <p:input port="query">
      <p:inline>
        <c:data>
          &lt;html> &lt;body> &lt;ul> ... query here ... &lt;/ul> &lt;/body> &lt;/html>
        </c:data>
     </p:inline>
    </p:input>
    <p:input port="parameters">
      <p:empty/>
    </p:input>
  </p:xquery>

</p:declare-step>

Can you send me a pipeline that exhibits the problem?

                                        Be seeing you,
                                          norm

-- 
Norman Walsh <ndw@nwalsh.com> | In matters of style, swim with the
http://nwalsh.com/            | current; in matters of principle, stand
                              | like a rock.--Thomas Jefferson

Received on Wednesday, 10 March 2010 16:14:26 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Wednesday, 10 March 2010 16:14:27 GMT