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/07/09 13:55:54 UTC
[Cocoon Wiki] Updated: SimpleTransformations
Date: 2004-07-09T04:55:54
Editor: DerekLastname <dh...@csir.co.za>
Wiki: Cocoon Wiki
Page: SimpleTransformations
URL: http://wiki.apache.org/cocoon/SimpleTransformations
no comment
Change Log:
------------------------------------------------------------------------------
@@ -17,10 +17,10 @@
configured in the example [:Sitemap]. If you're starting from a MinimalSitemapConfiguration
then here's the declaration that you need:
-{{{
-<map:transformers default="xslt">
- <map:transformer name="xslt" src="org.apache.cocoon.transformation.TraxTransformer"/>
-</map:transformers>
+{{{
+<map:transformers default="xslt">
+ <map:transformer name="xslt" src="org.apache.cocoon.transformation.TraxTransformer"/>
+</map:transformers>
}}}
Note: if you're using a sub-sitemap, then you don't need to configure the transformer
@@ -33,14 +33,14 @@
by parsing a file called {{{my.xml}}}, transforms it with a stylesheet {{{my.xsl}}}, and serializes
the results as HTML:
-{{{
-<map:pipeline>
- <map:match pattern="my.html">
- <map:generate src="my.xml"/>
- <map:transform src="stylesheets/my.xsl"/>
- <map:serialize/>
- </map:match>
-</map:pipeline>
+{{{
+<map:pipeline>
+ <map:match pattern="my.html">
+ <map:generate src="my.xml"/>
+ <map:transform src="stylesheets/my.xsl"/>
+ <map:serialize/>
+ </map:match>
+</map:pipeline>
}}}
Things to note here:
@@ -52,15 +52,15 @@
If you want to serialize the results as XML, then use the XML [:Serializer]:
-{{{
-<map:serialize type="xml"/>
+{{{
+<map:serialize type="xml"/>
}}}
If you want to serialize the results as XHTML (the XHTML Doctype will be automatically
added), then use the XHTML [:Serializer]:
-{{{
-<map:serialize type="xhtml"/>
+{{{
+<map:serialize type="xhtml"/>
}}}
== Passing Parameters ==
@@ -76,10 +76,10 @@
The {{{<map:parameter/>}}} element can be used to pass a fixed value to a
stylesheet, as follows:
-{{{
-<map:transform src="stylesheets/my.xsl">
- <map:parameter name="your-parameter-name" value="your-parameter-value"/>
-</map:transform>
+{{{
+<map:transform src="stylesheets/my.xsl">
+ <map:parameter name="your-parameter-name" value="your-parameter-value"/>
+</map:transform>
}}}
=== Sitemap Parameters ===
@@ -87,32 +87,32 @@
You can also use the {{{<map:parameter/>}}} element to pass dynamic [:Sitemap]
parameters to the XSLT processor using the curly brace syntax.
-{{{
-<map:transform src="stylesheets/my.xsl">
- <map:parameter name="your-parameter-name" value="{1}"/>
-</map:transform>
+{{{
+<map:transform src="stylesheets/my.xsl">
+ <map:parameter name="your-parameter-name" value="{1}"/>
+</map:transform>
}}}
-These parameters are set by [:Matchers] and/or [:Actions].
+These parameters are set by Matchers and/or Actions.
=== Request Parameters ===
You can pass request parameters to the XSL processor, as follows:
-{{{
-<map:transform src="stylesheets/my.xsl">
- <map:parameter name="use-request-parameters" value="true"/>
-</map:transform>
+{{{
+<map:transform src="stylesheets/my.xsl">
+ <map:parameter name="use-request-parameters" value="true"/>
+</map:transform>
}}}
When declaring the [:Component] (see '''XSLT Transformer''', above) you
can tell it to automatically use request parameters for ''all'' transformations
like this:
-{{{
-<map:transformer name="xslt" src="org.apache.cocoon.transformation.TraxTransformer">
- <use-request-parameters>true</use-request-parameters>
-</map:transformer>
+{{{
+<map:transformer name="xslt" src="org.apache.cocoon.transformation.TraxTransformer">
+ <use-request-parameters>true</use-request-parameters>
+</map:transformer>
}}}
Note that passing request parameters in this way can affect how Cocoon Caching the results of your transformation.