O'Reilly logo

Office 2003 XML by Evan Lenz, Mary McRae, Simon St. Laurent

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

How Do I Convert DTDs and RELAX NG to XSD?

Whether you’re working with legacy schemas or simply prefer to work in these simpler frameworks, you need to convert these forms to XSD for work in Office. As noted earlier, Trang, available from http://www.thaiopensource.com/relaxng/trang.html, offers an extremely easy path from DTDs or RELAX NG to XSD. At its core, Trang is a simple command-line utility that takes XML sample documents, DTDs, RELAX NG, RELAX NG Compact syntax, or XSD and converts them into DTDs, RELAX NG, RELAX NG Compact syntax, or XSD. For working with Office, you’ll mostly be converting DTDs and RELAX NG to XSD, though perhaps you’ll want to convert XSD to other forms to use with other systems.

Warning

RELAX NG is more expressive than XSD in a number of ways. If you really take advantage of RELAX NG, the limitations of XSD will be fairly apparent, and Trang can’t convert all of RELAX NG’s capabilities to XSD. If you stick with the subset shown in this appendix, however, you should not encounter such losses.

The basic syntax for using Trang looks like:

java -jar trang.jar sourceFile 
            destinationFile

By default, the kind of transformation Trang performs depends on the file extensions of the source and destination files, shown in Table D-3.

Table D-3. File extensions used by Trang

File extension

Meaning

.xsd

W3C XML Schema (XSD) file (output only)

.dtd

XML 1.0 Document Type Definition (DTD)

.rng

RELAX NG file, XML syntax

.rnc

RELAX NG file, compact syntax

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required