Which Library Should Be Used?
All the RELAX NG implementations must support the native
datatype library; many of them also support the DTD compatibility
datatypes library and the W3C XML Schema datatypes library. That
means that if you want to define a token
or
string
datatype, you can often choose between the
native library and W3C XML Schema datatypes, and if
you’re defining ID
,
IDREF
, or IDREFS
, you can often
choose between the DTD compatibility library and W3C XML Schema
datatypes.
Native Types Versus W3C XML Schema Datatypes
The criteria for choosing between native or
W3C XML Schema datatypes to define
string
and token
types is
simple: if you need facets, use W3C XML Schema datatypes. If you
don’t, use native datatypes: your schema will be
more portable, because the RELAX NG processors
aren’t obliged to support the W3C XML Schema type
library.
DTD Versus W3C XML Schema Datatypes
When you need to define a datatype covered by both
DTD and W3C XML Schema—i.e.,
ID
, IDREF
, or
IDREFS
—a similar rule of thumb applies. If
you use the DTD compatibility library, your schema should be slightly
more portable, but you will lose the facets.
The other factor to take into account is that the rules applied when you use the DTD compatibility feature are strict and consistent over different implementations; when you use the W3C XML Schema type library, a processor should apply these same rules if and only if it also supports the DTD datatype library. Processors that support only W3C XML Schema datatypes ...
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.