6. Associating a schema to the opened document

In the configuration based on the DTD, a document is assumed to always start with:

<!DOCTYPE section PUBLIC "-//XMLmind//DTD Simple Section//EN"
"http://www.xmlmind.com/dtd/section.dtd">

therefore the "-//XMLmind//DTD Simple Section//EN" DTD is automatically associated to the opened document. This DTD is then used to validate the document and also let XXE perform its schema-directed editing.

However there is no facility equivalent to <!DOCTYPE> for RELAX NG schemas, therefore this association must be specified in the configuration file. Excerpts from rng_section_config/section.xxe (configuration based on RELAX NG):

<relaxng location="section.rnc" />

The relaxng element allows to associate a RELAX NG schema to the opened document. Similarly, the schema element allows to associate a W3C XML Schema to the opened document and the dtd element allows to associate a DTD to the opened document. Note that the relaxng, schema and dtd elements are completely ignored by XXE when the opened document contains a reference to its schema (i.e. by the means of <!DOCTYPE>, xsi:schemaLocation, <?xml-model>).

For example, let's suppose that, unlike what is shown in the template.xml file below, in the configuration based on the XML Schema, the section root element does not have an xsi:schemaLocation attribute (which, by the way, is somewhat cleaner), then specifying:

<schema>
  <location>http://www.xmlmind.com/ns/sect 
            section.xsd</location>
</schema>

would have been mandatory.

File xsd_section_config/template.xml (configuration based on XML Schema):

<section xmlns="http://www.xmlmind.com/ns/sect"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://www.xmlmind.com/ns/sect
                             http://www.xmlmind.com/xsd/section.xsd">
  <title></title>
  <paragraph></paragraph>
</section>