A key feature of XML markup is that you validate it. The DocBook schema is a precise description of valid nesting: the order of elements, and their content. All DocBook documents must conform to this description or they are not DocBook documents (by definition). The validation technology that is built into XML is the Document Type Definition or DTD. A validating parser is a program that can read the DTD and a particular document and determine whether the exact nesting and order of elements in the document is valid according to the DTD.
DocBook is now defined by a RELAX NG grammar and Schematron rules, so it is no longer necessary to validate with the DTD. In fact, it isn’t even very valuable since the DTD version doesn’t enforce many DocBook constraints. Instead, an external RELAX NG and Schematron validator must be used.
Validation is performed on a document after it has been parsed. It is possible for parsing errors to occur as well as validation errors (if, for example, your document isn’t well-formed XML). We’re going to assume that your documents are well-formed and not discuss XML parsing errors.
If you are not using a structured editor that can provide guidance on the markup as you type, validation with an external tool is a particularly important step in the document creation process. You cannot expect to get rational results from subsequent processing (such as document publishing) if your documents are not valid.
There are several free validators that will handle RELAX NG and Schematron, including Jing and MSV. For more detail about available tools, see XML Tools.
In XML, attributes of type ID and IDREF
provide a straightforward cross-referencing mechanism. In DocBook, the
xml:id
attribute contains values of
type ID, and the linkend
attribute
contains values of type IDREF.
Within any document, no two attributes of type ID may have the same value. In addition, for any attribute of type IDREF, there must be one, and only one, instance of an attribute of type ID with the same value in the same document. In other words, you can’t have two elements with the same ID, and every IDREF must match an ID that exists somewhere in the same document.
Checking these constraints is not a core part of RELAX NG. If you
want RELAX NG to check them, you need to enable a set of “DTD
compatibility” extensions. Unfortunately, the DTD compatibility
extensions do not work well with the DocBook grammar. However, because
DocBook uses xml:id
for its ID
attribute, it’s not necessary to enforce the constraints with RELAX NG.
You can either tell your processor not to perform the DTD compatibility
extension checks, or ignore the warning messages that they produce. You
could also use Schematron to check ID/IDREF constraints.
3.136.233.153