CInclude Transformer
This transformer triggers for the element include in the
namespace "http://apache.org/cocoon/include/1.0".
The src attribute contains the url which points to
an xml resource which is included instead of the element.
With the attributes element , ns and
prefix it is possible to specify an element
which surrounds the included content.
-
Name : cinclude
-
Class: org.apache.cocoon.transformation.CIncludeTransformer
-
Cacheable: no.
-
Name : cinclude
-
Class: org.apache.cocoon.transformation.CachingCIncludeTransformer
-
Cacheable: yes.
There are two versions of CIncludeTransformer available:
-
A non caching version
org.apache.cocoon.transformation.CIncludeTransformer
-
A caching version
org.apache.cocoon.transformation.CachingCIncludeTransformer
A simple example might help to use the CIncludeTransfomer effectivly:
Add the CIncludeTransformer to the components in your sitemap.xmap
 |  |  |
 |
...
<map:components>
...
<map:transformers default="xslt">
...
<map:transformer name="cinclude"
src="org.apache.cocoon.transformation.CIncludeTransformer"/>
...
|  |
 |  |  |
Next define in your pipeline to use the CIncludeTransformer
 |  |  |
 |
<map:match pattern="cinc/simple-cinc">
<map:generate src="cinc/simple-cinc.xml"/>
<map:transform type="cinclude"/>
<map:transform src="stylesheets/page/simple-page2html.xsl"/>
<map:serialize/>
</map:match>
|  |
 |  |  |
In this example pipeline it assumed that simple-cinc.xml contains
the include element. Beside defining the include element
it defines the namespache URI "http://apache.org/cocoon/include/1.0".
This helps the CIncludeTransformer to find the tag to get replaced by
the xml content referenced via the src attribute.
The simple-cinc.xml may look like this:
 |  |  |
 |
<?xml version="1.0" encoding="UTF-8"?>
<page
xmlns:cinclude="http://apache.org/cocoon/include/1.0">
<title>Hello</title>
<content>
<para>This is my first Cocoon page!</para>
<cinclude:include src="include.xml" element="included"/>
</content>
</page>
|  |
 |  |  |
Next you should define the include.xml file which is included.
A simple include.xml might look like this:
 |  |  |
 |
<?xml version="1.0"?>
<p>
I am <strong>included</strong> by CIncludeTransformer.
I come from "include.xml".
</p>
|  |
 |  |  |
Now finally we have everything put together the xml content after the
CIncludeTransformer processing will look like this:
 |  |  |
 |
<?xml version="1.0" encoding="UTF-8"?>
<page
xmlns:cinclude="http://apache.org/cocoon/include/1.0">
<title>Hello</title>
<content>
<para>This is my first Cocoon page!</para>
<included>
<p>
I am <strong>included</strong> by CIncludeTransformer.
I come from "include.xml".
</p>
</included>
</content>
</page>
|  |
 |  |  |
|