Chapter 3Pipelines vs. Graphs

XML Calabash transforms a pipeline into a collection of graphs. It is the graphs that are evaluated at runtime.

T.B.D. This chapter needs a lot of work. It needs to be written, really. 🙂

To explore the difference between pipelines and graphs, consider the example pipeline in Figure 3.1, “Sample debugging pipeline”.

The pipeline declares two steps and uses one additional compound step.

 1 |<p:declare-step xmlns:p="http://www.w3.org/ns/xproc"
   |                xmlns:ex="https://xmlcalabash.com/ns/examples"
   |                xmlns:xs="http://www.w3.org/2001/XMLSchema"
   |                version="3.0">
 5 |<p:output port="result" sequence="true"/>
   | 
   |<p:declare-step type="ex:ident">
   |  <p:input port="source" sequence="true"/>
   |  <p:output port="result" sequence="true"/>
10 |  <p:identity/>
   |</p:declare-step>
   | 
   |<p:xinclude>
   |  <p:with-input href="../xml/default-input.xml"/>
15 |</p:xinclude>
   | 
   |<ex:ident name="ex1"/>
   | 
   |<p:for-each>
20 |  <p:with-input select="/ex:doc/*"/>
   |  <p:identity name="id1"/>
   |  <p:add-attribute name="add"
   |                   attribute-name="role" attribute-value="test"/>
   |</p:for-each>
25 | 
   |<p:wrap-sequence expand-text="false"
   |                 wrapper="Q{https://xmlcalabash.com/ns/examples}set"/>
   | 
   |<p:identity name="id2"/>
30 | 
   |</p:declare-step>
Figure 3.1Sample debugging pipeline

The processor analyzes the pipeline (resolves use-when attributes, default readable ports, etc.) and constructs a model like the one shown in Figure 3.2, “The pipeline model”.

Figure 3.2The pipeline model

The processor makes some changes in the pipeline. Some occurrences of p:document, p:inline, and even p:option and p:variable, are “promoted” to steps. This would be burdonsome for authoring, but simplifies the implementation.

The processor then analyzes the pipeline to construct a set of graphs. It’s the actual graph that gets executed. The graph for this pipeline is shown in Figure 3.3, “The pipeline graph model”.

Figure 3.3The pipeline graph model

Compound steps are represented as separate graphs. They have also grown “head” and “foot” steps that manage the boundaries.