forrest-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Crossley <>
Subject Re: XSL transformation as part of the page content?
Date Sun, 12 Feb 2006 10:55:38 GMT
Victor Okunev wrote:
> Hi All,
> I have an XSLT style sheet that I use to generate an HTML table. Is it
> possible with Forrest v0.7 to perform the transformation as part of
> the site build and include the results under a document's section?
> Here is a pseudo code that kind of illustrates what I am after:
> index.xml
> <?xml version="1.0" encoding="UTF-8"?>
> <!--
>   Copyright....
> -->
> <!DOCTYPE document PUBLIC "-//APACHE//DTD Documentation V2.0//EN"
> "">
> <document>
>   <header>
>     <title>Page Title</title>
>   </header>
>   <body>
>     <section id="sectionid">
>       <title>Section Title</title>
>       <transform src="data.xml" stylesheet="table.xsl"/>
>     </section>
>   </body>
> </document>

Yes, the Cocoon sitemap enables this and more.
This is a good situation to explain the powers
of teh Cocoon sitemap.

Remove that <transform ... from your source xml
and use the sitemap language to specify the extra
transformer to inject the table into the xml stream.

I attached some example files to a new issue.
You can download and use them. Later we will create
a document from this explanation.

The source file xdocs/one-announce.xml is the main
announcement text. Like yours above, but without
the <transform> pseudo-stuff and with another section.

The data table will be inserted in the top of the
first section.

Here is the data file xdocs/one-data.xml

Here is the relevant section of the sitemap ...

   <map:match pattern="**-announce.xml">
    <map:aggregate element="announce-and-data">
      <map:part src="{project:content.xdocs}{1}-announce.xml"/>
      <map:part src="{project:content.xdocs}{1}-data.xml"/>
    <map:transform src="{project:resources.stylesheets}/add-table.xsl" />
    <map:serialize type="xml-document"/>

Browser request is localhost:8888/one-announce.html

So that generates an aggregated xml stream like this ...
   ... the normal source xdoc, e.g. one-announce.xml

The add-table transformer then strips off the outer wrapper,
copies over the <document> content, deals with the first
<section> element and inserts the table by processing
the <data> element. It serialises as the "xml-document"
which is Forrest's internal format. Forrest takes over
and does the rest of the transforming and rendering.

That is the general idea. There are probably other
ways to do it too.

The new dispatcher will be even more versatile.


View raw message