You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@forrest.apache.org by Phillip Hall <pa...@gmail.com> on 2010/01/06 07:25:22 UTC

Rendering XML transformed from aggregated content

Hello,
I have a problem rendering the Forrest site from two XML files
aggregated in a pipeline from the Sitemap.xmap file.

I am using Forrest 8.0. I created an XSL stylesheet to format the
combined XML files wih "document" root tags as per v-13 DTD.

However this is not displayed with the Forrest skin but as raw HTML.

How can I apply the default Forrest skin to this XML output?

I have searched the Forrest FAQ and the mail Archives without finding
a solution. Please help.

sitemap.xmap insert :

  <map:pipelines>
    <map:pipeline>

      <map:match pattern="**index.html">
        <map:aggregate element="site">
          <map:part src="{properties:content.xdocs}index.xml"/>

          <map:part src="{properties:content.xdocs}index-two.xml"/>

        </map:aggregate>

        <map:transform
src="{properties:resources.stylesheets}/docs-to-document.xsl"/>
        <map:serialize type="xml-document"/>
      </map:match>

    </map:pipeline>


My "docs-to-document.xsl"  transform :

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml"/>
  <xsl:template match="/site">
    <xsl:element name="document">
      <xsl:element name="header">
        <xsl:element name="title">
          <xsl:value-of select="/site/document/header/title"/>
        </xsl:element>
      </xsl:element>
      <xsl:element name="body">
        <xsl:for-each select="//section">
          <xsl:copy-of select="."/>
        </xsl:for-each>
      </xsl:element>
    </xsl:element>
  </xsl:template>
</xsl:stylesheet>

Re: Rendering XML transformed from aggregated content

Posted by David Crossley <cr...@apache.org>.
Phillip Hall wrote:
>
> I have a problem rendering the Forrest site from two XML files
> aggregated in a pipeline from the Sitemap.xmap file.
> 
> I am using Forrest 8.0. I created an XSL stylesheet to format the
> combined XML files wih "document" root tags as per v-13 DTD.
> 
> However this is not displayed with the Forrest skin but as raw HTML.
> 
> How can I apply the default Forrest skin to this XML output?
> 
> I have searched the Forrest FAQ and the mail Archives without finding
> a solution. Please help.
> 
> sitemap.xmap insert :
> 
>   <map:pipelines>
>     <map:pipeline>
> 
>       <map:match pattern="**index.html">

Not 100% sure of my answer, but i reckon that should be
       <map:match pattern="**index.xml">
i.e. the internal request for the content xml.

With the match as you have it, it is intercepting the "output"
html request and finalising (i.e. map:serialize) the output
to xml.

>         <map:aggregate element="site">
>           <map:part src="{properties:content.xdocs}index.xml"/>
>           <map:part src="{properties:content.xdocs}index-two.xml"/>

Also to match sources in sub-directories you will need:
           <map:part src="{properties:content.xdocs}{1}index.xml"/>
etc.

There is a document explaining the "**" and "*" pattern matching
and token usage.

>         </map:aggregate>
> 
>         <map:transform
> src="{properties:resources.stylesheets}/docs-to-document.xsl"/>
>         <map:serialize type="xml-document"/>
>       </map:match>
> 
>     </map:pipeline>
> 
> 
> My "docs-to-document.xsl"  transform :
> 
> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
> <xsl:output method="xml"/>

This output method has no effect in a Cocoon-based app.
The "map:serialize" in the sitemaps does that job.

-David

>   <xsl:template match="/site">
>     <xsl:element name="document">
>       <xsl:element name="header">
>         <xsl:element name="title">
>           <xsl:value-of select="/site/document/header/title"/>
>         </xsl:element>
>       </xsl:element>
>       <xsl:element name="body">
>         <xsl:for-each select="//section">
>           <xsl:copy-of select="."/>
>         </xsl:for-each>
>       </xsl:element>
>     </xsl:element>
>   </xsl:template>
> </xsl:stylesheet>

Re: Rendering XML transformed from aggregated content

Posted by Phillip Hall <pa...@gmail.com>.
On Wed, Jan 6, 2010 at 1:25 AM, Phillip Hall <pa...@gmail.com> wrote:
> Hello,
> I have a problem rendering the Forrest site from two XML files
> aggregated in a pipeline from the Sitemap.xmap file.
>
Thanks David,
I needed to match the request for the XML content instead of the HTML.

That solves my problem.