2. Specifying which RELAX NG schema to use for validating a document

This section is just a primer. The reference documentation about this topic is really XMLmind XML Editor - Configuration and Deployment.

2.1. The relaxng configuration element

A document type declaration (<!DOCTYPE>) can be used to associate a DTD to a document. Attributes xsi:schemaLocation/xsi:noNamespaceSchemaLocation can be used to associate W3C XML Schemas to a document. But there is no standard way to associate a RELAX NG schema to a document. Therefore this association must be made using an external specification such as the Namespace Routing Language (NRL).

In the case of XMLmind XML Editor, this external specification is simply a configuration element called relaxng.

XHTML example:

<configuration name="XHTML Strict [RELAX NG]"
  xmlns:html="http://www.w3.org/1999/xhtml"
  xmlns="http://www.xmlmind.com/xmleditor/schema/configuration">
  <include location="xxe-config:schema/ns_xhtml.incl" />

  <detect>
    <rootElementNamespace>http://www.w3.org/1999/xhtml</rootElementNamespace>
  </detect>

  <relaxng location="xxe-config:common/rng/xhtml1/xhtml-strict.rng" />1

  <preserveSpace elements="html:pre html:style html:script" />2

  <css name="XHTML" location="xhtml_rng.css" />
  <template name="Page" location="page.html" />
</configuration>

1

The relaxng configuration element specifies the location of the RELAX NG schema (XML syntax or compact syntax) to which conforms the document being opened.

2

Unlike the DTD, xhtml-strict.rng does not specify a preserve default value for attribute xml:space of elements such as pre. Therefore, the preserveSpace configuration element must be used to specify whitespace-preserving elements.

2.2. The <?xxe-relaxng-schema> processing instruction

The following processing instruction is a non standard, proprietary, way to associate a document to a RELAX NG schema. Its use should be restricted to testing and other quick and dirty experiments.

DocBook example:

<?xml version="1.0" encoding="UTF-8" ?>
<?xxe-relaxng-schema name="-//OASIS//RELAX NG DocBook V4.3//EN"1
  location="http://www.docbook.org/rng/4.3/docbook.rnc" 
  compactSyntax="true" encoding="US-ASCII" ?>

<!DOCTYPE article [2

<!ENTITY % sgml.features "IGNORE">
<!ENTITY % xml.features "INCLUDE">

<!ENTITY euro "&#x20AC;">

<!ENTITY % dbcent PUBLIC
"-//OASIS//ENTITIES DocBook Character Entities V4.3//EN"
"http://www.oasis-open.org/docbook/xml/4.3/dbcentx.mod">
%dbcent;

]>

<article>
  <title></title>
  <section>
    <title></title>
    <para></para>
  </section>
</article>

1

The <?xxe-relaxng-schema> processing instruction has pseudo-attributes identical to the attributes of the relaxng configuration element.

2

Using a RELAX NG schema should not prevent you from specifying a document type declaration for character entities.