blob: 37555bfc1cc08bc3b56e25d573dc3b11b4668297 [file] [log] [blame]
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE document PUBLIC "-//APACHE//DTD Documentation V1.0//EN" "../../dtd/document-v10.dtd">
<document>
<header>
<title>HTML Generator</title>
<version>0.9</version>
<type>Technical document</type>
<authors>
<person name="Carsten Ziegeler" email="cziegeler@apache.org"/>
<person name="Sylvain Wallez" email="sylvain@apache.org"/>
<person name="Gianugo Rabellino " email="gianugo@apache.org"/>
</authors>
<abstract>This document describes the html generator of Cocoon.</abstract>
</header>
<body>
<s1 title="HTML Generator">
<p>The html generator reads an html document from the local file system or from any url.
It acts similar to the file generator with the difference that it reads
html documents and converts them using <link href="http://sourceforge.net/projects/jtidy">JTidy</link>
to xhtml.</p>
<p>This generator is optional and requires the jtidy package
in the lib directory when building Cocoon. However,
the distribution includes this package already.</p>
<ul>
<li>Name : html</li>
<li>Class: org.apache.cocoon.generation.HTMLGenerator</li>
<li>Cacheable: yes - uses the last modification date of the html document for validation.</li>
</ul>
<p>The location of the source html document is specified in
the pipeline by the src attribute.</p>
<source>
<![CDATA[
<map:generate src="document.html" type="html"/>
]]>
</source>
<p>The html generator, however, can operate also on a request
attribute or on a XML POST request. This can be done also by the
<link href="stream-generator.html">stream generator</link>, with whom
it shares the syntax: the added bonus here is that you can
"sanitize" a possibly non well-formed XML snippet for further
reuse later. In order to use this feature for request attributes,
just omit the "src" attribute and set a parameter like the following
one in the sitemap:</p>
<source>
<![CDATA[
<map:parameter name="form-name" value="my-request-attribute"/>
]]>
</source>
</s1>
<s1 title="Configuring JTidy">
<p>Without any configuration, the generator produces an XHTML document, with the proper namespace. However,
JTidy offers a full range of options for converting the HTML document to XML.</p>
<p>These options can be specified in a properties file (key=value pairs) whose location is given in the
component configuration :</p>
<source>
<![CDATA[
<map:generator type="html" src="org.apache.cocoon.generation.HTMLGenerator">
<jtidy-config>jtidy.properties</jtidy-config>
</map:generator>
]]>
</source>
<p>The <code>jtidy-config</code> URL can be either relative (to the application context), one of Cocoon's special
protocols such as <code>resouce:</code> which searches the file in the classpath.</p>
<p>For more information on the available configurations, please refer to the
<link href="http://www.w3.org/People/Raggett/tidy/">original Tidy page</link>. Beware that configuration
examples shown there use the ':' as a separator when JTidy requires a '=' as it is a standard Java properties file.
</p>
</s1>
</body>
</document>