Resources for Converting DTDs
Converting a DTD to an XML Schema by hand is still the best way to ensure that the new Schema you end up with most accurately fits your demands. It is also the best way to consider new features that moving to an XML Schema might allow you to implement. As you work your way through conversion, you can add features such as datatypes to make your XML Schema more robust, allowing you to place very specific constraints on the element or attribute content in an XML document.
However, sometimes it is handy just to have an automated conversion process, or to use an automated process to perform the base conversion so that you can then go in and add new features and clean up the converted Schema. As more software becomes XML Schemaaware, automated conversions will become easier. However, in the meantime, here are some resources for automatic conversion between DTDs and XML Schema.
DTD2Schema
The DTD2Schema project is a Perl script that automates the conversion of DTDs into XML Schema. The project is located at
http://www.w3.org/2000/04/schema_hack/
The site features an explanation of how the Perl script performs the conversion. Because the script is written in Perl, it has the flexibility of running under Windows, Unix, or any system that has a Perl implementation available. Figure 3.1 shows the DTD2Schema Web site with information about the script.
Figure 3.1 A Perl script resource for converting DTDs into XML Schema.
If you are familiar with Perl, this script can be a good resource. It allows users to automate the conversion of DTDs into Schema, which can be nice if you are converting a large number of DTDs. Of course, as with any conversion process, it isn't perfect, but it can serve as a good starting point for converting your DTDs.
XML Authority
For those users who are not familiar with Perl, or who are more comfortable using a GUI application for conversion, there is XML Authority, from TIBCO Extensibility. XML Authority is an application for schema design that actually converts between many different types of schema, not just DTDs and XML Schema.
A trial version of the application can be downloaded from its Web site at
http://www.extensibility.com/tibco/solutions/xml_authority/index.htm
The application, shown in Figure 3.2, allows you to open a DTD and then export the file to an XML Schema.
Figure 3.2 XML Authority from TIBCO Extensibility converts DTDs into Schema and other formats.
Again, although the conversion might not be perfect, it is a good starting place for converting DTDs into XML Schema. And one advantage of using an application like XML Authority is that once you have converted the file, you can then continue to use the application for customization of the XML Schemaschema as well.