Proposal: Enabling XInclude to implement page fragments

Note: This is just an idea. It has been briefly discussed on the lenya-dev mailing list and was found to be one of several possible ways to achive the goal. It is also work in progress in that it is not yet compatible with the authoring / live mechanism in Lenya.

Most modern websites have a complex layout which in many cases is not just navigation and content, but the content is usually devided into main content and additional elements. (FixMe: Find a good example!)

(Take this further ...)

Adding the XInclude Transformer to the lenybody-pipeline

Add the XInclude Transformer into the appropriate pipeline in publication-sitemap.xmap:

    <!-- This is the pipeline that builds the page. It aggregates all
    the navigational elements (breadcrumb, tabs, menu) with the actual
    content of the document. -->
      <!-- /lenyabody-{rendertype}/{publication-id}/{area}/{doctype}/{url} -->
      <map:match pattern="lenyabody-*/*/*/*/**">
        <map:aggregate element="cmsbody">
          <map:part src="cocoon://navigation/{2}/{3}/breadcrumb/{5}.xml"/>
          <map:part src="cocoon://navigation/{2}/{3}/tabs/{5}.xml"/>
          <map:part src="cocoon://navigation/{2}/{3}/menu/{5}.xml"/>
          <map:part src="cocoon:/lenya-document-{1}/{3}/{4}/{page-envelope:document-path}"/>

        <!-- start inserting here -->
        <map:transform type="xinclude" />
        <!-- end inserting here -->

        <map:transform src="xslt/page2xhtml.xsl">
          <map:parameter name="root" value="{page-envelope:context-prefix}/{2}/{3}"/>
          <map:parameter name="url" value="{5}"/>
        <map:serialize type="xml"/>

Note: It might be an alternative to have a custom "withincludes" doctype and to move the XInclude transformer into the local pipeline for only that doctype. This might save passing the XInclude transformer for pages in which there is nothing included at all. It might also be worth looking at the CInclude transformer instead.

Using xi:include in a document

Make sure you have defined the xi namespace in your document:



<xsl:stylesheet version="1.0"

  <xsl:param name="mount" />

  <xsl:template match="xi:include">
      <xsl:attribute name="href"><xsl:value-of select="$mount"/>/<xsl:value-of select="@href"/></xsl:attribute>

<xsl:template match="@*|node()">
    <xsl:apply-templates select="@*|node()"/>


See also:

  • No labels