Using XIncludes
Working with XIncludes is a little more cumbersome than using the XSLTdocument function, but it allows for the same functionality. Note that Firefox does not support the document function, making XIncludes a necessity for most Xopus 4 implementations.
We've created an example (download) to explain how to work with XIncludes. It elaborates on the Simple Demo. When you take a look at the Simple Demo files, you can find a file called start.html. This file contains the island which contains the pipeline, on which the views in Xopus are defined. A standard view is defined as such:
<x:view name="WYSIWYG View"> <x:transform xsl="stylesheet.xsl"/> </x:view>
This view transforms the document once, using the specified stylesheet. When using XIncludes you need to first prepare the XML with another transformation, and then use the Xopus specific resolveXIncludes element within the view, as a transformation to resolve the includes. The view definition then looks like this:
<x:view name="WYSIWYG View"> <x:transform xsl="prepareXIncludes.xsl"/> <x:resolveXIncludes/> <x:transform xsl="stylesheet.xsl"/> </x:view>
The prepareXIncludes.xsl in the example does no more than copy every element, and write an <xi:include> element for every header encountered in the document.
<xsl:template match="@*|node()">
<xsl:copy><xsl:apply-templates select="@*|node()"/></xsl:copy>
</xsl:template>
<!-- Write an xi:include element following every header. -->
<xsl:template match="header">
<header><xsl:apply-templates select="@*|node()" /></header>
<xi:include href="include.xml"/>
</xsl:template>
The <resolveXIncludes> transformation copies the XML from include.xml to the specified place. The stylesheet.xsl stylesheet then finds the included content together with the original content and can transform it as if it was part of the same document.
In the example you will find four views defined on the pipeline:
- The first view is the "WYSIWYG view" with resolved XIncludes
- The second view is the "XML view" as it is. (treeTransform)
- The third view show shows the
<xi:include>elements, being defined as a view with merely theprepareXIncludes.xsland a<treeTransform>(for 'XML view') - The fourth view shows the XML after the XIncludes have been resolved.
This is a very simple example of working with XIncludes, but it shows you how and where to begin.
- Documentation
- › How To
- › Using XIncludes