forrest-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Crossley <>
Subject Re: howto-custom-html-source
Date Sun, 18 Dec 2005 01:53:51 GMT
David Crossley wrote:
> Paul Bolger wrote:
> > I've been trying to get this to work, and I'm not sure what's going
> > wrong. I'll explain what I'd like to be able to do: I'd like to point
> > at a directory, and it's subdirectories, processing all html files so
> > that all content outside a #content div is stripped.
> Ah, that comment indicates a basic misunderstanding
> about how Cocoon operates. It doesn't actually process
> directories [1]. Rather it handles requests. Depending
> on the components of the URL, the sitemap will respond
> by matching certain patterns.
> You need a project sitemap (or plugin if it is common
> functionality) to intercept the specific matches that
> you want to transform. Any matches that remain are handled
> by the guts of forrest.
> Some of our documentation explains how to handle specific
> matches. As usual our docs need attention. This doc
> is close, but you need to wade through the example that
> it points to, because only part of that is relevant.
> Basically you need a project sitemap.xmap like this
> where "this-tree" is the directory tree to which
> you want to apply special processing ...
> <map:match pattern="**/this-tree/**.xml">
>  <map:generate src="{project:content.xdocs}{1}/this-tree/{2}.html" />
>  <map:transform src="{project:resources.stylesheets}/myStripContent-to-document.xsl"
>  <map:serialize type="xml"/>
> </map:match>

Of course, that should be <map:serialize type="xml-document"/>

Also your "myStripContent" transformer could probably
just remove the bits that you don't want and then follow
it with the forrest html transformer. So ...

<map:match pattern="**/this-tree/**.xml">
 <map:generate src="{project:content.xdocs}{1}/this-tree/{2}.html" />
 <map:transform src="{project:resources.stylesheets}/myStripContent-to-html.xsl" />
 <map:transform src="{forrest:stylesheets}/html2document.xsl"/>
 <map:serialize type="xml-document"/>

> (Caveat: Be careful with those directory separators
> in the match and generate components: The ** will match
> a slash. I just added the above for readability.)
> In other words, presume that the request is
> localhost:8888/some-dir/this-tree/foo/bar.html
> then your sitemap would fire and it would generate
> xml content from xdocs/some-dir/this-tree/foo/bar.html
> and apply your transformer to produce the forrest
> internal document structure.
>                   --oOo--
> [1] Preparing a directory listing, say for a table
> of contents page is another matter. For that you
> would use more complex Cocoon sitemap operations.
> See DirectoryGenerator which traverses the directory
> tree generates an xml fragment. Apply a Transformer
> to that to turn it into forrest internal xml format.
> You would need to follow Cocoon sitemap docs. Start at
> Understand sitemaps and then see:
> We need to add an example to our seed-sample site.
> > This How-To is
> > very detailed and I've learnt a lot from it, but it'd be good to have
> > 
> > a. and example file of sitemap.xmap with the extra element included (I
> > can't find the place that it's supposed to go...)
> > 
> > and
> > 
> >  b. an example xsl file.
> The stylesheet to strip everything except "div class=content"
> is a simple XSLT operation. Not apporpriate for this list.
> The "XSL FAQ" is a fantanstic resource
> and get Micahel Kay's book.
> -David

View raw message