A posting from James Clark to the XML-DEV List announces a new release of Trang, Clark's Multi-Format Schema Converter based on RELAX NG. The conversion tool supports several schema languages for XML, including RELAX NG (XML syntax), RELAX NG compact syntax, XML 1.0 DTDs, W3C XML Schema. With one exception, Trang will convert between any of these formats (W3C XML Schema is supported for output only, not for input). "Trang is written in Java, and available under a BSD-style license. In this release, [Clark has] added an input module for DTDs based on his DTDinst program; this implies that Trang can now convert directly from DTDs to W3C XML Schema (XSD)." Clark identifies three unique features of Trang: "(1) it can reliably turn parameter entities into the higher-level semantic constructs available in XSD (simple types, groups, attribute groups) -- even in the presence of arbitrarily deep nesting of parameter entity references within parameter entity declarations; (2) it supports namespaces, including DTDs that mix multiple namespaces; (3) it can create good-quality, idiomatic XSD, which takes advantage of features such as substitution groups."
Overview
From the announcement:
Although there are other DTD to XSD converters available, Trang has some unique features
It is able to reliably turn parameter entities into the higher-level semantic constructs available in XSD (simple types, groups, attribute groups). It can do this even in the presence of arbitrarily deep nesting of parameter entity references within parameter entity declarations. At the same time, it accurately follows XML 1.0 rules on parameter entity expansion, so that any valid XML 1.0 DTD can be handled. If a parameter entity is used in a way that does not correspond to any of these higher-level semantic constructs (for example parameter entities used to allow a change of namespace prefix in the DTD), then references to that parameter entity are simply expanded.
It supports namespaces, including DTDs that mix multiple namespaces. It interprets DTDs in a namespace-aware way and can automatically create additional files and move declarations between files so as to create valid XML Schemas that accurately capture the intended semantics of the DTD.
It can create good-quality, idiomatic XSD, which takes advantage of features such as substitution groups.
Trang is not limited to converting from DTD to XSD. It supports the following schema languages for XML:
- RELAX NG (XML syntax)
- RELAX NG compact syntax
- XML 1.0 DTDs
- W3C XML Schema
A schema written in any of the supported schema languages can be converted into any of the other supported schema languages, except that W3C XML Schema is supported for output only, not for input.
Trang is constructed around an RELAX NG object model designed to support schema conversion. For each schema language supported for input, there is an input module that can convert from the schema language into this internal object model. Similarly, for each schema language supported for output, there is an output module that can convert from the internal object model in the schema language.
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.
Principal references:
- Announcement 2003-01-22: "Trang: Multi-format Schema Converter."
- Trang website
- Trang Manual
- DTDinst. "Trang's DTD input module uses DTDinst. The Trang binary already includes the necessary parts of DTDinst, so there is no need to download DTDinst just in order to use Trang. DTDinst is also available as an independent program that outputs an XML representation of an XML DTD."
- Clark's RELAX NG website
- Developer: James Clark, Thai Open Source Software Center. See also James Clark's Home Page
- "Converting RELAX NG to W3C XML Schema." By James J. Clark (Director, Thai Open Source Software Center Ltd, Thailand). Presentation given at the XML 2002 Conference, Baltimore, MD, USA. December 11, 2002. 'These are the slides for a talk given at the XML 2002 conference in Baltimore. They have been combined into a single HTML file. The talk was designed to assess how well RELAX NG can be made to work as a mechanism for creating W3C XML Schemas.'
- Prepared abstract for the XML 2002 Conference presentation.
- "Update of Jing and Trang from James Clark." News item 2003-01-08.
- "RELAX NG" - Main reference page.
- "XML Schemas" - Main reference page.