Overview

Callimachus supports XProc pipeline documents as first-class Pipeline objects. It uses the Calabash XProc implementation for this purpose. Pipeline objects can be created in a folder (selecting the 'Pipeline' item from the create menu) and given content that conforms with the XProc: An XML Pipeline Language specification.

Then, POST and GET requests can be dispatched to them as web resource in order to invoke the pipeline and return the XML document from the result primary output port as the body of the response. The query component of the request URI can be used to pass values in as options into the pipeline.

The input document for the source port (declared as a document input of the pipeline) can be specified for the instantiation of the pipeline.

HTTP Methods

XProc pipelines can be invoked by POST and GET requests using their URL as the request URL along with request in the query component. We will refer to this as the result URL. For example:

..pipeline..URL..?results

Additional key / value pairs can be used in the query component to pass options into the XProc pipeline. This is discussed in the next section.

Sending an HTTP GET request to the result URL will trigger an instantiation of the pipeline without providing an input document in the source port. The pipeline would have to take care of that by either embedding the input document into the pipeline or requesting it using the p:load step, for example:

<?xml version="1.0" encoding="UTF-8" ?>
<p:pipeline xmlns:p="http://www.w3.org/ns/xproc" version="1.0" name="pipeline">

    <p:load href="my-query.rq?results" />

    <p:xslt> 
        <p:input port="stylesheet">
            <p:document href="my-transform.xsl" />      
        </p:input>
    </p:xslt>

</p:pipeline>

Note the URL used by the p:load step can identify a Callimachus web resource (an XML document), facilitating the use of Callimachus web resources as XProc pipelines and inputs to such pipelines.

Sending an HTTP POST request to the result URL will trigger an instantiation of the pipeline, passing the request body as an input document for the source port.

Pipeline Options

Any query parameters appended to the result URL, as additional query components, will be passed into the pipeline as options name/value string pairs, if the pipeline declares the options.

So a POST request to:

..pipeline..URL..?results&foo=bar

To the following pipeline:

<?xml version="1.0" encoding="UTF-8" ?>
<p:pipeline xmlns:p="http://www.w3.org/ns/xproc" version="1.0" name="pipeline">

    <p:option name="foo" required="true" />

    <p:load>
        <p:with-option name="href" select="concat('my-query.rq?results&amp;foo=', encode-for-uri($foo))"/>
    </p:load>

    <p:xslt> 
        <p:input port="stylesheet">
            <p:document href="my-transform.xsl" />      
        </p:input>
    </p:xslt>

</p:pipeline>

Will pass the foo option as a query parameter to the named query my-query.rq and use the result as the source for the xsl transformation.

I.e., the options are passed into the pipeline document as in-scope bindings options.