Francois Perrad


dtd2db - Generate a DocBook documentation from a DTD


dtd2db [-d] [-C | -M] [-HZ] [-o filename] [-t title] [-x 'example1.xml example2.xml ...'] [-l language | -p path] file.xml



Suppress all comments.


Suppress date generation.


Generate a clean DTD (without comment).


Disable generation of links in comments.


Display help.


Specify the language of templates ('en' is the default).


Suppress multi comments, preserve the last.


Specify the output.


Specify the path of templates.


Specify the title of the DocBook files.


Display Version.


Include a list of XML files as examples.


Delete zombi element (e.g. without parent).


dtd2db is a front-end for XML::Handler::Dtd2DocBook and its subclasses. It uses them to generate XML DocBook documentation from DTD source.

Because it uses XML::Parser and an external DTD is not a valid XML document, the input source must be an XML document with an internal DTD or an XML document that refers to an external DTD.

The goal of this tool is to increase the level of documentation in DTD and to supply a more readable format for DTD.

It is a tool for DTD users, not for writer.

All comments before a declaration are captured.

All entity references inside attribute values are expanded.

This tool needs XML::SAX::Base, XML::SAX::Exception, XML::SAX::Expat, XML::Parser, HTML::Template modules and XML::Handler::Dtd2Html.


XML files (and DTD) can include comments. The XML syntax is :

 <!-- comments -->

All comments before a declaration are captured (except with -M option). Each comment generates its own paragraph <para>.

dtd2db Tags

dtd2db parses tags that are recognized when they are embedded within an XML comment. These doc tags enable you to autogenerate a complete, well-formatted document from your XML source. The tags start with an @. A tag with two @ forces a link generation if the option -H is set.

Tags must start at the beginning of a line.

The special tag @BRIEF puts its value in 'Name' section.

The special tag @INCLUDE allows inclusion of the content of an external file.

   @Version : 1.0
   @INCLUDE : description.txt
   @@See Also : REC-xml

The special tag @HIDDEN don't put the data in the documentation.

The special tag @TITLE before <!DOCTYPE> has the same effect as the option -t.

The special tag @SAMPLE allows inclusion of a XML fragment from an external file.

   @SAMPLE ex2 : ex2.xml

The special tags are case insensitive.

generated files

dtd2db generates a collection of files. Two files need attention.


This is the DocBook entry point. It could be use as example for your own need :


This file concentrates all textual descriptions as entities. These entities are initialized by DTD comments if exists.

But this file could be manually modified after generation.

So unlike with dtd2html, adding comments directly in the DTD is not mandatory.

DocBook transformations

These transformation needs :

DocBook XML DTD 4.2


DocBook XSL Stylesheets






For example : -o ppd -x sample.ppd entry.ppd
 xsltproc -o ppd.html --novalid \some-where\docbook-xsl\xhtml\docbook.xsl ppd.xml

 xsltproc --novalid \some-where\docbook-xsl\xhtml\chunk.xsl ppd.xml

 xsltproc --novalid \some-where\docbook-xsl\htmlhelp\htmlhelp.xsl ppd.xml
 hhc htmlhelp.hhp

 xsltproc -o --novalid \some-where\docbook-xsl\fo\docbook.xsl ppd.xml
 fop -fo -pdf ppd.pdf

HTML Templates

XML design and Perl programming are decoupling. And a language switch option is available.

So, translation of the templates are welcome.


XML::Handler::Dtd2Html , dtd2html


Francois PERRAD,


(c) 2003 Francois PERRAD, France. All rights reserved.

This program is distributed under the Artistic License.