apache > cocoon
 

Cocoon Sitemap Generator FAQs

What is a generator?

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.

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.

For conceptual information on generators see the user's guide document The Sitemap. For detailed descriptions about all of the available Cocoon generators, see the user's guide document Generators in Cocoon. You may also wish to consult the Cocoon API documentation.

How can I write my own generator?

See the tutorial Writing a Cocoon 2 generator.

How can I dynamically specify the source for my generator?

For example, I want the <generate>'s src attribute to be defined based on a request.

Here are two solutions (depending on your version of Cocoon):

(1) RequestParamAction (2.0.x + 2.1)

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

Adding <map:act type="request"> and <map:parameter name="parameters" value="true"/> 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: <map:generate src="{page}"/>.

(2) InputModules (2.1)

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

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