Copyright © 2002 Thai Open Source Software Center Ltd
See the file copying.txt for copying permission.
Trang translates schemas written in RELAX NG into different formats. In particular, it can
Trang aims to produce human-understandable schemas; it tries for a translation that preserves all aspects of the input schema that may be significant to a human reader, including the definitions, the way the schema is divided into files, annotations and comments.
The implementation is available for download as
The main class is
com.thaiopensource.relaxng.output.Driver
.
Trang requires at least two command-line arguments: the first is the URI or filename of the schema to be translated; the second is the output filename.
Trang infers the input and output format from the extension of input and output filenames as follows:
.rng
.rnc
.dtd
This inference can be overridden using the -i
and
-o
options.
Trang accepts the following command-line options:
-i format
format
specifies the input format as follows:
rng
rnc
-o format
format
specifies the output format
as follows:
rng
dtd
-e enc
enc
for schema input and
output.The DTD output module of Trang has many limitations. There are many RELAX NG features that it cannot handle, including:
element
patterns with the same nameexternalRef
include
)combine="choice"
However, Trang can handle many RELAX NG features, including some
that go beyond the capabilities of DTDs. When some part of a RELAX NG
schema cannot be represented exactly in DTD, Trang will try to
approximate it. The approximation will always be more general,
that is, the DTD will allow everything that is allowed by the RELAX NG
schema, but there may be some things that are allowed by the DTD that
are not allowed by the RELAX NG schema. For example, if the RELAX NG
schema specifies that the content of an element is a string conforming
to some datatype, then Trang will make the content of the element be
(#PCDATA)
; or if the RELAX NG schema specifies a choice
between two attributes x and y, then the DTD
will allow both x and y optionally. Whenever
Trang approximates, it will give a warning message.
If you want to be able to generate a DTD but need to use some feature of RELAX NG that Trang is unable to convert into a DTD, then you might try one of the following approaches:
include
s
S1, and overrides definitions in
S1 replacing them with definitions that make
unrestricted use of the features of RELAX NG.Trang is constructed around a RELAX NG object model designed to support schema conversion. Trang can support additional input and output formats simply by adding modules that convert these formats from and to this object model.
Features planned for future releases include:
DTDinst translates from DTDs into RELAX NG; like Trang, it tries for a translation that preserves definitions and file structure. Trang can handle all the features in RELAX NG schemas generated by DTDinst.
The Sun RELAX NG Converter converts from a variety of different schema languages into RELAX NG. However, it is based on an object model which is designed to support validation, and so does not preserve aspects of the input schemas that are irrelevant for validation (such as the definitional structure).
James Clark