Introduction
You can use Orbeon Forms to build standalone command-line applications running pipelines. Use
cases include: creating a hardcopy of a web site, importing or exporting XML data to
and from a relational database, testing pipelines, automating repetitive operations
on XML files (selection, transformation, aggregation, etc.). Orbeon Forms becomes your "XML
toolbox".
Command line interface
Orbeon Forms ships with a command line interface (CLI). The easiest way to run it is to use
the executable orbeon-cli.jar file and pass it a pipeline file:
java -jar orbeon-cli.jar pipeline.xpl
In this case, a pipeline can use relative URLs, or, if using absolute URLs, can use
either the file: protocol to access files or, equivalently, the
oxf: protocol.
Sometimes, it is better to group files under a resources sandbox addressed by
the oxf: protocol. This is the standard way of accessing resources
(files) within web applications, but it is also useful with command-line
applications. In such cases, specify a resource manager root directory with the
-r option, for example:
java -jar orbeon-cli.jar -r . oxf:/pipeline.xpl
java -jar orbeon-cli.jar -r C:/my-example oxf:/pipeline.xpl
When specifying a resource manager root directory, it is mandatory to use a protocol
and an absolute path within the sandbox, as shown above.
[Since 2012-05-29] Pipeline inputs and outputs can be specified as URLs using --input (aka -i) and --output (aka -o) options:
java -jar orbeon-cli.jar -i "data1=oxf:/data1.xml" -i "data2=oxf:/data2.xml" -o "data=oxf:/data.xml" -r C:/my-example oxf:/pipeline.xpl
NOTE: Orbeon Forms's jar file (orbeon-cli.jar) is executable via the java
-jar mechanism. However, it depends on a number of libraries that must be
in the 'lib' directory beneath the directory containing
orbeon-cli.jar. It is recommended to expand the WAR file, and refer
to the orbeon-cli.jar file under the WAR file's WEB-INF
directory.
Examples
Orbeon Forms comes with simple examples of command-line applications under the
src/examples/cli directory. To run those examples, from a command
prompt, enter either one of the subdirectories and run the java command
following the explanations above, for example, from the simple
directory:
java -jar /path/to/orbeon-war/WEB-INF/orbeon-cli.jar stdout.xpl
or, from the transform directory:
java -jar /path/to/orbeon-war/WEB-INF/orbeon-cli.jar transform.xpl
Notice that those two example pipelines use serializers, for example:
<p:config xmlns:p="http://www.orbeon.com/oxf/pipeline" xmlns:oxf="http://www.orbeon.com/oxf/processors">
<p:processor name="oxf:xslt">
<p:input name="data" href="foo.xml"/>
<p:input name="config" href="foo.xsl"/>
<p:output name="data" id="result"/>
</p:processor>
<p:processor name="oxf:xml-serializer">
<p:input name="config">
<config/>
</p:input>
<p:input name="data" href="#result"/>
</p:processor>
</p:config>
It is important to note that, when running from within a servlet or portlet
environment, serializers send their data to the web client, such as a web browser.
When running from a command-line environment, serializers output data to the
standard output.