Dear users,

I've been asked off-list how to create a simple XSLT transformation
in OXF with XPL. Here is how you could go about this, assuming you
want to see the result either as a file on disk or as XML in your Web
browser:

1) Create a new entry in config/controller.xml for your test page, for
   example:

<page id="simple" path-info="/simple" model="oxf:/simple/model.xpl"/>

2) Create a new file, simple/model.xpl, containing your
   transformation, for example:

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

       <p:processor uri="oxf/processor/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 uri="oxf/processor/file-serializer">
           <p:input name="data" href="#result"/>
           <p:input name="config">
               <config>
                   <file>c:/test.xml</file>
               </config>
           </p:input>
       </p:processor>

</p:config>

3) Create your two input files, simple/foo.xml, and simple/foo.xsl.

4) Hit /oxf/simple with your Web browser, and the result will be
   output to c:/test.xml.

If you want to output the result as XML to your Web browser, you can
change simple.xpl as follows:

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

       <p:processor uri="oxf/processor/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 uri="oxf/processor/xml-serializer">
           <p:input name="data" href="#result"/>
           <p:input name="config">
               <config/>
           </p:input>
       </p:processor>

</p:config>

You can even embed your stylesheet and source data in your XPL file, as
follows:

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

<p:processor uri="oxf/processor/xslt">
<p:input name="data">
<list>
<item>1</item>
<item>2</item>
<item>3</item>
</list>
</p:input>
<p:input name="config">
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
<xsl:template match="/">
<xsl:copy-of select="*"/>
</xsl:template>
</xsl:stylesheet>
</p:input>
<p:output name="data" id="result"/>
</p:processor>


       <p:processor uri="oxf/processor/xml-serializer">
           <p:input name="data" href="#result"/>
           <p:input name="config">
               <config/>
           </p:input>
       </p:processor>

</p:config>

This is particularly useful if your transformations and XML documents
are short.

-Erik


_______________________________________________ oxf-users mailing list [EMAIL PROTECTED] http://mail.orbeon.com/mailman/listinfo/oxf-users

Reply via email to