Note that with the document() function, you will run into other problems with the default XSLT transformer. Caching, for one, will be wrong. If you edit a document referenced by the document() function after the stylesheet has been cached, it will not reflect the change (someone correct me if this has been fixed recently).

I think what you want is a stylesheet that transforms the XML into html that has cincludes:

<?xml version="1.0"?>
<!-- DON'T FORGET TO ADD THE RELEVANT NAMESPACES!!! -->
<xsl:stylesheet xmlns="http://www.w3.org/1999/xhtml";
xmlns:cinclude="http://apache.org/cocoon/include/1.0";
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; version='1.0'>
<xsl:output method="html" />
<xsl:template match="/page">
<html lang="en" xml:lang="en">
<xsl:apply-templates/>
</html>
</xsl:template>
<xsl:template match="column">
<p>
<xsl:text>Column</xsl:text>
<br />
<xsl:apply-templates select="module" />
</p>
</xsl:template>
<xsl:template match="module">
<!-- HERE'S THE RELEVANT CHANGED CODE -->
<cinclude:include href="{.}"/>
<xsl:text>Module</xsl:text>
<br />
</xsl:template>
</xsl:stylesheet>

(I hope you don't mind that I changed the first matcher to get rid of the extraneous <xsl:call-template> directive.) At any rate, you then pass this through a cinclude transformer and you are done.

<map:match pattern="foo.html">
<map:generate type="file" src="foo.xml"/>
<map:transform type="xslt" src="foo2htmlandcinclude.xsl"/>
<map:transform type="cinclude"/>
<map:serialize type="html"/>
</map:match>

If you use the caching cinclude transformer, the whole pipeline is cacheable.

- Miles


[EMAIL PROTECTED] wrote:

There are several ways to accomplish content aggregation in Cocoon:

(1) cinclude and xinclude
(2) The XSLT document() function (this seems to match your approach best)
(3) map:aggregate in a sitemap
(4) XSP includes

Each method has advantages/disadvantages relative to flexibility,
performance, etc. Take a look at the portal framework approach
(described in two of the recent Cocoon books). AFAIK they rely on the
cinclude/xinclude and customer transformers.


I'm relatively new to Cocoon and XML and I've been lurking on the list for a
while. I have a problem that's stymied me--perhaps someone could help me? I
want to build an aggregate web page from a set of simple XHTML pages by
extracting the contents of their bodies and aggregating them. I have an XML
file that designates the structure of the page:

<?xml version="1.0"?>
<page>
 <column>
   <module>AboutIntro.xhtml</module>
   <module>AboutQContinued.xhtml</module>
 </column>
 <column>
   <module>AboutQ3.xhtml</module>
 </column>
</page>

I have a stylesheet that I mean to use to aggregate the files, but I haven't
figured out a way to pull in the bodies of the files designated by the XML
above. I've designated below where I've been inserting my test code:

<?xml version="1.0"?>
<xsl:stylesheet
   xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; version='1.0'>
 <xsl:output method="html" />
 <xsl:template match="/">
   <html>
     <xsl:call-template name="page" />
   </html>
 </xsl:template>
 <xsl:template name="page">
   <xsl:apply-templates/>
 </xsl:template>
 <xsl:template match="column">
   <p>
     <xsl:text>Column</xsl:text>
     <br />
     <xsl:apply-templates select="module" />
   </p>
 </xsl:template>
 <xsl:template match="module">
   <xsl:variable name="mod">
     <xsl:value-of select="." />
   </xsl:variable>
<!-- HERE'S THE MISSING CODE -->
   <xsl:text>Module</xsl:text>
   <br />
 </xsl:template>
</xsl:stylesheet>

What's the missing piece?


---------------------------------------------------------------------
Please check that your question  has not already been answered in the
FAQ before posting.     <http://xml.apache.org/cocoon/faq/index.html>

To unsubscribe, e-mail:     <[EMAIL PROTECTED]>
For additional commands, e-mail:   <[EMAIL PROTECTED]>

Reply via email to