CInclude serves the same basic function as XInclude however it is a bit more versatile and is most likely higher performance.

Steps

You must:

  • Add CInclude Namespace to your Page Element definition.
  • Use the cinclude:include element in your page
  • Add the CInclude transformer to your sitemap component definitions
  • Add a CInclude transformer to the pipeline where you used the cinclude:include element

This page defines the first two, the second two steps are shown here: AddCIncludeToMinimalSitemap.

Basic Usage

You must include the CInclude transformer in your basic sitemap. From there you must include this:

<page 
  xmlns:cinclude="http://apache.org/cocoon/include/1.0">

to your Page Element. And this:

<cinclude:include src="include.xml" element="included"/>

whereever you wish the content to be included.

Attributes

  • src – src is required and is a supported URL. These may be relative or direct and may use any cocoon-supported protocol.
  • element – element is optional. The string is the name of a tag which should surround cincluded content.
  • prefix – prefix is optionally used with the element attribute. If prefix is speficied then the element will be *included* with the defined Namespace.
  • ns – ns is optionally used with the element attribute. If ns is specified then the element will be *selected* with the defined Namespace.
  • select – If select is defined then the elements specified by the XLink formatted string will be included. (available in 2.1)

Example of select and element attribute

<cinclude:include
  src="cocoon:/payment_combo.xml" element="payments" select="xformpayments/*">

This would include all children of "xformpayments" but not "xformpayments" itself, instead the root element will be "payments".

Hint: If your select is returning empty but you're sure you're naming the right nodes you may be selecting from the wrong namespace. When selecting nodes from the document's default namespace (as with most xhtml documents) try selecting the node with //*[local-name()='body']/* where body is the node name.

See this example:

AddCIncludeToMinimalSitemap for information on adding a CInclude tranformer to the basic sitemap.

Advanced use

In cocoon-2.0.4, only the basic CInclude transformer described above is available. Development versions (see WhereToGet21Dev) add a new element, <cinclude:includexml>, which is described in the Cocoon documentation.

  • No labels