You are viewing a plain text version of this content. The canonical link for it is here.
Posted to docs@cocoon.apache.org by da...@cocoon.zones.apache.org on 2005/09/21 16:56:13 UTC

[DAISY] Created: Cocoon Sitemap Generator FAQs

A new document has been created.

http://cocoon.zones.apache.org/daisy/legacydocs/712.html

Document ID: 712
Branch: main
Language: default
Name: Cocoon Sitemap Generator FAQs
Document Type: Document
Created: 9/21/05 2:55:53 PM
Creator (owner): Helma van der Linden
State: publish

Parts
=====

Content
-------
Mime type: text/xml
Size: 2314 bytes
Content:
<html>
<body>

<h2>What is a generator?</h2>

<p>A generator is the starting point of an xml pipeline. It generates XML
content as SAX events and initializes pipeline processing. Every pipeline match
containing a generator must be terminated by a serializer.</p>

<p>In the sitemap file, each generator has a unique name which is mapped to a
java class. One generator name must be declared as the default generator. Each
generator may have additional configuration information specified in child
elements.</p>

<p>For conceptual information on generators see the user's guide document
<a href="../userdocs/concepts/sitemap.html">The Sitemap</a>. For detailed
descriptions about all of the available Cocoon generators, see the user's guide
document <a href="../userdocs/concepts/sitemap.html">Generators in Cocoon</a>.
You may also wish to consult the Cocoon API documentation.</p>

<h2>How can I write my own generator?</h2>

<p>See the tutorial <a href="../tutorial/tutorial-rmi-generator.html">Writing a
Cocoon 2 generator</a>.</p>

<h2>How can I dynamically specify the source for my generator?</h2>

<p>For example, I want the &lt;generate&gt;'s src attribute to be defined based
on a request.</p>

<p>Here are two solutions (depending on your version of Cocoon):</p>

<p>(1) RequestParamAction (2.0.x + 2.1)</p>

<pre>  &lt;map:match pattern="tba/*"&gt;
    &lt;map:act type="request"&gt;
	  &lt;map:parameter name="parameters" value="true"/&gt;
	  &lt;map:generate src="{page}"/&gt;
 	  &lt;map:transform src="docs/samples/tba/redirect.xsl"/&gt;
 	  &lt;map:serialize type="html"/&gt;
    &lt;/map:act&gt;
    &lt;!-- else ? --&gt;
 &lt;/map:match&gt; 
</pre>

<p>Adding &lt;map:act type="request"&gt; and &lt;map:parameter name="parameters"
value="true"/&gt; makes it possible to get the page request attribute. Then, you
can define the src attribute by using the value of the page attribute like this:
&lt;map:generate src="{page}"/&gt;.</p>

<p>(2) InputModules (2.1)</p>

<pre> &lt;map:match pattern="tba/*"&gt;
 	&lt;map:generate src="{request:page}"/&gt;
 	&lt;map:transform src="docs/samples/tba/redirect.xsl"/&gt;
 	&lt;map:serialize type="html"/&gt;
 &lt;/map:match&gt; 
</pre>

<p>In addition, you may want to use ResourceExistsAction to check whether the
provided page exists.</p>

</body>
</html>

Collections
===========
The document belongs to the following collections: legacydocs