|
Steven Noels explains the difference between <map:aggregate> and the cinclude transformer in Cocoon when composing aggregated XML documents, like HTML pages for portals. Subtle differences which I didn't realize so far: great stuff, thanks Steven!
The basic difference is in the way the generation of the final aggregated page happens. The <map:aggregate> is a sitemap construct, which essentially places the included XML content from the different source inside some XML elements. Here is an excerpt from Cocoon's samples sitemap entry:
<map:match pattern="news/aggregate.xml">
<map:aggregate element="page" ns="http://foo.bar.com/myspace">
<map:part element="news" ns="http://foo.bar.com/slashdot" src="cocoon:/news/slashdot.xml"/>
<map:part element="news" ns="http://foo.bar.com/moreover" src="cocoon:/news/moreover.xml"/>
<map:part element="news" ns="http://foo.bar.com/xmlhack" src="cocoon:/news/xmlhack.xml"/>
</map:aggregate>
<map:transform src="stylesheets/news/news.xsl"/>
<map:serialize/>
</map:match>
With <map:aggregate> you need to apply an additional transformation step to translate the resulting XML document to (X)HTML.
In contrast cinclude is a transformer which processes a template file with placeholders for the content to be inserted instead. Here's a simple file which could be fed to the cinclude transformer (assume the file is named aggregate.xml):
<page>
<title>A Simple Page using Content Aggregation</title>
<content>
<para>
<cinclude:include src="cocoon:/news/slashdot.xml" element="slashdot" ns="http://foo.bar.com/slashdot"/>
</para>
<para>
<cinclude:include src="cocoon:/news/moreover.xml" element="moreover" ns="http://foo.bar.com/moreover"/>
</para>
<para>
<cinclude:include src="cocoon:/news/xmlhack.xml" element="isyndicate" ns="http://foo.bar.com/xmlhack"/>
</para>
</content>
</page>
The equivalent sitemap entry would look like (adapted from Cocoon's samples sitemap):
<map:match pattern="news/aggregate">
<map:generate src="file/aggregate.xml"/>
<map:transform type="cinclude"/>
<map:transform src="stylesheets/news/news.xsl"/>
<map:serialize/>
</map:match>
In the case of the cinclude transformer, we can avoid the last transformation by modifying our aggregate.xml to contain only the necessary (X)HTML html, body, table and/or div elements to give structure to the aggregated XML/XHTML documents.
|