|
Page Edited :
SLINGxSITE :
XSLT Processing Pipeline
XSLT Processing Pipeline has been edited by Juanjo Vazquez (Apr 07, 2009). Content:In the Apache Sling Scripting W3C XML Processing Support bundle, Juanjo Vázquez has implemented XSLT processing support for Sling as another new scripting engine, based on the Cocoon 3 pipeline engine IntroAn XML pipeline specifies a sequence of operations to be performed on zero or more XML documents. There are a number of advantages to using pipelines above all in terms of separation of concerns. On the other hand, we talk about XSLT processing if the operations in a pipeline are performed executing or applying XSLT stylesheets. XSLT processing support is implemented in Sling as an scripting engine bundle named Apache Sling Scripting W3C XML Processing Support. This bundle is based on the Cocoon 3 pipeline engine For the time being, XProc is partially implemented and it´s not clear that Sling must support all W3C recomendation yet. This could depend of concrete user requirements or use cases. The source code is found in the contrib/scripting/xproc How to InstallInstall the org.apache.sling.scripting.xproc bundle in order to work with XProc. You can achieve this either building it from contrib/scripting/xproc folder in the Sling trunk or by downloading it from the Apache Snapshot repository here: org.apache.sling.scripting.xproc-2.0.0-incubator-20090403.114403-1.jar To deploy the bundle go to the bundles page of Apache Felix Web Console (http://localhost:8888/system/console/bundles In order to check whether XProc scripting engine has been installed, go to the Script Engines page of the Apache Felix Web Console and see the entry for XProc there: Apache Sling Scripting W3C XML Processing Support, 2.0.0-incubator-SNAPSHOT Language XMLProc, 1.0 Extensions xpl MIME Types application/xml Names XProc, xml processing, xml pipeline processor
SamplesLet´s see some samples in order to understand the processing behaviour. 1. Create some content $ curl -F sling:resourceType=xproc -F title="some title" -F text="And some text" http://admin:ad...@localhost:8888/foo 2. Use WebDAV or curl to create a pipeline script at /apps/xproc/xproc.xpl : <?xml version="1.0" encoding="UTF-8"?> <p:pipeline xmlns:p="http://www.w3.org/ns/xproc"> <p:xslt> <p:input port="stylesheet"> <p:document href="" class="code-quote">"/apps/xproc/one.xsl"/> </p:input> </p:xslt> <p:xslt> <p:input port="stylesheet"> <p:document href="" class="code-quote">"/apps/xproc/two.xsl"/> </p:input> </p:xslt> </p:pipeline> 3. Store the XSLT transforms in the repository: /apps/xproc/one.xsl <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="/"> <one> <xsl:copy-of select="."/> </one> </xsl:template> </xsl:stylesheet> /apps/xproc/two.xsl <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="/"> <two> <xsl:copy-of select="."/> </two> </xsl:template> </xsl:stylesheet> 4. Request foo.html to execute the pipeline: $ curl http://admin:ad...@localhost:8888/foo.html
<?xml version="1.0" encoding="UTF-8"?>
<two>
<one>
<foo ...sling:resourceType="xproc" text="And some text" title="some title"/>
</one>
</two>
In this case, the node´s document view has been the pipeline´s source. 5. Now, store an static XML in the repository: /foo.xml <?xml version="1.0" encoding="UTF-8"?> <foo> <content> foo: static content </content> </foo> 6. Again, request foo.html to execute the pipeline: $ curl http://admin:ad...@localhost:8888/foo.html
<?xml version="1.0" encoding="UTF-8"?>
<two>
<one>
<foo>
<content>
foo: static content
</content>
</foo>
</one>
</two>
This time the pipeline´s source has been an static XML file. 7. Store an script in the repository: /apps/xproc/xproc.xml.esp <?xml version="1.0" encoding="UTF-8"?> <foo> <content> foo: dynamic content </content> </foo> 8. Delete previous static xml file (/foo.xml). 9. Request foo.html to execute the pipeline: $ curl http://admin:ad...@localhost:8888/foo.html
<?xml version="1.0" encoding="UTF-8"?>
<two>
<one>
<foo>
<content>
foo: dynamic content
</content>
</foo>
</one>
</two>
This time the pipeline´s source has been a dinamically generated XML. References |
Unsubscribe or edit your notifications preferences
