Name

pydtd2xsd — convert XML Document Type Declarations to XML Schema

Synopsis

pydtd2xsd [--dtd-file file] [--repr-file file] [--use-repr-file] [--ns-uri prefix URI...] [--ns-schema-file prefix file...] [--no-ns-workaround]

Description

pydtd2xsd converts XML Document Type Declarations into XML Schemata. It can handle DTDs that use complex entity substitutions, XML namespace prefixes for several namespaces, and are distributed over several files.

Options

--dtd-file file

Read the DTD from file. Note, however, that use of the --use-repr-file or --repr-file options may supress reading the DTD file.

--repr-file file

Read the compiled DTD from file. Implies --use-repr-file.

Warning

Since the compiled DTD is stored as Python code, this means that any Python code that somehow ended up in file will be evaluated!

--use-repr-file

Attempt to read the DTD from a precompiled DTD representation file, or, if this file does not exist, generate it. If --repr-file is not given the filename will be determined by replacing the .dtd suffix of the DTD file with .prp. This can save a great deal of time.

Warning

Since the compiled DTD is stored as Python code, this means that any Python code that somehow ended up in the representation file will be evaluated!

--ns-uri prefix URI

Associate the namespace prefix prefix with the namespace URI URI. If prefix is None then the namespace URI will be associated with elements that do not have a prefix. If URI is None, which is only permissible if prefix is also None, then elements without a prefix will not be associated with a namespace.

--ns-schema-file prefix file

Write the XML Schema file for the namespace with the associate prefix prefix to file. If prefix is None then the XML Schema file for elements with no prefix (which may or may not be associated with a namespace, see --ns-uri) will be written to file.

--no-ns-workaround

For DTDs that mix elements associated with a namespace with elements not associated with a namespace, normally the elements not associated with a namespace are imported by the other XML Schemata by <xsd:import schemaLocation='file'>. With this option an additional namespace='' attribute will be generated which seems to violate the XML Schema specification, but is necessary to make the schemata work with certain programs, such as Syntext Serna.

Usage

In order to make schema files for a DTD that mixes namespaceless TEI with MathML, we could invoke pydtd2xsd thus: pydtd2xsd --dtd-file math-tei.dtd --ns-uri None None --ns-uri math http://www.w3.org/1998/Math/MathML --ns-schema-file None math-tei.xsd --ns-schema-file math mathml.xsd

Author

Oliver M. Haynold

Bugs

Namespaces should be inferred from xmlns:xxx attribute declarations with fixed values in the DTD.

There is no support for notations.

The must be a 1:1 mapping of prefixes to namespaces across the DTD.

Copyright

pydtd2xsd is copyright (c) 2004 by Oliver M. Haynold.

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA