Differences between revisions 8 and 9
Revision 8 as of 2003-10-02 09:23:48
Size: 2546
Editor: AndreasHartmann
Comment:
Revision 9 as of 2003-10-02 09:27:09
Size: 2548
Editor: AndreasHartmann
Comment:
Deletions are marked like this. Additions are marked like this.
Line 60: Line 60:
      <map:generate src="xslt/{1}/document2page.xsl"/>       <map:transform src="xslt/{1}/document2page.xsl"/>
Line 63: Line 63:
      <map:generate src="xslt/document2page.xml"/>       <map:transform src="xslt/document2page.xml"/>

While working with Cocoon, I have come upon some useful patterns for use in the sitemap. Feel free to change/tweak these as needed. -- TonyCollen

Match/Generate/Transform/Serialize

  • Most basic usage of sitemap components
  • Usually generating from static XML files
  • Good candidate for pre-generation using CLI

<map:match pattern="*.html">
    <map:generate src="documents/{1}.xml"/>
    <map:transform src="stylesheets/docbook2html.xsl"/>
    <map:serialize type="xhtml"/>
</map:match>

Recursive Match/Generate/Transform/Serialize

  • Useful for automated M/G/T/S
  • Allows people to create subdirectories and Cocoon will automatically serve them
  • Will match foo/blah.html, foo/bar/blah.html, foo/bar/baz/blah.html, etc.
  • Centralized XSLT for unified document structure

<map:match pattern="**/*.html">
    <map:generate src="documents/{1}/{2}.xml"/>
    <map:transform src="stylesheets/docbook2site.xsl"/>
    <map:serialize type="html"/>
</map:match>

Redirect "empty" requests to a known URI

  • Similar to DirectoryIndex directive in httpd.conf

<map:match pattern="">
    <map:redirect-to uri="welcome"/>
</map:match>

Sub-Sitemap Automounting

  • Used in default [Sitemap]

  • Minimizes maintenance of parent sitemaps
  • Extremely useful

<map:match pattern="*/**">
    <map:mount check-reload="yes" src="{1}/" uri-prefix="{1}"/>
</map:match>   

Fallback Transformation -- AndreasHartmann

  • typical examply of resource-exists selector usage
  • allows dynamic selection of a general or specific stylesheet
  • easily reusable when implemented as a resource
  • allows "inheritance" of stylesheet sets - typically the specific stylesheet imports the general one
  • also useful for XML source documents

<map:match pattern="**/*.html"
  <map:generate src="content/{1}/{2}.xml"/>
  <map:select type="resource-exists">
    <map:when test="xslt/{1}/document2page.xsl">
      <map:transform src="xslt/{1}/document2page.xsl"/>
    </map:when>
    <map:otherwise>
      <map:transform src="xslt/document2page.xml"/>
    </map:otherwise>
  </map:select>
  <map:serialize/>
</map:match>


Other Pattern Pages:


Readers' comments

Wonderful. Thank you. I needed this! --- [:Gabridome]

SitemapPatterns (last edited 2009-09-20 23:40:04 by localhost)