cocoon-docs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
Subject [DAISY] Created: Cocoon Sitemap Serializer FAQs
Date Wed, 21 Sep 2005 14:43:11 GMT
A new document has been created.

Document ID: 710
Branch: main
Language: default
Name: Cocoon Sitemap Serializer FAQs
Document Type: Document
Created: 9/21/05 2:43:09 PM
Creator (owner): Helma van der Linden
State: publish


Mime type: text/xml
Size: 3582 bytes

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

<p>A serializer is the end point of an xml pipeline. It transforms SAX events
into binary or char streams for final client consumption. Every pipeline match
containing a generator must be terminated by a serializer.</p>

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

<p>For more conceptual information about serializers see the sitemap. For
detailed descriptions about all of the available Cocoon serializers, see the
user's guide document Serializers in Cocoon. You may also wish to consult the
Cocoon API documentation.</p>

<h2>What is the easiest way to generate XHTML output?</h2>

<p>I have an stylesheet which transforms XML to XHTML, but it seems that the
serializer converts it to HTML. For example, I have some &lt;br/&gt; elements
which are converted to &lt;br&gt; elements. What can I do?</p>

<p>Cocoon has serializer configured for XHTML. First, make sure to declare it in
your sitemap's component section (within map:serializers).</p>

<pre>&lt;map:serializer name="xhtml" mime-type="text/html"
  &lt;doctype-public&gt;-//W3C//DTD XHTML 1.0 Strict//EN&lt;/doctype-public&gt;

<p>Then, in any pipeline, simply use the serializer as follows.</p>

<pre>&lt;map:serialize type="xhtml" /&gt;</pre>

<h2>How can I remove the DTD declaration at the top of my HTML pages created
from pipelines with the default (HTML) serializer?</h2>

<p>Within the map:components section of sitemap.xmap, adjust the configuration
of your HTML serializer component as follows.</p>

<pre>&lt;map:serializers default="html"&gt;

  &lt;map:serializer name="html" mime-type="text/html; charset=ISO-8859-1"

  &lt;!-- other serializers --&gt;


<p>Consider using the XMLSerializer in your pipeline. The XMLSerializer will not
write a DocType Declaration.</p>

<h2>How can I remove namespaces from my xml files?</h2>

<p>Sometimes adding xsl:exclude-result-prefixes attributes to the
&lt;xsl:stylesheet&gt; or literal result element is not effective in removing
all namespace declarations. For example, namespace nodes copied from the source
document within &lt;xsl:copy&gt; or &lt;xsl:copy-of&gt; instructions (commonly
found in catch-all stylesheet templates) will not be excluded.</p>

<p>There are two approaches to this problem.</p>

<p>One approach is to extend your serializer component and override the
startPrefixMapping and endPrefixMapping methods to do nothing. This will remove
<strong>all</strong> namespaces from the serialized output. Since your
serializer will no longer be processing namespaces, this theoretically will
improve performance ever so slightly. You could generalize this approach by
using the serializer's configuration method to declare namespaces to be

<p>Another approach is to use an interim transformation step in your pipeline
with a stylesheet described here.</p>


The document belongs to the following collections: legacydocs

View raw message