Copyright © 2001-2003 Thai Open Source Software Center Ltd

See the file copying.txt for copying permission.

Version 2003-01-22

DTDinst is a program for converting XML DTDs into an XML instance format.

Previous versions of DTDinst could also convert XML DTDs into RELAX NG. This functionality has now migrated into Trang, which now shares the DTDinst code.

The key feature of DTDinst is its handling of parameter entities. It is able to reliably turn parameter entity declarations and references into a variety of higher-level semantic constructs. It can do this even in the presence of arbitrarily deep nesting of parameter entity references within parameter entity declarations. At the same time, it accurately follows XML 1.0 rules on parameter entity expansion, so that any valid XML 1.0 DTD can be handled. If a parameter entity is used in a way that does not correspond to any of the higher-level semantics constructs supported by DTDinst, then references to that parameter entity will be expanded in the DTDinst output.

Getting DTDinst

DTDinst is available as a precompiled JAR file. The source is also available.

You also need to have a Java runtime environment installed on your system.

Running DTDinst

To run DTDinst, use a command of the form:

java -jar dtdinst.jar DTD

The DTD argument can be either a file or a URL.

DTDinst writes an XML representation of the DTD in DTDinst format to the standard output. For example, the command

java -jar dtdinst.jar http://www.w3.org/XML/1998/06/xmlspec-v21.dtd >xmlspec.xml

would write an XML representation of the W3C xmlspec DTD to the file xmlspec.xml.

DTDinst format

The DTDinst format is designed to represent the parameterization of the DTD as fully as possible.

There is a schema for this format in RELAX NG compact syntax; the schema is also available in RELAX NG format.

Each parameter entity declaration is represented by one of the following elements:

The element used to represent a parameter entity reference depends on the element used to represent the declaration of the parameter entity.

An XSLT stylesheet is available that converts DTDinst format to RELAX NG. It has many more limitations than the converter builtin to DTDinst, but it may be useful as a basis for XSLT-based processing of DTDinst format.

Sample DTDs

You may find it interesting to experiment with the following XML DTDs which are available online:


DTDinst does not attempt to understand the contents of ignored conditional sections: DTDinst format represents the contents of an ignored section as a string. If you wish to preserve information about conditional sections, you should therefore make as many conditional sections as possible be included marked sections rather than ignored marked sections. You can do this by creating a wrapper DTD that declares parameter entities as INCLUDE and then references the real DTD. For example, you might use this wrapper DTD to convert the TEI P4 DTD.

DTDinst does not attempt to understand the contents of parameter entities that are never referenced.

Reporting bugs

Please send bug reports to jjc@thaiopensource.com. Be sure to include a complete DTD for which DTDinst exhibits the bug.

James Clark