Schema languages in technical documentation

Article image Schema languages for technical documentation

23. November 2021

What are schema languages for technical documentation?

Schema languages define sets of rules for XML documents and describe the structure and content of these documents syntactically. The defined set of rules thus ensures that the XML document is valid, i.e. consists of correct, standardized and machine-readable information units.

There are grammar-based and rule-based schema languages: DTD, XML Schema and Relax NG belong to the grammar-based schema languages. They can be used to define elements and attributes and specify data types. The defined content models determine the order, frequency and hierarchy in which an element may be used. Schematron, on the other hand, is a rule-based schema language. It can be used to formulate additional conventions that supplement the grammatical rules of an XML application.

The most important schema languages in detail

DTD (Document Type Definition) simply explained

A document type definition (DTD) is a set of rules that describes the logical structure of a document with elements, attributes, entities and notations. The sequence, arrangement and type of content are defined in a DTD. The number and quality of the elements determines the level of detail of a DTD and therefore the degree of semantics. DTD is the most common syntax for document types.

XML Schema (XSD): Define structure and data types

XML Schema, abbreviated XSD (XML Schema Definition), is also used to define structures in XML documents. Unlike a DTD, the structure itself is described here as an XML document. XML Schema is primarily intended for the exchange between applications (e.g. web services) and data-intensive workflows. DTDs, on the other hand, are better suited to text-heavy applications.

Relax NG: The flexible alternative

The Regular Language Description for XML New Generation, RELAX NG for short, is also a schema language for defining the structure of XML documents and an international standard ISO/IEC 1975-2 within the Document Schema Definition Language. Just like XML Schema, RELAX NG, unlike a DTD, does not use its own syntax, but (optionally) XML-based vocabulary. RELAX NG is more powerful than DTD but less complex than XML Schema and is also suitable for validating elements and attributes in XML documents. RELAX NG arose from the desire to eliminate the disadvantages of DTD and XML Schema: the new schema language should use XML syntax and be lightweight. This has been achieved with RELAX NG.

Schematron: Rules for XML validation

Schematron is a schema language that does not use a formal grammar and is therefore not used to define XML documents (like DTD and XML Schema), but to validate them. It defines rules that are not possible in grammar-based schema languages. Schematron 1.6 has been an official ISO/IEC standard since May 2006. Schematron is a supplement to conventional schema languages. Schematron is now supported by common XML editors. For example, the Oxygen Editor provides a Schematron Quick Fix function that automatically detects and corrects rule violations.

What is the difference between XML Schema and a DTD?

CriterionDTD (Document Type Definition)XML Schema (XSD)
Data typesNo or very limited support for data typesExtensive support for data types (e.g. string, integer, date)
Cardinalities & conditionsOnly simple structure definition possibleExtendable by integrity conditions and detailed cardinalities
NamespacesNo support for namespacesSupports namespaces to avoid name conflicts
SyntaxOwn, non-XML-based syntaxXML-based syntax
ValidationRequires own parserCan be validated with standard XML parsers
Inheritance / type hierarchiesNot possibleSupport of inheritance and type hierarchies
Sequence of elementsStrictly definedSequence-independent structures also possible
SemanticsLow expressive powerHigher semantic expressiveness
Complexity / PowerfulnessSimpler, but less powerfulMore powerful and expressive, especially for data structures
TransformabilityBasis for XML SchemaAny DTD can be transformed into an XML Schema (the reverse is not always possible)

Schema languages in comparison: DTD & Schematron vs. XML Schema

DTD and Schematron vs. XML Schema

We will give you an insight into the various schema languages and categorize the different terms. We address the question of whether there is actually the right schema language for technical documentation and show various scenarios for the use of schema languages and the use of Schematron for validation in two practical examples.

Maximilian Gärber Technical Consultant PANTOPIX

Maximilian Gärber

Technical Consultant | PANTOPIX

We will be happy to inform you regularly about new articles, videos or podcast episodes.

Knowledge

Find out more about networking information

Share this post
Kopiert!

Search

Search