Validating ZeeRex Records

27th February 2004

It is useful to validate ZeeRex records against the appropriate version of the SGML or XML DTD, or XML Schema. This can be done using tools such as xmllint.

In order to validate against a DTD or Schema, you need either a local copy of that DTD or a stable URL for the copy on the Internet. The URLs of the ZeeRex specifications may be considered stable and are as follows, for any given version:

In order to indicate that a ZeeRex XML record complies with a particular version of the ZeeRex XML DTD, then, a prologue like the following may be used:

<?xml version="1.0" ?>
<!DOCTYPE explain SYSTEM
	"http://explain.z3950.org/dtd/zeerex-2.0.xml.dtd">
<explain ...
  

The formal public identifier (FPI) for any given version of the ZeeRex DTD (both SGML and XML incarnations) is -//explain.z3950.org//DTD ZeeRex version//EN

So DOCTYPE declarations may also use PUBLIC name strings, like this:

<?xml version="1.0" ?>
<!DOCTYPE explain PUBLIC "-//explain.z3950.org//DTD ZeeRex 2.0//EN"
	"http://explain.z3950.org/dtd/zeerex-2.0.xml.dtd">
<explain ...
  

Both these forms allow validation using commands such as

xmllint --valid --noout whatever.xml
Or if you find yourself needing to validate a ZeeRex document that does not specify its own DTD, many tools will let you do so by explicitly telling them where the DTD is:
xmllint --dtdvalid http://explain.z3950.org/dtd/zeerex-2.0.xml.dtd --noout whatever.xml

It is also possible to validate ZeeRex documents against the XML Schema: for example, using xmllint like this:

xmllint --schema zeerex-2.0.xsd --noout whatever.xml
However, if you do this using a libxml2-based tool such as xmllint, you will need version 2.6.8 or later of the library, as a bug in earlier versions prevents it from understanding mixed content as used by the ZeeRex Schema.

Feedback to <mike@indexdata.com> is welcome!