home *** CD-ROM | disk | FTP | other *** search
/ PC Professionell 2004 December / PCpro_2004_12.ISO / files / webserver / xampp / xampp-cocoon-addon-1.4.9-installer.exe / faq-serializers.xml < prev    next >
Encoding:
Extensible Markup Language  |  2004-07-12  |  4.6 KB  |  141 lines

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!--
  3.   Copyright 1999-2004 The Apache Software Foundation
  4.  
  5.   Licensed under the Apache License, Version 2.0 (the "License");
  6.   you may not use this file except in compliance with the License.
  7.   You may obtain a copy of the License at
  8.  
  9.       http://www.apache.org/licenses/LICENSE-2.0
  10.  
  11.   Unless required by applicable law or agreed to in writing, software
  12.   distributed under the License is distributed on an "AS IS" BASIS,
  13.   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14.   See the License for the specific language governing permissions and
  15.   limitations under the License.
  16. -->
  17. <!DOCTYPE faqs PUBLIC "-//APACHE//DTD FAQ V1.0//EN" "faq-v10.dtd">
  18.  
  19. <faqs title="Cocoon Sitemap Serializer FAQs">
  20.  
  21. <faq>
  22.  <question>
  23.   What is a serializer?
  24.  </question>
  25.  
  26.  <answer>
  27.   <p>
  28. 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. 
  29.   </p>
  30.   <p>
  31. 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.
  32.   </p>
  33.   <p>
  34.  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.
  35.   </p>
  36. </answer>
  37. </faq>
  38.  
  39. <faq>
  40.  <question>
  41.   What is the easiest way to generate XHTML output?
  42.  </question>
  43.  
  44.  <answer>
  45.   <p>
  46. I have an stylesheet which transforms XML to XHTML, but it seems that the 
  47. serializer converts it to HTML. For example, I have some <br/> elements which are converted to  <br> elements. What can I do?
  48.   </p>
  49.   <p>
  50. Cocoon has serializer configured for XHTML. First, make sure to declare it in
  51. your sitemap's component section (within map:serializers).
  52.   </p>
  53. <source><![CDATA[
  54. <map:serializer name="xhtml" mime-type="text/html"
  55.   logger="sitemap.serializer.xhtml"
  56.   src="org.apache.cocoon.serialization.XMLSerializer"
  57.   pool-max="64" pool-min="2" pool-grow="2">
  58.   <doctype-public>-//W3C//DTD XHTML 1.0 Strict//EN</doctype-public>
  59.   <doctype-system>http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd</doctype-system>
  60.  <encoding>UTF-8</encoding>
  61. </map:serializer>  
  62. ]]></source>
  63.  
  64.   <p>
  65. Then, in any pipeline, simply use the serializer as follows.
  66.   </p>
  67.   
  68. <source><![CDATA[
  69. <map:serialize type="xhtml" />
  70. ]]></source>
  71.  
  72. </answer>
  73.  
  74. </faq>
  75.  
  76. <faq>
  77.  <question>
  78. How can I remove the DTD declaration at the top of my HTML
  79. pages created from pipelines with the default (HTML) serializer?
  80.  </question>
  81.  
  82.  <answer>
  83.   <p>
  84. Within the map:components section of sitemap.xmap, adjust the configuration of your HTML serializer component as follows.
  85.   </p>
  86. <source><![CDATA[
  87. <map:serializers default="html">
  88.  
  89.   <map:serializer name="html" mime-type="text/html; charset=ISO-8859-1"
  90.      src="org.apache.cocoon.serialization.HTMLSerializer">
  91.     <encoding>ISO-8859-1</encoding>
  92.     <omit-xml-declaration>true</omit-xml-declaration>
  93.   </map:serializer>
  94.    
  95.   <!-- other serializers -->
  96.    
  97. </map:serializers>
  98. ]]></source>
  99.  
  100.   <note>
  101. Consider using the XMLSerializer in your pipeline. The XMLSerializer will not write a DocType Declaration.
  102.   </note>
  103.   
  104. </answer>
  105.  
  106. </faq>
  107.  
  108. <faq>
  109.  <question>
  110. How can I remove namespaces from my xml files?
  111.  </question>
  112.  
  113.  <answer>
  114.   <p>
  115. Sometimes adding xsl:exclude-result-prefixes attributes
  116. to the <xsl:stylesheet> or literal result element is not effective
  117. in removing all namespace declarations. For example, namespace nodes copied 
  118. from the source document within <xsl:copy> or <xsl:copy-of> instructions 
  119. (commonly found in catch-all stylesheet templates) will not be excluded.
  120.   </p> 
  121.   <p>
  122. There are two approaches to this problem. 
  123.   </p> 
  124.     <p>
  125. 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.
  126.   </p>
  127.  <p>
  128. 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>.
  129.   </p>
  130.  
  131.   
  132. </answer>
  133.  
  134. </faq>
  135.  
  136.  
  137.  
  138.  
  139.  
  140. </faqs>
  141.