[prev in list] [next in list] [prev in thread] [next in thread]
List: xml-cocoon-dev
Subject: Re: [c2 proposal] map:aggregate
From: Michael Hartle <mhartle () hartle-klug ! com>
Date: 2001-07-28 22:17:57
[Download RAW message or body]
Vadim Gritsenko wrote:
>>But - hopefully - we have other solution: X/Cinclude mechanism
>>which is perfectly suitable in this case:
>>
>><map:match pattern="documents_pdf/documentation.pdf">
>> <map:generate type="directory" src="docs/xdocs"/>
>> <map:transform src="filter-xml-files.xsl"/>
>> <map:transform src="xml-file-to-xinclude.xsl"/>
>> <map:transform type="xinclude"/>
>> <!-- here you have all xdocs in one stream -->
>> ....
>></map:match>
>>
This way worked perfectly for aggregating XML news articles in a
directory subtree, I used
<map:match pattern="collection/news-overview.xml">
<map:generate type="directory" src="repository/news/current">
<map:parameter name="root" value="repository"/>
<map:parameter name="depth" value="2"/>
</map:generate>
<map:transform src="stylesheets/directory-to-xinclude.xsl"/>
<map:transform type="xinclude"/>
<map:serialize type="xml"/>
</map:match>
for generating a collection document containing all current news in the
repository which in turn can then be aggregated to the pages in need for
news. I attached the directory-to-xinclude.xsl I wrote; a drawback of
this solution is that the DirectoryGenerator does not provide caching of
its results.
Best regards,
Michael
["directory-to-xinclude.xsl" (text/xml)]
<?xml version="1.0" encoding="iso-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" \
xmlns:dir="http://apache.org/cocoon/directory/2.0" \
xmlns:xinclude="http://www.w3.org/1999/XML/xinclude" \
xmlns:java="http://xml.apache.org/xslt/java" exclude-result-prefixes="dir java">
<xsl:template match="/">
<news-collection>
<xsl:apply-templates/>
</news-collection>
</xsl:template>
<xsl:template match="dir:directory">
<!-- get the path parameter -->
<xsl:param name="path"/>
<!-- add @name attribute to path parameter -->
<xsl:variable name="addedPath"><xsl:value-of select="$path"/><xsl:value-of \
select="@name"/>/</xsl:variable>
<!-- pass path parameter on to all directory entries -->
<xsl:apply-templates select="dir:directory">
<xsl:with-param name="path"><xsl:value-of select="$addedPath"/></xsl:with-param>
</xsl:apply-templates>
<!-- pass path parameter on to all file entries -->
<xsl:apply-templates select="dir:file">
<xsl:with-param name="path"><xsl:value-of select="$addedPath"/></xsl:with-param>
</xsl:apply-templates>
</xsl:template>
<xsl:template match="dir:file">
<!-- grab "path" parameter -->
<xsl:param name="path"/>
<!-- generate XInclude-statements -->
<xinclude:include parse="xml"><xsl:attribute name="href">file:<xsl:value-of \
select="$path"/><xsl:value-of select="@name"/></xsl:attribute></xinclude:include> \
</xsl:template>
</xsl:stylesheet>
---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org
For additional commands, email: cocoon-dev-help@xml.apache.org
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic