Node:Using the document's URI to locate a schema, Next:, Previous:Schema locating file syntax basics, Up:Schema locating files



Using the document's URI to locate a schema

A uri rule locates a schema based on the URI of the document. The resource attribute specifies the URI of the document. The uri attribute specifies the URI of the schema. For example,

<uri resource="spec.xml" uri="docbook.rnc"/>

specifies that that the schema for spec.xml is docbook.rnc.

A uri rule may use a pathSuffix attribute instead of a resource attribute to locate a schema based on the suffix of the URI. It considers only the path component of the URI. In terms of files, it is equivalent to matching on the file extension. For example,

<uri pathSuffix=".xsl" uri="xslt.rnc"/>

specifies that the schema for documents whose URI ends with .xsl is xslt.rnc.

A transformURI rule locates a schema by transforming the URI of the document. The rule matches only if the transformed URI exists. If there is a pathSuffix attribute, then the path component of the document's URI must end with the specified suffix. If there is a pathAppend attribute, then the URI is transformed by appending the specified string to the URI's path component. For example,

<transformURI pathAppend=".rnc"/>

specifies that to locate a schema for a document foo, Emacs should test whether a file foo.rnc exists in the same directory as foo, and, if so, should use it as the schema. If there is a replacePathSuffix attribute, then the URI is transformed by replacing the suffix matched by the pathSuffix attribute by the value of the replacePathSuffix attribute. A transformURI rule matches only if the transformed URI is a valid URI that identifies an existing resource. For example,

<transformURI pathSuffix=".xml" replacePathSuffix=".rnc"/>

specifies that to locate a schema for a document foo.xml, Emacs should test whether a file foo.rnc exists in the same directory as foo.xml, and, if so, should use it as the schema.