cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alexander Schatten <ala...@gmx.at>
Subject Re: Table of contents
Date Fri, 20 Jun 2003 11:11:04 GMT
Albert Shih wrote:

>Hi all
>
>(sorry for my bad english)
>
>I'm very newbie in cocoon. But before I very start in this nice framework. I want
>need to known something. After I read the book (Cocoon developper's handbook Moscar &
Aston) 
>I think it's possible, but I need a confirmation.
>
>  
>
alright: I send you my solution, maybe it is helpful.

(1) first of all the sitemap:

                    <map:match pattern="articles/browse.html" 
id="artbrowse">
                        <map:generate src="user/xml/articles" 
type="directory"/>
                        <!-- generate cincludes from directory listing -->
                        <map:transform 
src="style/articles/article-cincludes.xsl">
                            <map:parameter name="article-dir" 
value="user/xml/articles" />
                        </map:transform>
                        <!-- all articles are merged -->
                        <map:transform type="cinclude"/>
                        <!-- and overview is printed as table -->
                        <map:transform 
src="style/articles/article-list.xsl">
                            <map:parameter name="use-request-parameters" 
value="true"/>
                        </map:transform>
                        <map:serialize type="html"/>
                    </map:match>

in the /user/xml/articles directory the XML files to be aggregated can 
be found.

(2) "article-cincludes.xsl" this file is responsible for the aggregation 
of the documents:

<?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:ci="http://apache.org/cocoon/include/1.0"
 >
    <xsl:param name="article-dir"/>
    <xsl:template match="dir:directory">
            <articles>
            <xsl:for-each select="dir:file">
                <file name="{@name}">
                    <ci:include src="{$article-dir}/{@name}" 
element="included" />
                </file>
            </xsl:for-each>
        </articles>
    </xsl:template>
</xsl:stylesheet>


(3) and then there is finally the "article-list.xsl" I will not post it 
here because it is rather long and not really interesting for you as it 
is very depending of the purpose of your documents.

however, if you modify the sitemap entry above to this:


                    <map:match pattern="articles/browse.html" 
id="artbrowse">
                        <map:generate src="user/xml/articles" 
type="directory"/>
                        <!-- generate cincludes from directory listing -->
                        <map:transform 
src="style/articles/article-cincludes.xsl">
                            <map:parameter name="article-dir" 
value="user/xml/articles" />
                        </map:transform>
                        <!-- all articles are merged -->
                        <map:transform type="cinclude"/>
                        <map:serialize type="xml"/>
                    </map:match>


open the page in the browser, then view the page source; then you see 
the generated aggregated XML document. It should be of no difficulty for 
you to write an appropriate XSL file for this result.


hope this helps.


Alex


---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
For additional commands, e-mail: cocoon-users-help@xml.apache.org


Mime
View raw message