DTD Compatibility Datatypes
DTD compatibility is both a library
that checks the lexical spaces of its
ID
,
IDREF
, and
IDREFS
datatypes and a more expansive
feature. This library adds to the normal RELAX NG processing and
enforces DTD-like rules on the schema and on the instance document.
This package is designed to facilitate the transition from DTDs to
RELAX NG by emulating the attribute types ID
,
IDREF
, and IDREFS
. The DTD
compatibility feature checks whether ID
values are
unique within a document and that IDREF
and
IDREFS
are references or whitespace-separated
lists of references to ID
values defined in the
document. It also checks the schema itself to ensure that datatypes
are used only in attributes. Unlike their W3C XML Schema counterpart,
these datatypes have no facets.
That’s pretty much all you have to know about this
library. Let’s use it straightaway to define the
id
attributes in our library:
<element xmlns="http://relaxng.org/ns/structure/1.0" name="library" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes"> <oneOrMore> <element name="book"> <attribute name="id"> <data datatypeLibrary="http://relaxng.org/ns/compatibility/datatypes/1.0" type="ID"/> </attribute> <attribute name="available"> <data type="boolean"/> </attribute> <element name="isbn"> <data type="NMTOKEN"> <param name="pattern">[0-9]{9}[0-9x]</param> </data> </element> <element name="title"> <attribute name="xml:lang"> <data type="language"> <param name="length">2</param> </data> </attribute> ...
Get RELAX NG now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.