ndw / xmlcalabash1

XML Calabash, an XProc processor
http://xmlcalabash.com/
108 stars 41 forks source link

'ERROR: Pipeline failed: null' when evaluating p:iteration-position() #227

Open gimsieke opened 9 years ago

gimsieke commented 9 years ago

What’s happening is that a certain complex pipeline exits with said exception when I try to evaluate p:iteration-position().

When I replace a previous step that is the result of a cx:eval with something that doesn’t involve cx:eval, p:iteration-position() may be computed alright.

I’m just guessing, after several hours of tracking down this thing, that it might be related to cx:eval. It doesn’t matter though whether the cx:eval’s output or something unrelated is iterated over.

I’m posting the issue already despite of my current inability to post a handy repro because I have a faint hope that you immediately recognize what’s causing the exception when I mention cx:eval. However, I wouldn’t rule out the possibility that I’m still on the wrong track wrt identifying the error’s ultimate cause. If it doesn’t ring a bell then wait until I manage to post the repro in 3 weeks’ time or so.

gimsieke commented 9 years ago

Version info: XML Calabash version 1.1.5, an XProc processor. Running on Saxon version 9.6.0.7, HE edition.

ndw commented 9 years ago

I'm afraid it doesn't ring a bell. Can you run with -D and send me the stack trace?

grtjn commented 7 years ago

Getting same error message using latest XMLCalabash 1.1.16-97 with essentially https://github.com/xquery/xquerydoc/blob/master/xquerydoc.xpl (and some tweaks to replace collection(), since that was giving different errors). No cx:eval, and no p:iteration-position. Nor a stacktrace when I add -D to the command-line.. :(

grtjn commented 7 years ago

I traced things down somewhat to this bit:

    <!-- chokes with:
      ERROR: Pipeline failed: Required item type of result of call to collection is node(); supplied value has item type xs:base64Binary
    <p:variable name="source" select='collection(concat($base1,"?select=",$filename,";unparsed=yes"))'/>
    -->

    <!-- fails with:
      ERROR: Pipeline failed: null
    <p:variable name="source">
      <p:data content-type="text/plain">
        <p:with-option name="href" select="resolve-uri($filename, $base1)"/>
      </p:data>
    </p:variable>
    -->

    <!-- fails with:
      ERROR: Pipeline failed: null
    <p:variable name="source">
      <p:inline><query>1+1</query></p:inline>
    </p:variable>
    -->

    <!-- works:
    -->
    <p:variable name="source" select='"1+1"'/>

  <p:xquery name="run"> 
    <p:with-param name="source" select='$source'/>
    <p:input port="query">
      <p:inline>
        <query>
          xquery version "1.0" encoding "UTF-8";
          import module namespace xqdoc="http://github.com/xquery/xquerydoc" at "src/xquery/xquerydoc.xq";
          import module namespace xqp="http://github.com/jpcs/xqueryparser.xq" at "src/xquery/parsers/xqueryparser.xq";
          import module namespace p="XQueryML30" at "src/xquery/parsers/XQueryML30.xq";

          declare variable $format external;
          declare variable $source external;

          if($format eq 'raw') then
               p:parse-XQuery($source)
          else  if($format eq 'raw2') then
               let $markup := p:parse-XQuery($source)
               let $markup := xqp:_simplify($markup)
               let $ns :=  xqp:_build_namespaces($markup)
               return xqp:_analyze($markup,$ns)
          else 
             xqdoc:parse($source)
        </query>
      </p:inline>
    </p:input>
    <p:input port="parameters">
      <p:pipe step="vars" port="result"/>
    </p:input>   
  </p:xquery>

The line with <p:variable name="source" select='collection(concat($base1,"?select=",$filename,";unparsed=yes"))'/> is the original, but since that threw an error, I started looking for a workaround using p:data. That didn't work either, so tried p:inline as a simple test, which failed as well. Only selecting a plain string value for source seems to run without errors.

It looks like - or at least in my case - p:xquery doesn't like variables that contain anything other than strings..

Any suggestions welcome..