Comments? Feedback?

This wiki does not yet support public comments (a limitation of Google Sites), so we encourage you to post your comments either:

On Twitter by responding to @orbeon.

On our community mailing list: subscribe sending an email to ops-users-subscribe@ow2.org (content of subject/body doesn't matter), you'll get a response with the email to use to send your message to the community mailing list.

Recent site activity

Implement a transformation service

The problem

Implement a simple transformation service which:
  • Takes XML data as input.
  • Transforms the XML data using XSLT
  • Returns the result as XML

The solution

Create a page flow entry, e.g.:

<page path-info="/my-app/transform" view="my-transform.xsl"/>

You can place this in the top-level RESOURCES/page-flow.xml or better under your own file under RESOURCES/my-app/page-flow.xml:

<config xmlns="http://www.orbeon.com/oxf/controller">
    <page path-info="/my-app/transform" view="my-transform.xsl"/>
    <epilogue url="oxf:/config/epilogue.xpl"/>
</config>

Where:
  • RESOURCES points to your resources directory, typically in your WAR file under WEB-INF/resources.
  • my-app represents a name for of your application
Then write your XSLT transformation under RESOURCES/my-app/my-transform.xsl. Here is the standard identify transform which returns what it was passed:

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:template match="@*|node()" priority="-100">
        <xsl:copy>
            <xsl:apply-templates select="@*|node()"/>
        </xsl:copy>
    </xsl:template>
</xsl:stylesheet>

You can use that simple transform to test your service.

NOTE: If you are using separate deployment, the service and XSLT transformation must be present in the Orbeon WAR file, instead of within your application.

Bypassing the standard Orbeon Forms epilogue

The result of the transform passes through the standard Orbeon Forms epilogue. This means in particular that if you return XHTML, the result will be processed by the epilogue and return HTML, and you might not want that.

Instead, you can write the page flow entry as follows:

<page path-info="/my-app/transform" model="my-transform.xpl"/>

This calls an XPL file under RESOURCES/my-app/my-transform.xpl which calls the XSLT transformation and serializes the result:

<p:config xmlns:p="http://www.orbeon.com/oxf/pipeline"
          xmlns:oxf="http://www.orbeon.com/oxf/processors">

    <p:param type="input" name="instance"/>

    <p:processor name="oxf:xslt">
        <p:input name="data" href="#instance"/>
        <p:input name="config" href="my-transform.xsl"/>
        <p:output name="data" id="transformed"/>
    </p:processor>

    <p:processor name="oxf:xml-converter">
        <p:input name="config">
            <config><indent>false</indent></config>
        </p:input>
        <p:input name="data" href="#transformed"/>
        <p:output name="data" id="converted"/>
    </p:processor>

    <p:processor name="oxf:http-serializer">
        <p:input name="config">
            <config>
                <cache-control><use-local-cache>false</use-local-cache></cache-control>
            </config>
        </p:input>
        <p:input name="data" href="#converted"/>
    </p:processor>

</p:config>