Copyright 1999-2004 The Apache Software Foundation
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<!DOCTYPE faqs PUBLIC "-//APACHE//DTD FAQ V1.0//EN" "faq-v10.dtd">
<faqs title="Cocoon Sitemap Serializer FAQs">
<faq>
<question>
What is a serializer?
</question>
<answer>
<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 elements.
</p>
<p>
For more conceptual information about serializers see <link href="../userdocs/concepts/sitemap.html">the sitemap</link>. For detailed descriptions about all of the available Cocoon serializers, see the user's guide document <link href="../userdocs/serializers/serializers.html">Serializers in Cocoon</link>. You may also wish to consult the Cocoon API documentation.
</p>
</answer>
</faq>
<faq>
<question>
What is the easiest way to generate XHTML output?
</question>
<answer>
<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 <br/> elements which are converted to <br> 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).
Consider using the XMLSerializer in your pipeline. The XMLSerializer will not write a DocType Declaration.
</note>
</answer>
</faq>
<faq>
<question>
How can I remove namespaces from my xml files?
</question>
<answer>
<p>
Sometimes adding xsl:exclude-result-prefixes attributes
to the <xsl:stylesheet> or literal result element is not effective
in removing all namespace declarations. For example, namespace nodes copied
from the source document within <xsl:copy> or <xsl:copy-of> 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 excluded.
</p>
<p>
Another approach is to use an interim transformation step in your pipeline with a stylesheet described <link href="faq-xslt.html#faq-5">here</link>.