TOP

convert.dtd2xsd

Description

Convert a DTD into XSD
Based on Trang Manual

Based on Version 20081028

DTD input module

This input module accepts DTDs as defined by the XML 1.0 Recommendation.

It accepts the following INPUT parameters:

xmlns=uri Specifies the default namespace, that is the namespace used for unqualified element names.
xmlns:prefix=uri Specifies the namespace for the element and attribute names using prefix.
colon-replacement=chars Replaces colons in element names by chars when constructing the names of definitions used to represent the element declarations and attribute list declarations in the DTD. Trang generates a definition for each element declaration and attlist declaration in the DTD. The name of the definition is based on the name of the element. In RELAX NG, the names of definitions cannot contain colons. However, in the DTD, the element name may contain a colon. By default, Trang will first try to use the element names without prefixes. If this causes a conflict, it will instead replace the colon by a legal name character (it try first to use a period).
element-define=name-pattern Specifies how to construct the name of the definition representing an element declaration from the name of the element. The name-pattern must contain exactly one percent character. This percent character is replaced by the name of element (after colon replacement) and the result is used as the name of the definition.
inline-attlist Specifies not to generate definitions for attribute list declarations and instead move attributes declared in attribute list declarations into the definitions generated for element declarations. This is the default behavior when the output module is xsd. Otherwise, the default behaviour is as described in the nonline-attlist parameter.
nonline-attlist Generates a distinct definition (with combine="interleave") for each attribute list declaration in the DTD; the definition for each element declaration references the definition for the corresponding attribute list declaration. This is the default behavior, except when the output module is xsd, for which the default behavior is as described in the inline-attlist parameter.
attlist-define=name-pattern This specifies how to construct the name of the definition representing an attribute list declaration from the name of the element. The name-pattern must contain exactly one percent character. This percent character is replaced by the name of element (after colon replacement) and the result is used as the name of the definition.
any-name=name Specifies the name of the definition generated for the content of elements declared in the DTD as having a content model of ANY.
strict-any Preserves the exact semantics of ANY content models by using an explicit choice of references to all declared elements. By default, Trang uses a wildcard that allows any element.
annotation-prefix=prefix Default values are represented using an annotation attribute prefix:defaultValue where prefix is bound to http://relaxng.org/ns/compatibility/annotations/1.0 as defined by the RELAX NG DTD Compatibility Committee Specification. By default, Trang will use a for prefix unless that conflicts with a prefix used in the DTD.
generate-start
no-generate-start Specifies whether Trang should generate a start element. DTDs do not indicate what elements are allowed as document elements. Trang assumes that all elements that are defined but never referenced are allowed as document elements.

W3C XML Schema output module

This output module outputs an W3C XML Schema as defined by the XML Schema Recommendation.

It supports the following OUTPUT parameters:

encoding=name Use an encoding of name for the output files.
indent=n Indent by n spaces for each indentation level.
disable-abstract-elements Disables the use of abstract elements and subsitution groups in the generated XML Schema. This can also be controlled using an annotation attribute.
any-process-contents=strict|lax|skip Specifies the value for the processContents attribute of any elements. The default is skip (corresponding to RELAX NG semantics) unless the input format is dtd, in which case the default is strict (corresponding to DTD semantics).
any-attribute-process-contents=strict|lax|skip Specifies the value for the processContents attribute of anyAttribute elements. The default is skip (corresponding to RELAX NG semantics).

It has the following limitations:

Annotations can be added to the RELAX NG schema to guide the translation. These annotations have the namespace URI http://www.thaiopensource.com/ns/relaxng/xsd. This document will use the convention that the prefix tx refers to this namespace URI; in other words, it will assume a namespace declaration of

xmlns:tx="http://www.thaiopensource.com/ns/relaxng/xsd"

Currently, only one annotation is supported, an attribute tx:enableAbstractElements. The value of this must be true or false. It applies to RELAX NG define elements. Trang has the ability to translate a define that contains a choice of element patterns into an abstract element declaration, which will be used as the head of a substitution group whose members are the elements in the choice. Whether it does this is determined by the value of the tx:enableAbstractElements annotation attribute. If the value is true, it will attempt to use an abstract element element. If the value is false, it will not, which means the define will typically be translated into a group definition.

The tx:enableAbstractElements attribute is inherited in a similar way to the ns attribute: it can be specified on a grammar, div or include element to enable or disable the use of abstract elements for all descendant define elements. In the absence of any inherited tx:enableAbstractElements attribute, the use of abstract elements is enabled unless the disable-abstract-elements option was specified.

It can happen that the same element name occurs in a choice in more than one define element; at most one of these define elements can be translated to an abstract element. In this case, Trang will not translate any of them to an abstract element, unless the use of abstract elements has been disabled by tx:enableAbstractElements for all except one of the define elements.

In fact, the use of abstract elements is not restricted to the case where the define consists of a choice that contains only element patterns; the choice may also contain ref patterns referring to definitions that are to be translated into element declarations, whether abstract or not. The tx:enableAbstractElements attribute applies equally to these definitions.

Convert a DTD into an XSD

Implementation class

net.mdatools.modelant.uml13.reverse.task.Dtd2XsdTask

Parameters

Attribute Description Type
outputFile the target schema to build String

Nested elements

Element Description
inputParam provides string parameter(s) to the input converter
Any nested text Any textual value of the parameter
inputSchema lists the DTDs to convert. At least one source DTD should be provided
Any nested text Any textual value of the parameter
outputParam provides string parameter(s) to the output converter
Any nested text Any textual value of the parameter

Use <typedef resource="net/mdatools/modelant/uml13/reverse/antlib.xml"/>
Documentation generated by ant.doc Ant macro from ModelAnt by MDA Tools