5. Specifying which configuration to use for a given document type

The detect element allows to specify which configuration to use for a given document type.

It works as follows: when XXE opens a document, it evaluates in turn the detect element found in each configuration. When all the conditions found in a detect element are met, XXE stops its evaluations and associates the configuration containing the matching detect element to the document being opened.

Excerpts from rng_section_config/section.xxe (configuration based on RELAX NG):

<detect>      
  <rootElementNamespace>http://www.xmlmind.com/ns/sect</rootElementNamespace>
</detect>

The above detect element reads as: if the namespace of the root element of the file being opened is "http://www.xmlmind.com/ns/sect", then its configuration is rng_section_config/section.xxe.

The above detect element could be used as well for the configurations based on the DTD and the W3C XML Schema. However, in order to show you that there are often several ways to detect a document type, we have used a different detect condition in the configuration based on DTD:

<detect>      
  <dtdPublicId>-//XMLmind//DTD Simple Section//EN</dtdPublicId>
</detect>