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 resource f with schema file s. The resource may be a full URI or a local file name.

For example, this rule would associate file with schema xyz.rnc:

  <uri resource="" uri="xyz.rnc"/>

<uri pattern="p" uri="s"/>

Like the previous form, but p may contain one or more wild-card characters “*”.

For example, this rule would associate all files ending in .xyz with schema xyz.rnc:

  <uri pattern="*.xyz" uri="xyz.rnc"/>

<uri pattern="p" typeId="T"/>

A rule of this form associates any URI matching pattern p with type identifier T. See Section 4.2, “Type identifiers and how they work”.

<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. Example:

  <documentElement localName="horses" uri="horse.rnc"/>

This will associate any file whose root element is horses with schema file horse.rnc.

<documentElement prefix="N" localName="E" typeId="T"/>

Like the preceding form, but it associates the matching files with type identifier T; see Section 4.2, “Type identifiers and how they work”. Examples:

  <documentElement localName="stylesheet" typeId="XSLT"/>
  <documentElement prefix="xsl" localName="transform" typeId="XSLT"/>

The first example will associate any file whose root element is stylesheet with type XSLT. The second example associates any file whose root element is xsl:transform with that same type code.

<transformURI fromPattern="p" toPattern="q"/>

If a file has a name of the form “p”, try to match a schema file whose name is “q”. The patterns may contain one or more * characters. For each * in pattern p, the text that matches the * will be substituted for the corresponding * in pattern q.

Here's an example. The following rule means that for any file ending in “.xml”, if there is a schema by the same name ending with “.rnc”, use that schema.

  <transformURI fromPattern="*.xml" toPattern="*.rnc"/>

So for example if you have a file named “horses.xml” and a schema file “horses.rnc”, the above locating rule would associate them.

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

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

<namespace ns="N" typeId="T"/>

Like the previous form, but files in namespace N will be associated with type id T.

<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.