You are viewing a plain text version of this content. The canonical link for it is here.
Posted to docs@cocoon.apache.org by do...@cocoon.apache.org on 2004/11/25 21:43:07 UTC
[Cocoon Wiki] Updated: MetaStylesheets
Date: 2004-11-25T12:43:07
Editor: UpayaVira <uv...@upaya.co.uk>
Wiki: Cocoon Wiki
Page: MetaStylesheets
URL: http://wiki.apache.org/cocoon/MetaStylesheets
an article that actually shows you how to do it!
Change Log:
------------------------------------------------------------------------------
@@ -6,6 +6,8 @@
There are several examples of this:
+
+ * For details on creating XSLT stylesheets that create other stylesheets, see [http://www.xml.com/pub/a/2003/11/05/xslt.html XML Reflection]
* Schematron -- an XML validation language implemented as XSLT, see [http://www.ldodds.com/papers/schematron_xsltuk.html Schematron - Validating XML using XSLT] for a tutorial
* Web template languages -- see the XML.com article [http://www.xml.com/pub/a/2002/03/27/templatexslt.html Template Languages in XSLT] for some relevant background
@@ -22,22 +24,22 @@
=== How It's Done ===
-{{{
-<map:pipeline>
-<map:match pattern="my.html">
- <map:generate src="my.xml"/>
- <map:transform type="xalan" src="cocoon:/implementation-stylesheet.xsl"/>
- <map:serialize/>
-</map:match>
-</map:pipeline>
-
-<map:pipeline>
-<map:match pattern="implementation-stylesheet.xsl">
- <map:generate src="process-description.xml"/>
- <map:transform src="meta-stylesheet.xsl"/>
- <map:serialize type="xml"/>
-</map:match>
-</map:pipeline>
+{{{
+<map:pipeline>
+<map:match pattern="my.html">
+ <map:generate src="my.xml"/>
+ <map:transform type="xalan" src="cocoon:/implementation-stylesheet.xsl"/>
+ <map:serialize/>
+</map:match>
+</map:pipeline>
+
+<map:pipeline>
+<map:match pattern="implementation-stylesheet.xsl">
+ <map:generate src="process-description.xml"/>
+ <map:transform src="meta-stylesheet.xsl"/>
+ <map:serialize type="xml"/>
+</map:match>
+</map:pipeline>
}}}
Here we have two pipelines, each of which perform one steps outline above. The first pipeline does the actual work: it transforms our XML into HTML results using the implementation stylesheet.
@@ -57,25 +59,25 @@
=== Note ===
Always be aware of the fact that such a pipeline is not cached. E.g., if you have a time-consuming generator (like HTML which uses JTidy), split the pipeline into two separate ones. Instead of
-{{{
-<map:match pattern="*.html">
- <map:generate src="{1}.html"/>
- <map:transform src="cocoon:/{1}.xsl"/>
- <map:serialize/>
-</map:match>
+{{{
+<map:match pattern="*.html">
+ <map:generate src="{1}.html"/>
+ <map:transform src="cocoon:/{1}.xsl"/>
+ <map:serialize/>
+</map:match>
}}}
use
-{{{
-<map:match pattern="*.html">
- <map:generate src="cocoon:/{1}.xml"/>
- <map:transform src="cocoon:/{1}.xsl"/>
- <map:serialize/>
-</map:match>
-
-<map:match pattern="*.xml">
- <map:generate src="{1}.html"/>
- <map:serialize type="xml"/>
-</map:match>
+{{{
+<map:match pattern="*.html">
+ <map:generate src="cocoon:/{1}.xml"/>
+ <map:transform src="cocoon:/{1}.xsl"/>
+ <map:serialize/>
+</map:match>
+
+<map:match pattern="*.xml">
+ <map:generate src="{1}.html"/>
+ <map:serialize type="xml"/>
+</map:match>
}}}
In the latter case, the "*.xml" pipeline is cached and the overall performance is much better.