Next / Previous / Contents / TCC Help System / NM Tech homepage

4.1. Schema locating rules

Here is a list of the rules that can appear in a schema locating file:

<uri resource="f" uri="s"/>

Associate XML file f with schema file s.

<uri pathSuffix=".p" uri="s"/>

Associate files whose names end in .p with schema file s.

<documentElement prefix="N" localName="E" uri="s"/>

If a document's root element is E in namespace N, use schema file s.

If you omit the namespace identifier prefix="N", this rule matches by document element regardless of the namespace.

If you omit the element name prefix="E", this rule will match all root elements in namespace N, if given. If both prefix and localName attribute are omitted, it matches all documents.

<transformURI pathSuffix=".p" replacePathSuffix=".q"/>

If a file has a name of the form “f.p”, try to match a schema file whose name is “f.q”.

<transformURI pathAppend=".q"/>

If a file has a name of the form “f”, try to match a schema file whose name is “f.q”.

<namespace ns="N" uri="s"/>

If the file's root element has the same namespace URI as N, use schema s.

<typeId id="T" uri="s"/>

Defines a new type ID T , and says to use schema s for rules that refer to that type ID. A type ID name is an arbitrary string you make up to describe a document type (schema).

In any of the rules that have a uri="s" attribute, you can instead use a typeId="T" attribute. Assuming you have defined the type ID T, the rule will use the schema related to that type ID.

<typeId id="T" typeId="U"/>

Defines a type ID named T as the same as type ID U.

<include rules="F"/>

Includes another schema locating file F.

<applyFollowingRules ruleType="R"/>

This rule instructs emacs to immediately search all the remaining schema locating files in its list (the value of its rng-schema-locating-files variable), and apply all rules of type R.

For example, suppose you want to use the transform rewrite rules of type <transformURI> that are in the files after this one in the sequence of schema locating files. You can't just use the <include> rule, because if any rule in the later files matches, it will win. So instead you use this rule:

    <applyFollowingRules ruleType="transformURI"/>

If emacs gets to this rule without a match, it will then go and apply all the <transformURI> rules from later files, using them to rewrite the pathname if appropriate. Then matching continues in the current file, using the rewritten pathname.