It's Alive!

Volume 9, Issue 45; 21 Apr 2006; last modified 08 Oct 2010

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.

Success is relative; it is what we make of the mess we have made of things.

T. S. Eliot

I'm determined to build an implementation of XProc as we 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 our specification will eventually describe, but I'm shooting in the right direction, I hope.

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 StAX 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.

Yesterday, my code ran it's first pipeline, constructed by hand something like this:

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 ());

Today, it loaded and evaluated a pipeline document describing that pipeline:

<p:pipeline xmlns:p="">

<p:step name="p:xslt10">
  <p:input name="document" label="doc"/>
  <p:input name="stylesheet" label="style"/>
  <p:output name="output" label="out"/>

<p:step name="p:load">
  <p:param name="href" value="/projects/src/StaxTest/test/style.xsl"/>
  <p:output name="output" label="style"/>

<p:step name="p:load">
  <p:param name="href" value="/projects/src/StaxTest/test/input.xml"/>
  <p:output name="output" label="doc"/>

<p:step name="p:save">
  <p:param name="href" value="/tmp/pipeout.xml"/>
  <p:input name="input" label="out"/>


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.)

It loads a configuration file to determine how to initialize each component (e.g., what class to instantiate). The configuration file also tells it something about the inputs, outputs, and parameters (e.g., the fact that href on the “load” component identifies an input file that has to be parsed, but href on the “save” component is just a string).

Baby steps, sure, but it put a smile on my face to see:

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)

I'm gonna call that a days work. Time for a drink, I think!


Nice work! Title reminds me of the scene in BUG where the mutant cockroaches spell out "We Live"...

—Posted by Danny on 22 Apr 2006 @ 12:13 UTC #
This is very cool, good luck with the work, both in the WG and your implementation! 8-)

I'm slightly nervous however about the implied (as opposed to explicit) ordering in the pipeline language, that seems like an unnecessary feature to me.

—Posted by Jacek on 22 Apr 2006 @ 02:08 UTC #


I was wondering if there is any resource explaining the similarities and differences between XProc and Apache Cocoon

—Posted by Rogier on 24 Apr 2006 @ 07:01 UTC #

Hi Norm

Great news! Is this first implementation available? I'm just curious about it :-)



—Posted by Florent Georges on 28 Apr 2006 @ 08:27 UTC #