Next / Previous / Contents / Shipman's homepage

4.2. Type identifiers and how they work

If you are writing a general-purpose schema locating file, type identifiers declared using typeId rules can be most useful.

Here's an example. Suppose you want all files ending in .html, and all files that use the XHTML namespace URI, to use the XHTML Strict schema. You could use <uri pattern="*.html" xhtml-strict.rnc/> and namespace rules that refer directly to the XHTML Strict schema. However, consider this fragment of a schema locating file:

    <uri pattern="*.html" typeId="XHTML" />
    <namespace ns="http://www.w3.org/1999/xhtml"
               typeId="XHTML" />
    <typeId id="XHTML" typeId="XHTML Strict"/>
    <typeId id="XHTML Strict"
            uri="xhtml-strict.rnc"/>
    <typeId id="XHTML Transitional"
            uri="xhtml-transitional.rnc"/>

The first rule associates all files ending in .html with type ID "XHTML".

The second rule associates all files with default namespace "http://www.w3.org/1999/xhtml" with type ID "XHTML".

The third rule defines type ID "XHTML" as the equivalent of another type ID "XHTML Strict".

The last two rules relates type IDs "XHTML Strict" and "XHTML Transitional" to specific schema files.

The advantage to this indirect linking of rules to schema is that, if you want to, you can change from XHTML Strict to XHTML Transitional by changing the third line to:

    <typeId id="XHTML" typeId="XHTML Transitional"/>