2

I have an XProc pipeline with two http-request steps. The first http-request retrieves an XML document containing a sequence of RDF/XML documents. An xquery step extracts only the RDF/XML, which I then want to post to a SPARQL endpoint in the second http-request. In the last step, I want to retrieve the data from the SPARQL endpoint again so that I can do further processing.

I've tried following the solution to a similar question, but I get an error (in XML Calabash) stating, Expression could not be evaluated: c:request/c:body: Prefix c has not been declared. Here is the current pipeline, which is being submitted via XForms to the Calabash Piperack service:

<p:declare-step name="main" version="1.0"
    xmlns:p="http://www.w3.org/ns/xproc"
    xmlns:c="http://www.w3.org/ns/xproc-step"
    xmlns:cx="http://xmlcalabash.com/ns/extensions">
    <p:input port="source"/>
    <p:output port="result"/>
    <p:import href="http://localhost:8984/static/rdf.xpl"/>
    <p:http-request>
        <p:input port="source">
            <p:inline>
                <c:request method="GET"
                    href="http://localhost:9070/all?query=dc.title=test+search&amp;startRecord=1&amp;maximumRecords=50&amp;recordSchema=bibframe"/>
            </p:inline>
        </p:input>
    </p:http-request>
    <p:xquery name="xq">
        <p:input port="query">
            <p:inline>
                <c:query> 
                    declare namespace rdf =
                    "http://www.w3.org/1999/02/22-rdf-syntax-ns#";
                    element rdf:RDF { 
                        let $rdf := //rdf:RDF 
                        for $r in $rdf/* 
                        return $r 
                    } </c:query>
            </p:inline>
        </p:input>
        <p:input port="parameters">
            <p:empty/>
        </p:input>
    </p:xquery>
    <p:insert match="c:request/c:body" position="first-child">
        <p:input port="source">
            <p:inline>
                <c:request method="POST"
                    href="http://localhost:3030/bibframe/data?graph=cwb:tmp">
                    <c:body content-type="application/rdf+xml"/>
                </c:request>
            </p:inline>
        </p:input>
        <p:input port="insertion">
            <p:pipe step="xq" port="result"/>
        </p:input>
    </p:insert>
    <p:http-request/>
    <p:sink/>
    <cx:rdf-load
        href="http://localhost:3030/bibframe/get?graph=cwb:tmp"                                 
        language="turtle">
        <p:input port="source">
           <p:empty/>
        </p:input>
    </cx:rdf-load>      
</p:declare-step>

If I change the XPath in the @match attribute of the p:insert step to /*[local-name() = 'request']/*[local-name() = 'body'], then the prefix error disappears and the post submission works correctly. But is there a way to do this with the prefix?

Finally, the rdf-load step is executing before the other steps have completed, but I need it to always execute last. How can I do this, given that the rdf-load step is not taking direct input from the other steps?

Community
  • 1
  • 1
tat
  • 321
  • 1
  • 19

0 Answers0