Next: Schema locating files, Up: Locating a schema

### 6.1 Commands for locating a schema

The command `C-c C-s C-w` will tell you what schema is currently being used.

The rules for locating a schema are applied automatically when you visit a file in nXML mode. However, if you have just created a new file and the schema cannot be inferred from the file-name, then this will not locate the right schema. In this case, you should insert the start-tag of the root element and then use the command `C-c C-s C-a`, which reapplies the rules based on the current content of the document. It is usually not necessary to insert the complete start-tag; often just ‘`<name`’ is enough.

If you want to use a schema that has not yet been added to the schema locating files, you can use the command `C-c C-s C-f` to manually select the file containing the schema for the document in current buffer. Emacs will read the file-name of the schema from the minibuffer. After reading the file-name, Emacs will ask whether you wish to add a rule to a schema locating file that persistently associates the document with the selected schema. The rule will be added to the first file in the list specified ‘`rng-schema-locating-files`’; it will create the file if necessary, but will not create a directory. If the variable ‘`rng-schema-locating-files`’ has not been customized, this means that the rule will be added to the file ‘`schemas.xml`’ in the same directory as the document being edited.

The command `C-c C-s C-t` allows you to select a schema by specifying an identifier for the type of the document. The schema locating files determine the available type identifiers and what schema is used for each type identifier. This is useful when it is impossible to infer the right schema from either the file-name or the content of the document, even though the schema is already in the schema locating file. A situation in which this can occur is when there are multiple variants of a schema where all valid documents have the same document element. For example, XHTML has Strict and Transitional variants. In a situation like this, a schema locating file can define a type identifier for each variant. As with `C-c C-s C-f`, Emacs will ask whether you wish to add a rule to a schema locating file that persistently associates the document with the specified type identifier.

The command `C-c C-s C-l` adds a rule to a schema locating file that persistently associates the document with the schema that is currently being used.