XML Pipelines Part2XML Pipelines Part2
Sequencing an XQuery Pipeline. Pipeline exception handling
Home > Books > Tutorials and Training Guides > Pipeline Processing > XML Pipelines > XML Pipelines Part2

Rate this page:
Really useful
Satisfactory
Not helpful
Confusing
Incorrect
Unsure
Extra comments:


Sequencing an XQuery Pipeline. Pipeline exception handling

In the previous section we showed how the active: URI may be used to invoke an XQuery. We also showed that by using active URI as the argument to the XQuery doc() function we can construct simple XQuery pipelines. In this section we show how pipelines can be decoupled to provide flexible sequencing.

Decoupling the input

Below is the stage 1 XQuery, in this example, rather than use the doc() function, we have parameterized an input variable which can be passed to the xquery when it is executed.

<xquery> declare variable $input as node() external; &lt;content&gt; { $input//ACT[1] } &lt;/content&gt; </xquery>

In this section the pattern of input decoupling has been used for all of the XQueries we saw in the previous section, for example, below is the final stage 4 which again uses an input parameter rather than the doc() function.

<xquery> declare variable $input as node() external; &lt;gloucester&gt; { for $speech in $input//SPEECH for $line in $speech//LINE where contains( $line, 'France') return $speech } &lt;/gloucester&gt; </xquery>

Sequencing the pipeline

Now that the inputs have been parameterized we need to sequence the pipeline. Below is a DPML process which couples together the pipeline. The first instruction invokes XQuery 1, the second instruction invokes XQuery 2 and passes in the output of XQuery 1 as a parameter (here called var:pipe). The third invokes XQuery 3 with the output from 2 and so on through to stage 4 which finally returns the result as the response of the DPML process.

<idoc>
  <seq>
    <comment> ********* A 4 stage XQuery Pipeline ********** </comment>
    <instr>
      <type>xquery</type>
      <operator>xq1.xml</operator>
      <input>ffcpl:/content/lear.xml</input>
      <target>var:pipe</target>
    </instr>
    <instr>
      <type>xquery</type>
      <input>var:pipe</input>
      <operator>xq2.xml</operator>
      <target>var:pipe</target>
    </instr>
    <instr>
      <comment> *********** Here were using an inline literal XML document for the query. It makes no difference and can be very convenient for development. *********** </comment>
      <type>xquery</type>
      <input>var:pipe</input>
      <operator>
        <xquery> declare variable $input as node() external; &lt;gloucester&gt; { for $speech in $input//SPEECH where $speech/SPEAKER = 'GLOUCESTER' return $speech } &lt;/gloucester&gt; </xquery>
      </operator>
      <target>var:pipe</target>
    </instr>
    <instr>
      <type>xquery</type>
      <input>var:pipe</input>
      <operator>xq4.xml</operator>
      <target>this:response</target>
    </instr>
  </seq>
</idoc>

try it!

You will see that scheduling the pipeline at a higher level gives some flexibility in how we define or may change the process. However you will also see that this is a pretty useless pipeline since it is entirely static - in the next section we show how to create a dynamic pipeline.

© 2003-2007, 1060 Research Limited. 1060 registered trademark, NetKernel trademark of 1060 Research Limited.