<?xml version="1.0" encoding="UTF-8"?>
<essay xml:lang="en" version="5.0" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:dcterms="http://purl.org/dc/terms/" xmlns:gal="http://norman.walsh.name/rdf/gallery#" xmlns:foaf="http://xmlns.com/foaf/0.1/">
<info>
    
    
    
    
    
    
    
    
<title>It's Alive!</title><biblioid class="uri">http://norman.walsh.name/2006/04/21/xprocRuns</biblioid>
<volumenum>9</volumenum>
<issuenum>45</issuenum>
<pubdate>2006-04-21T16:13:06-04:00</pubdate>
<date>$Date: 2007-04-05 09:55:02 -0400 (Thu, 05 Apr 2007) $</date>
<author>
      <personname>
<firstname>Norman</firstname>
	<surname>Walsh</surname>
</personname>
    </author>
<copyright>
      <year>2006</year>
      <holder>Norman Walsh</holder>
    </copyright>
<abstract>
<para>My XProc implementation successfully loaded and evaluated it's
first pipeline without throwing an exception, hanging, or otherwise falling
over. Pardon the melodramatic title, please.</para>
</abstract>
<dc:subject rdf:resource="http://norman.walsh.name/knows/taxonomy#XProc"/>
</info>

<epigraph>
<attribution>
      <personname>
	<firstname>T. S.</firstname>
<surname>Eliot</surname>
      </personname>
    </attribution>
<para xml:id="p2">Success is relative; it is what we make of the
mess we have made of things.</para>
</epigraph>

<para xml:id="p1">I'm determined to build an implementation of
<wikipedia page="XML_pipeline">XProc</wikipedia> as
<link xlink:href="http://www.w3.org/XML/Processing/">we</link> develop it,
so for the past couple of weeks I've been carving out as much time as
I can to get some sort of a skeleton off the ground. It's too early in
the process to imagine that I'm implementing the language that
<link xlink:href="http://www.w3.org/XML/XProc/docs/langspec.html">our
specification</link> will eventually describe, but I'm shooting in the
right direction, I hope.</para>

<para xml:id="p3">In broad strokes, my implementation strategy is to
represent each step in the pipeline as a component that can run
in its own thread. Bolt the inputs to the outputs, unleash the threads,
throw <link xlink:href="http://en.wikipedia.org/wiki/StAX">StAX</link>
events through the pipes, wait until done, and then pick up the
output. I'm sure it'll grow more complicated than that, but for a very
simple pipeline, that works.</para>

<para xml:id="p4">Yesterday, my code ran it's first pipeline, constructed by
hand something like this:</para>

<programlisting>…
Load loadStyle = new Load();
loadStyle.setParam ("href", new DocumentReader("/projects/src/StaxTest/test/style.xsl"));

Load loadDoc = new Load();
loadDoc.setParam ("href", new DocumentReader("/projects/src/StaxTest/test/input.xml"));

XSLT10 transform = new XSLT10();

Connector styleConn = new Connector();
Connector docConn = new Connector();

loadStyle.setOutput ("output", styleConn.getWriter());
transform.setInput ("stylesheet", styleConn.getReader());

loadDoc.setOutput ("output", docConn.getWriter ());
transform.setInput ("document", docConn.getReader ());
…</programlisting>

<para xml:id="p5">Today, it loaded and evaluated a pipeline document
describing that pipeline:</para>

<programlisting>&lt;p:pipeline xmlns:p="http://xproc.org/ns/p"&gt;

&lt;p:step name="p:xslt10"&gt;
  &lt;p:input name="document" label="doc"/&gt;
  &lt;p:input name="stylesheet" label="style"/&gt;
  &lt;p:output name="output" label="out"/&gt;
&lt;/p:step&gt;

&lt;p:step name="p:load"&gt;
  &lt;p:param name="href" value="/projects/src/StaxTest/test/style.xsl"/&gt;
  &lt;p:output name="output" label="style"/&gt;
&lt;/p:step&gt;

&lt;p:step name="p:load"&gt;
  &lt;p:param name="href" value="/projects/src/StaxTest/test/input.xml"/&gt;
  &lt;p:output name="output" label="doc"/&gt;
&lt;/p:step&gt;

&lt;p:step name="p:save"&gt;
  &lt;p:param name="href" value="/tmp/pipeout.xml"/&gt;
  &lt;p:input name="input" label="out"/&gt;
&lt;/p:step&gt;

&lt;/p:pipeline&gt;</programlisting>

<para xml:id="p6">Sweet! (Yes, it's silly to put the XSLT step before
the load steps, but I was testing the code that picks a component order.)</para>

<para xml:id="p7">It loads a configuration file to determine how to initialize
each component (<foreignphrase>e.g.</foreignphrase>, what class to
instantiate). The configuration file also tells it something about the
inputs, outputs, and parameters (<foreignphrase>e.g.</foreignphrase>, the
fact that <tag class="attribute">href</tag> on the “load” component
identifies an input file that has to be parsed, but 
<tag class="attribute">href</tag> on the “save” component is just a string).
</para>

<para xml:id="p8">Baby steps, sure, but it put a smile on my face to see:</para>

<programlisting>run:
Node: 1: p:load: 1
Node: 2: p:load: 2
Node: 3: p:xslt10: 3
Node: 4: p:save: 4
INFO: Set param href (tree)
INFO: Set output output
INFO: Set input stylesheet
INFO: Set param href (tree)
INFO: Set output output
INFO: Set input document
INFO: Set output output
INFO: Set input input
INFO: Set param href=/tmp/pipeout.xml
Starting component for p:load
Starting component for p:load
INFO: Running Load
INFO: Running Load
Starting component for p:xslt10
Starting component for p:save
INFO: Running XSLT10
INFO: Running Save.
INFO: Skipping bogus attempt to write some sort of namespace decl attribute
BUILD SUCCESSFUL (total time: 0 seconds)</programlisting>

<para xml:id="p9">I'm gonna call that a days work.
Time for a drink, I think!</para>

</essay>

