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

How-to guides‎ > ‎XForms Logic‎ > ‎

Run an embedded XSLT transformation from XForms



The problem

You want to run an XSLT transformation on a document you have in an instance directly from XForms, with the XSLT transformation available in another instance.

See also: Run an external XSLT transformation from XForms

The solution

The core of the solution is to use the Saxon extension function saxon:transform() which allows you to run XSLT from XPath. The example linked below uses 3 instances to hold the input document you want to transform, the XSLT stylesheet, and the result of the transformation:

<xforms:instance id="input">      ... </xforms:instance>
<xforms:instance id="stylesheet"> ... </xforms:instance>
<xforms:instance id="output">     ... </xforms:instance>

You run the transformation with the following action:

<xforms:insert nodeset="instance('output')" origin="saxon:transform(
    saxon:compile-stylesheet(instance('stylesheet')/root()),
    saxon:parse(saxon:serialize(instance('input'), 'xml')))"/>

In the future, Orbeon Forms can make this use of saxon:transform() more efficient by allowing the compiled stylesheet to be cached (so it doesn't need to be compiled every time the transformation runs), and by removing the need to use the saxon:parse() and saxon:serialize() on the input document.

Run it and get the source