The logo is a pig framed between two angle brackets.

XProc’s Basic Syntax

Usually a “Hello World!” example is used to illustrate a language’s basic syntax. We continue this tradition in the following pipeline, which doesn’t do anything special but just passes its input to the output:

<?xml version="1.0" encoding="UTF-8"?>
<p:declare-step xmlns:p="http://www.w3.org/ns/xproc"
  version="3.0">
  
  <p:input port="source">
    <p:inline>
      <doc>Hello XPorc!</doc>
    </p:inline>
  </p:input>
  
  <p:output port="result"/>
  
  <p:identity/>
  
</p:declare-step>

Output:

<?xml version="1.0" encoding="UTF-8"?>
<doc>Hello XPorc!</doc>

The root element of an XProc pipeline is p:declare-step. The element is bound to XProc’s default namespace http://www.w3.org/ns/xproc. The use of the namespace prefix p is not mandatory, but there is no reason to deviate from this practice unless you want to make your code less readable. The version attribute indicates the XProc version being used.

The prolog consists of two port declarations. You can name the ports whatever you want but the main input and output ports of a pipeline are named source and result by convention. The source port contains a small XML document which is declared within the port with p:inline.

This pipeline includes one step named p:identity, which takes its input and passes an exact copy to its output. The step has one input port named source and one output port entitled result. Since these are the primary ports of this step, they are implicitely connected to the pipeline’s input and output ports and we don’t need to declare them here.

If you are looking for a code editor that makes programming with XProc easier, I recommend the oXygen XML editor. I have developed an XProc 3.0 framework for the oXygen XML Editor that provides code completion and validation support. oXygen also offers native XProc 3.0 support with version 26.1.

Read more…