63383ca04c979952f572ec682a5bf7f246936bf4
[geeqie.git] / doc / wiki2docbook / html2db / index.xml
1 <?xml version="1.0" encoding="UTF-8"?>\r
2 <article>\r
3 \r
4 <title>html2db.xsl</title>\r
5 \r
6 \r
7 <articleinfo>\r
8   <author>\r
9     <firstname>Oliver</firstname>\r
10     <surname>Steele</surname>\r
11   </author>\r
12   <revhistory>\r
13     <revision>\r
14       <revnumber>1</revnumber>\r
15       <date>2004-07-30</date>\r
16     </revision>\r
17     <revision>\r
18       <revnumber>1.0.1</revnumber>\r
19       <date>2004-08-01</date>\r
20       <revdescription><para>Editorial changes to the\r
21       readme.</para></revdescription>\r
22     </revision>\r
23   </revhistory>\r
24   <date>2004-07-30</date>\r
25 </articleinfo>\r
26 \r
27 <para/><section><title>Overview</title>\r
28 \r
29 <para><literal>html2db.xsl</literal> converts an XHTML source document into a Docbook output\r
30 document.  It provides features for customizing the generation of the\r
31 output, so that the output can be tuned by annotating\r
32 the source, rather than hand-editing the output.  This makes it useful\r
33 in a processing pipeline where the source documents are maintained in\r
34 HTML, although it can be used as a one-time conversion tool\r
35 too.</para>\r
36 \r
37 <para>This document is an example of <literal>html2db.xsl</literal> used in conjunction with\r
38 the Docbook XSL stylesheets.  The <ulink url="index.src.html">source\r
39 file</ulink> is an XHTML file with some embedded Docbook elements and\r
40 processing instructions.  <literal>html2db.xsl</literal> compiles it into a <ulink url="index.xml">Docbook document</ulink>, which can be used to generate\r
41 this output file (which includes a Table of Contents), a <ulink url="docs/index.html">chunked HTML file</ulink>, a <ulink url="html2db.pdf">PDF</ulink>, or other formats.</para>\r
42 \r
43 <para/></section><section><title>Features</title>\r
44 <variablelist><varlistentry><term>XSLT implementation</term><listitem><para>This tool is designed to be embedded within an XSLT processing\r
45 pipeline.  <literal>html2html.xslt</literal> can be used in a custom\r
46 stylesheet or integrated into a larger system.  See <link linkend="embedding">Overriding</link>.</para></listitem></varlistentry><varlistentry><term>Customizable</term><listitem><para>The output can be customized by the means of additonal markup in\r
47 the XHMTL source.  See the section on <link linkend="customization">customization</link>.</para></listitem></varlistentry><varlistentry><term>Creates outline structure</term><listitem><para><literal>h1</literal>, <literal>h2</literal>, etc. are turned into nested\r
48 <literal>section</literal> and <literal>title</literal> elements (as opposed to\r
49 bridge heads).</para></listitem></varlistentry><varlistentry><term>Accepts a wide variety of XHTML</term><listitem><para>In particular, <literal>html2db.xsl</literal> automatically wraps <indexterm significance="preferred"><primary>naked item\r
50 text</primary></indexterm><glossterm>naked item\r
51 text</glossterm> (text that is not enclosed in a <literal>&lt;p&gt;</literal>)\r
52 inside a table cell or list item.  Naked text is a common property of\r
53 XHTML documents, but needs to be clothed to create valid\r
54 Docbook.<footnote><para>This feature is limited.  See <link linkend="implicit-blocks">Implicit Blocks</link>.)</para></footnote></para></listitem></varlistentry></variablelist>\r
55 \r
56 <para/></section><section><title>Requirements</title>\r
57 <itemizedlist spacing="compact"><listitem><para>Java: JRE or JDK 1.3 or greater.</para></listitem><listitem><para>Xalan 2.5.0.</para></listitem><listitem><para>Familiarity with installing and running JAR files.</para></listitem></itemizedlist>\r
58 \r
59 <para><literal>html2db.xsl</literal> might work with earlier versions of Java and Xalan, and\r
60 it might work with other XSLT processors such as Saxon and\r
61 xsltproc.</para>\r
62 \r
63 <para/></section><section><title>License</title>\r
64 <para>This software is released under the Open Source <ulink url="http://www.opensource.org/licenses/artistic-license.php">Artistic License</ulink>.</para>\r
65 \r
66 <para/></section><section><title>Installation</title>\r
67 <itemizedlist spacing="compact"><listitem><para>Install JRE 1.3 or higher.</para></listitem><listitem><para>Install Xalan, if necessary.</para></listitem><listitem><para>Download <literal>html2db-1.zip</literal> from <ulink url="http://osteele.com/sources/html2db.zip">http://osteele.com/sources/html2db-1.zip</ulink>.</para></listitem><listitem><para>Unzip <literal>html2db-1.zip</literal>.</para></listitem></itemizedlist>\r
68 \r
69 <para/></section><section><title>Usage</title>\r
70 <para>Use Xalan to process an XHTML source file into a Docbook file:</para>\r
71 \r
72 <informalexample><programlisting>\r
73 java org.apache.xalan.xslt.Process -XSL html2dbk.xsl -IN doc.html &gt; doc.xml\r
74 </programlisting></informalexample>\r
75 \r
76 <para>See <ulink url="index.src.html"><literal>index.src.html</literal></ulink> for an\r
77 example of an input file.</para>\r
78 \r
79 <para>If your source files are in HTML, not XHTML, you may find the <ulink url="http://tidy.sourceforge.net/">Tidy</ulink> tool useful.  This is a\r
80 tool that converts from HTML to XHTML, and can be added to the front\r
81 of your processing pipeline.</para>\r
82 \r
83 <para>(If you need to process HTML and you don't know or can't figure out\r
84 from context what a processing pipeline is, <literal>html2db.xsl</literal> is probably not\r
85 the right tool for you, and you should look for a local XML or Java\r
86 guru or for a commercially supported product.)</para>\r
87 \r
88 <para/></section><section><title>Specification</title>\r
89 \r
90 <para/><section><title>XHTML Elements</title>\r
91 <para><literal>code/i</literal> stands for "an <literal>i</literal> element\r
92 immediately within a <literal>code</literal> element".  This notation is\r
93 from XPath.</para>\r
94 \r
95 <para>XHTML elements must be in the XHTML Transitional namespace,\r
96 <literal>http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd</literal>.</para>\r
97 \r
98 <informaltable><tgroup cols="3"><thead><row><entry>XHTML</entry><entry>Docbook</entry><entry>Notes</entry></row>\r
99 </thead><tbody><row><entry><literal>b</literal>, <literal>i</literal>, <literal>em</literal>, <literal>strong</literal></entry><entry><literal>emphasis</literal></entry><entry>The <literal>role</literal> attribute is the original tag name</entry></row>\r
100 <row><entry><literal>dfn</literal></entry><entry><literal>glossitem</literal>, and also <literal>primary</literal> <literal>indexterm</literal></entry></row>\r
101 <row><entry><literal>code/i</literal>, <literal>tt/i</literal>, <literal>pre/i</literal></entry><entry><literal>replaceable</literal></entry><entry>In practice, <literal>i</literal> within a monospace content is usually used to mean replaceable text.  If you're using it for emphasis, use <literal>em</literal> instead.</entry></row>\r
102 <row><entry><literal>pre</literal>, <literal>body/code</literal></entry><entry><literal>programlisting</literal></entry></row>\r
103 <row><entry><literal>img</literal></entry><entry><literal>inlinemediaobject/imageobject/imagedata</literal></entry><entry>In an inline context.</entry></row>\r
104 <row><entry><literal>img</literal></entry><entry><literal>[informal]figure/mediaobject/imageobject/imagedata</literal></entry><entry>If it has a <literal>title</literal> attribute or <literal>db:title</literal> it's wrapped in a <literal>figure</literal>.  Otherwise it's wrapped in an <literal>informalfigure</literal>.</entry></row>\r
105 <row><entry><literal>table</literal></entry><entry><literal>[informal]table</literal></entry><entry>XHTML <literal>table</literal> becomes Docbook <literal>table</literal> if it has a <literal>summary</literal> attribute; <literal>informaltable</literal> otherwise.</entry></row>\r
106 <row><entry><literal>ul</literal></entry><entry><literal>itemizedlist</literal></entry><entry>But see the processing instruction <link linkend="simplelist">below</link>.</entry></row>\r
107 </tbody></tgroup></informaltable>\r
108 \r
109 \r
110 \r
111 <para/></section><section><title>Links</title>\r
112 <table><title>Link Translation</title><tgroup cols="3"><thead><row><entry>XHTML</entry><entry>Docbook</entry><entry>Notes</entry></row>\r
113 </thead><tbody><row><entry><literal>&lt;a name="<replaceable>name</replaceable>"&gt;</literal></entry><entry><literal>&lt;anchor id="{$anchor-id-prefix}<replaceable>name</replaceable>"&gt;</literal></entry><entry>An anchor within a <literal>h<replaceable>n</replaceable></literal> element is attached to the enclosing <literal>section</literal> as an <literal>id</literal> attribute instead.</entry></row>\r
114 <row><entry><literal>&lt;a href="#<replaceable>name</replaceable>"&gt;</literal></entry><entry><literal>&lt;link linkend="{$anchor-id-prefix}<replaceable>name</replaceable>"&gt;</literal></entry></row>\r
115 <row><entry><literal>&lt;a href="<replaceable>url</replaceable>"&gt;</literal></entry><entry><literal>&lt;ulink url="<replaceable>name</replaceable>"&gt;</literal></entry></row>\r
116 <row><entry><literal>&lt;a name="mailto:<replaceable>address</replaceable>"&gt;</literal></entry><entry><literal>&lt;email&gt;<replaceable>address</replaceable>&lt;/email&gt;</literal></entry></row>\r
117 </tbody></tgroup></table>\r
118 \r
119 <para/></section><section id="tables"><title>Tables</title>\r
120 \r
121 <para>XHTML <literal>table</literal> support is minimal.  <literal>html2db.xsl</literal> changes the\r
122 element names and counts the columns (this is necessary to get table\r
123 footnotes to span all the columns), but it does not attempt to deal\r
124 with tables in their full generality.</para>\r
125 \r
126 <para>An XHTML <literal>table</literal> with a <literal>summary</literal> attribute\r
127 generates a <literal>table</literal>, whose <literal>title</literal> is the value\r
128 of that summary.  An XHTML <literal>table</literal> without a\r
129 <literal>summary</literal> generates an <literal>informaltable</literal>.</para>\r
130 \r
131 <para>Any <literal>tr</literal>s that contain <literal>th</literal>s are pulled to\r
132 the top of the table, and placed inside a <literal>thead</literal>.  Other\r
133 <literal>tr</literal>s are placed inside a <literal>tbody</literal>.  This matches\r
134 the commanon XHTML <literal>table</literal> pattern, where the first row is\r
135 a header row.</para>\r
136 \r
137 <para/></section><section id="implicit-blocks"><title>Implicit Blocks</title>\r
138 <para>XHTML allows <literal>li</literal>, <literal>dd</literal>, and <literal>td</literal>\r
139 elements to contain either inline text (for instance,\r
140 <literal>&lt;li&gt;a list item&lt;/li&gt;</literal>) or block structure\r
141 (<literal>&lt;li&gt;&lt;p&gt;a block&lt;/p&gt;&lt;/li&gt;</literal>).  The\r
142 corresponding Docbook elements require block structure, such as\r
143 <literal>para</literal>.</para>\r
144 \r
145 <para><literal>html2db.xsl</literal> provides limited support for wrapping naked text in\r
146 these positions in <literal>para</literal> elements.  If a list item or\r
147 table cell item directly contains text, all text up to the position of\r
148 the first element (or all text, if there is no element) is wrapped in\r
149 <literal>para</literal>.  This handles the simple case of an item that\r
150 directly contains text, and also the case of an item that contains\r
151 text followed by blocks such as paragraphs.</para>\r
152 \r
153 <para>Note that this algorithm is easily confused.  It doesn't\r
154 distinguish between block and inline XHTML elements, so it will only\r
155 wrap the first word in <literal>&lt;li&gt;some &lt;b&gt;bold&lt;/b&gt;\r
156 text&lt;/li&gt;</literal>, leading to badly formatted output.  Twhe\r
157 workaround is to wrap troublesome content in explicit\r
158 <literal>&lt;p&gt;</literal> tags.</para>\r
159 \r
160 <para/></section><section id="docbook-elements"><title>Docbook Elements</title>\r
161 \r
162 <para>Elements from the Docbook namespace are passed through as is.\r
163 There are two ways to include a Docbook element in your XHTML\r
164 source:</para>\r
165 \r
166 <variablelist><varlistentry><term>Global prefix</term><listitem><para>A <indexterm significance="preferred"><primary>fake Docbook namespace</primary></indexterm><glossterm>fake Docbook namespace</glossterm><footnote><para>The fake\r
167 Docbook namespace is <literal>urn:docbook</literal>.  Docbook doesn't really\r
168 have a namespace, and if it did, it wouldn't be this one.  See <link linkend="docbook-namespace">Docbook namespace</link> for a discussion of\r
169 this issue.</para></footnote>\r
170 \r
171 declaration may be added to the document root element.  Anywhere in\r
172 the document, the prefix from this namespace declaration may be used\r
173 to include a Docbook element.  This is useful if a document contains\r
174 many Docbook elements, such as <literal>footnote</literal> or\r
175 <literal>glossterm</literal>, interspersed with XHTML.  (In this case it may\r
176 be more convenient to allow these elements in the XHMTL namespace and\r
177 add a customization layer that translates them to docbook elements,\r
178 however.  See <link linkend="customization">Customization</link>.)</para>\r
179 \r
180 <informalexample><programlisting>\r
181 &lt;html xmlns="http://www.w3.org/1999/xhtml"\r
182       xmlns:db="urn:docbook"&gt;\r
183   ...\r
184   &lt;p&gt;Some text&lt;db:footnote&gt;and a footnote&lt;/db:footnote&gt;.&lt;/p&gt;\r
185 </programlisting></informalexample></listitem></varlistentry><varlistentry><term>Local namespace</term><listitem><para>A Docbook element may be introduced along with a prefix-less\r
186 namespace declaration.  This is useful for embedding a Docbook\r
187 document fragment (a hierarchy of elements that all use Docbook tags)\r
188 within of a XHTML document.</para>\r
189 \r
190 <informalexample><programlisting>\r
191   ...\r
192   &lt;articleinfo xmlns="urn:docbook"&gt;\r
193     &lt;author&gt;\r
194       &lt;firstname&gt;...&lt;/firstname&gt;\r
195   ...\r
196 </programlisting></informalexample></listitem></varlistentry></variablelist>\r
197 \r
198 <para>The source to <ulink url="index.src.html">this document</ulink>\r
199 illustrates both of these techniques.</para>\r
200 \r
201 <note><para>Both these techniques will cause your document to be\r
202 invalid as XHTML.  In order to validate an XHTML document that\r
203 contains Docbook elements, you will need to create a custom schema.\r
204 Technically, you then ought to place your document in a different\r
205 namespace, but this will cause <literal>html2db.xsl</literal> not to recognize it!</para></note>\r
206 \r
207 \r
208 <para/></section><section><title>Output Processing Instructions</title>\r
209 \r
210 <para><literal>html2db.xsl</literal> adds a few of processing instructions to the output file.\r
211 The Docbook XSL stylesheets ignore these, but if you write a\r
212 customization layer for Docbook XSL, you can use the information in\r
213 these processing instructions to customize the HTML output.  This can\r
214 be used, for example, to set the <literal>a</literal> <literal>onclick</literal>\r
215 and <literal>target</literal> attributes in the HTML files that Docbook XSL\r
216 creates to the same values they had in the input document.</para>\r
217 \r
218 <variablelist><varlistentry><term><literal>&lt;?html2db attribute="<replaceable>name</replaceable>" value="<replaceable>value</replaceable>"?&gt;</literal></term><listitem><para>Placed inside a link element to capture the value of the <literal>a</literal> <literal>target</literal> and <literal>onclick</literal> attributes.  <replaceable>name</replaceable> is the name of the attribute (<literal>target</literal> or <literal>onclick</literal>), and <replaceable>value</replaceable> is its value, with <literal>"</literal> and <literal>\</literal> replaced by <literal>\"</literal> and <literal>\\</literal>, respectively.</para></listitem></varlistentry><varlistentry><term><literal>&lt;?html2db element="br"?&gt;</literal></term><listitem><para>Represents the location of an XHTML <literal>br</literal> element in the\r
219 source document.</para></listitem></varlistentry></variablelist>\r
220 \r
221 <para>You can also include <literal>&lt;?db2html?&gt;</literal> processing\r
222 instructions in the HTML source document, and they will be copied\r
223 through to the Docbook output file unchanged (as will all other\r
224 processing instructions).</para>\r
225 \r
226 \r
227 <para/></section></section><section id="customization"><title>Customization</title>\r
228 <para/><section><title>XSLT Parameters</title>\r
229 <variablelist><varlistentry><term><literal>&lt;xsl:param name="anchor-id-prefix" select="''/&gt;</literal></term><listitem><para>Prefixed to every id generated from <literal>&lt;a name=&gt;</literal>\r
230   and <literal>&lt;a href="#"&gt;</literal>.  This is useful to avoid\r
231   collisions between multiple documents that are compiled into the\r
232   same book.  For instance, if a number of XHTML sources are assembled\r
233   into chapters of a book, you style each source file with a prefix of\r
234   <literal><replaceable>docid</replaceable>.</literal> where <replaceable>docid</replaceable> is a unique id\r
235   for each source file.</para></listitem></varlistentry><varlistentry><term><literal>&lt;xsl:param name="document-root" select="'article'"/&gt;</literal></term><listitem><para>The default document root.  This can be overridden by\r
236   <literal>&lt;?html2db class="<replaceable>name</replaceable>"&gt;</literal> within the\r
237   document itself, and defaults to <literal>article</literal>.</para></listitem></varlistentry></variablelist>\r
238 \r
239 <para/></section><section id="processing-instructions"><title>Processing instructions</title>\r
240 <para>Use the <literal>&lt;?html2db?&gt;</literal> processing instruction to\r
241 customize the transformation of the XHTML source to Docbook:</para>\r
242 \r
243 <informaltable><tgroup cols="3"><thead><row><entry>Processing instruction</entry><entry>Content</entry><entry>Effect</entry></row>\r
244 </thead><tbody><row><entry><literal>&lt;?html2db class="<replaceable>xxx</replaceable>"?&gt;</literal></entry><entry><literal>body</literal></entry><entry>Sets the output document root to <replaceable>xxx</replaceable>.  Useful for\r
245 translating to <literal>prefix</literal>, <literal>appendix</literal>, or <literal>chapter</literal>; the default is\r
246 <replaceable>$document-root</replaceable>.</entry></row>\r
247 <row id="simplelist"><entry><literal>&lt;?html2db class="simplelist"?&gt;</literal></entry><entry><literal>ul</literal></entry><entry>Creates a vertical <literal>simplelist</literal>.<footnote><para>Note that the\r
248 current implementation simply checks for the presence of <emphasis role="em">any</emphasis>\r
249 <literal>html2db</literal> processing instruction.</para></footnote></entry></row>\r
250 <row><entry><literal>&lt;?html2db rowsep="1"?&gt;</literal></entry><entry><literal>[informal]table</literal></entry><entry>Sets the <literal>rowsep</literal> attribute on the generated <literal>table</literal>.<footnote><para>Note that the current implementation simply checks for the presence of <emphasis role="em">any</emphasis> <literal>html2db</literal> processing instruction that begins with <literal>rowsep</literal>, and assumes the vlaue is <literal>1</literal>.</para></footnote></entry></row>\r
251 </tbody></tgroup></informaltable>\r
252 \r
253 <para/></section><section id="embedding"><title>Overriding the built-in templates</title>\r
254 <para>For cases where the previous techniques don't allow for enough\r
255 customization, you can override the builtin templates.  You will need\r
256 to know XSLT in order to do this, and you will need to write a new\r
257 stylesheet that uses the <literal>xsl:import</literal> element to import\r
258 <literal>html2db.xsl</literal>.</para>\r
259 \r
260 <para>The <ulink url="examples.xsl"><literal>example.xsl</literal></ulink> stylesheet\r
261 is an example customization layer.  It recognizes the <literal>&lt;div\r
262 class="abstract"&gt;</literal> and <literal>&lt;p class="note"&gt;</literal>\r
263 classes in the <ulink url="index.src.html">source</ulink> for this document,\r
264 and generates the corresponding Docbook elements.</para>\r
265 \r
266 \r
267 <para/></section></section><section><title>FAQ</title>\r
268 <para/><section><title>Why generate Docbook?</title>\r
269 <para>The primary reason to use Docbook as an <emphasis role="em">output</emphasis> format is\r
270 to take advantage of the Docbook XSL stylesheets.  These are a\r
271 well-designed, well-documented set of XSL stylesheets that provide a\r
272 variety of publishing features that would be difficult to recreate\r
273 from scratch for HTML:</para>\r
274 \r
275 <itemizedlist spacing="compact"><listitem><para>Automatic Table-of-Contents generation</para></listitem><listitem><para>Automatic part, chapter, and section numbering.</para></listitem><listitem><para>Creation of single-page, multi-page, PDF, and WinHelp files from the same source document.</para></listitem><listitem><para>Navigation headers, footers, and metadata for multi-page HTML\r
276 documents.</para></listitem><listitem><para>Link resolution and link target text insertion across multiple pages and numbered targets.</para></listitem><listitem><para>Figure, example, and table numbering, and tables of these.</para></listitem><listitem><para>Index and glossary tools.</para></listitem></itemizedlist>\r
277 \r
278 <para/></section><section><title>Why write in XHTML?</title>\r
279 \r
280 <para>Given that Docbook is so great, why not write in it?</para>\r
281 \r
282 <para>Where there are not legacy concerns, Docbook is probably a better\r
283 choice for structured or technical documentation.</para>\r
284 \r
285 <para>Where the only legacy concern is the documents themselves, and not\r
286 the tools and skill sets of documentation contributors, you should\r
287 consider using an (X)HMTL convertor to perform a one-time conversion\r
288 of your documentation source into Docbook, and then switching\r
289 development to the result files.  You can use this stylesheet to\r
290 perform this conversion, or evaluate other tools, many of which are\r
291 probably appropriate for this purpose.</para>\r
292 \r
293 <para>Often there are other legacy concerns: the availability of cheap\r
294 (including free) and usable HTML editors and editing modes; and the\r
295 fact that it's easier to teach people XHTML than Docbook.  If either\r
296 of this is an issue in your organization, you may want to maintain\r
297 documentation sources in XHTML instead of Docbook</para>\r
298 \r
299 <para>For example, at <ulink url="http://www.laszlosystems.com/">Laszlo</ulink>,\r
300 most developers contribute directly to the documentation.  Requiring\r
301 that developers learn Docbook, or that they wait on the doc team to\r
302 get content into the docs, would discourage this.</para>\r
303 \r
304 <para/></section><section><title>Why not use an existing convertor?</title>\r
305 \r
306 <para>This isn't the first (X)HTML to Docbook convertor.  Why not use one\r
307 of the exisitng ones?</para>\r
308 \r
309 <para>Each HTML to Docbook convertors that I could find had at least some\r
310 of the following limitations, some of which stemmed from their\r
311 intended use as one-time-only convertors for legacy documents:</para>\r
312 \r
313 <itemizedlist spacing="compact"><listitem><para>Many only operated on a subset of HTML, and relied upon hand\r
314 editing of the output to clean up mistakes.  This made them impossible\r
315 to use as part of a processing pipeline, where the source is\r
316 <emphasis role="em">maintained</emphasis> in XHTML.</para></listitem><listitem><para>There was no way to customize the output, except by (1) hand\r
317 editing, or (2) writing a post-processing stylesheet, which didn't\r
318 have access to the information in the XHTML source document.</para></listitem><listitem><para>Many of them were difficult or impossible to customize and\r
319 extend. They were closed-source, or written in Java or Perl (which I\r
320 find to be a difficult languages to use for customizing this kind of\r
321 thing) and embedded in a larger system.</para></listitem><listitem><para>They didn't take full advantage of the Docbook tag set and content\r
322 model to represent document structure.  For instance, they didn't\r
323 generate nested <literal>section</literal> elements to represent\r
324 <literal>h1</literal> <literal>h2</literal> sequences, or <literal>table</literal> to\r
325 represent tables with <literal>summary</literal> attributes.</para></listitem></itemizedlist>\r
326 \r
327 <para/></section><section><title>I got this error.  What does it mean?</title>\r
328 <variablelist><varlistentry><term>Q. <literal>Fatal Error! The element type "br" must be terminated by the matching end-tag "&lt;/br&gt;".\r
329 </literal></term><listitem><para>A. Your document is HTML, not <emphasis role="em">X</emphasis>HTML.  You need to fix it, or run it through Tidy first.</para></listitem></varlistentry><varlistentry><term>Q. My output document is empty except for the <literal>&lt;?xml version="1.0" encoding="UTF-8"?&gt;</literal> line.</term><listitem><para>A. The document is missing a namespace declaration.  See the <ulink url="index.src.html">example</ulink> for an example.</para></listitem></varlistentry><varlistentry><term>Q. Some of the headers and document sections are repeated multiple times.</term><listitem><para>A. The document has out-of-sequence headers, such as <literal>h1</literal> followed by <literal>h3</literal> (instead of <literal>h2</literal>).  This won't work.</para></listitem></varlistentry><varlistentry><term>Q. <literal>Fatal Error! The prefix "db" for element "db:footnote" is not bound.</literal></term><listitem><para>A. You haven't declared the <literal>db</literal> namespace prefix.  See the <ulink url="index.src.html">example</ulink> for an example.</para></listitem></varlistentry></variablelist>\r
330 \r
331 \r
332 <para/></section></section><section><title>Implementation Notes</title>\r
333 \r
334 <para/><section><title>Bugs</title>\r
335 <itemizedlist spacing="compact"><listitem><para>Improperly sequenced <literal>h<replaceable>n</replaceable></literal> (for example\r
336 <literal>h1</literal> followed by <literal>h3</literal>, instead of\r
337 <literal>h2</literal>) will result in duplicate text.</para></listitem></itemizedlist>\r
338 \r
339 \r
340 <para/></section><section><title>Limitations</title>\r
341 <itemizedlist spacing="compact"><listitem><para>The <literal>id</literal> attribute is only preserved for certain\r
342 elements (at least <literal>h<replaceable>n</replaceable></literal>, images, paragraphs, and\r
343 tables).  It ought to be preserved for all of them.</para></listitem><listitem><para>Only the <link linkend="tables">very simplest</link> table format is\r
344 implemented.</para></listitem><listitem><para>Always uses compact lists.</para></listitem><listitem><para>The string matching for <literal>&lt;?html2b\r
345 class="<replaceable>classname</replaceable>"?&gt;</literal> requires an exact match\r
346 (spaces and all).</para></listitem><listitem><para>The <link linkend="implicit-blocks">implicit blocks</link> code is easily\r
347 confused, as documented in that section.  This is\r
348 easy to fix now that I understand the difference between block and\r
349 inline elements (I didn't when I was implementing this), but I\r
350 probably won't do so until I run into the problem again.</para></listitem></itemizedlist>\r
351 \r
352 \r
353 \r
354 \r
355 <para/></section><section><title>Wishlist</title>\r
356 <itemizedlist spacing="compact"><listitem><para>Allow <literal>&lt;html2db attribute-name="<replaceable>name</replaceable>"\r
357 value="<replaceable>value</replaceable>"?&gt;</literal> at any position, to set arbitrary\r
358 Docbook attributes on the generated element.</para></listitem><listitem><para>Use different technique from the <link linkend="docbook-elements">fake\r
359 namespace prefix</link> to name Docbook elements in the source, that\r
360 preserves the XHTML validity of the source file. For example, an\r
361 option transform <literal>&lt;div class="db:footnote"&gt;</literal> into\r
362 <literal>&lt;footnote&gt;</literal>, or to use a processing attribute\r
363 (<literal>&lt;div&gt;&lt;?html2db classname="footnote"?&gt;</literal>).</para></listitem><listitem><para>Parse DC metadata from XHTML <literal>html/head/meta</literal>.</para></listitem><listitem><para>Add an option to use <literal>html/head/title</literal> instead of\r
364 <literal>html/body/h1[1]</literal> for top title.</para></listitem><listitem><para>Allow an <literal>id</literal> on every element.</para></listitem><listitem><para>Add an option to translate the XHTML <literal>class</literal> into a\r
365 Docbook <literal>role</literal>.</para></listitem><listitem><para>Preserve more of the whitespace from the source document  especially within lists and tables  in order to make it easier to debug the output document.</para></listitem></itemizedlist>\r
366 \r
367 \r
368 <para/></section><section><title>Design Notes</title>\r
369 <para/><section id="docbook-namespace"><title>The Docbook Namespace</title>\r
370 <para><literal>html2db.xsl</literal> accepts elements in the "Docbook namespace" in XHTML\r
371 source.  This namespace is <literal>urn:docbook</literal>.</para>\r
372 \r
373 <para>This isn't technically correct.  Docbook doesn't really have a\r
374 namespace, and if it did, it wouldn't be this one.  <ulink url="http://www.faqs.org/rfcs/rfc3151.html">RFC 3151</ulink> suggests\r
375 <literal>urn:publicid:-:OASIS:DTD+DocBook+XML+V4.1.2:EN</literal> as the\r
376 Docbook namespace.</para>\r
377 \r
378 <para>There two problems with the RFC 3151 namespace.  First, it's long\r
379 and hard to remember.  Second, it's limited to Docbook v4.1.2 \r
380 but <literal>html2db.xsl</literal> works with other versions of Docbook too, which would\r
381 presumably have other namespaces.  I think it's more useful to\r
382 <emphasis role="em">under</emphasis>specify the Docbook version in the spec for this tool.\r
383 Docbook itself underspecifies the version completely, by avoiding a\r
384 namespace at all, but when mixing Docbook and XHTML elements I find it\r
385 useful to be <emphasis role="em">more</emphasis> specific than that.</para>\r
386 \r
387 <para/></section></section><section><title>History</title>\r
388 <para>The original version of <literal>html2db.xsl</literal> was written by <ulink url="http://osteele.com">Oliver Steele</ulink>, as part of the <ulink url="http://laszlosystems.com">Laszlo Systems, Inc.</ulink> documentation\r
389 effort.  We had a set of custom stylesheets that formatted and added\r
390 linking information to programming-language elements such as\r
391 <literal>classname</literal> and <literal>tagname</literal>, and added\r
392 Table-of-Contents to chapter documentation and numbers examples.</para>\r
393 \r
394 <para>As the documentation set grew, the doc team (John Sundman)\r
395 requested features such as inter-chapter navigation, callouts, and\r
396 index and glossary elements.  I was able to beat all of these back\r
397 except for navigation, which seemed critical.  After a few days trying\r
398 to implement this, I decided it would be simpler to convert the subset\r
399 of XHTML that we used into a subset of Docbook, and use the latter to\r
400 add navigation.  (Once this was done, the other features came for\r
401 free.)</para>\r
402 \r
403 <para>During my August 2004 "sabbatical", I factored the general html2db\r
404 code out from the Laszlo-specific code, refactored and otherwise\r
405 cleaned it up, and wrote this documentation.</para>\r
406 \r
407 <para/></section><section><title>Credits</title>\r
408 <para><literal>html2db.xsl</literal> was written by <ulink url="http://osteele.com">Oliver Steele</ulink>, as part of the <ulink url="http://laszlosystems.com">Laszlo Systems, Inc.</ulink> documentation effort.</para>\r
409 \r
410 <para/></section></section></article>