Debugging Orbeon XPL programs

Orbeon XPL is way of describing processing flows using XML syntax. Since there is no debugger the debugging mostly happens by putting something in and looking at what comes out.

You can always get the output from pipeline by using the “debug” attribute with processors, but reading the information from log files can be cumbersome if you have many steps. I’ve found it easier to put the output from certain processors to separate files on disk. I then keep the files open in editor that reload changes automatically. This makes it quick and easy to see how the changes I have made to XPL have affected the results.

To do this I have created a simple processor that writes the file to certain location.

write-to-file.xpl:

<p:config xmlns:p="http://www.orbeon.com/oxf/pipeline"
	  xmlns:oxf="http://www.orbeon.com/oxf/processors">
	<p:param type="input" name="data" />
	<p:param type="input" name="setup" />

	<p:processor name="oxf:xml-converter">
	    <p:input name="config">
	        <config>
	            <encoding>utf-8</encoding>
	        </config>
	    </p:input>
	    <p:input name="data" href="#data"/>
	    <p:output name="data" id="converted"/>
	</p:processor>
	<!-- Comment out the following processor to disable debugging -->
	<p:processor name="oxf:file-serializer">
	    <p:input name="config" href="#setup" />
	    <p:input name="data" href="#converted"/>
	</p:processor> 
 </p:config>

That processor is used from my main XPL by connecting it to interesting outputs (below the #xforms).

<p:processor name="oxf:pipeline">
	<p:input name="config" href="write-to-file.xpl"/>
	<p:input name="data" href="#xforms" />
	<p:input name="setup">
		<config>
			<directory>c:/temp</directory>
			<file>xforms.xml</file>
		</config>
	</p:input>
</p:processor>