This is ../../info/nxml-mode, produced by makeinfo version 4.11 from nxml-mode.texi. This manual documents nxml-mode, an Emacs major mode for editing XML with RELAX NG support. Copyright (C) 2007, 2008, 2009, 2010 Free Software Foundation, Inc. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or any later version published by the Free Software Foundation; with no Invariant Sections, with the Front-Cover texts being "A GNU Manual," and with the Back-Cover Texts as in (a) below. A copy of the license is included in the section entitled "GNU Free Documentation License" in the Emacs manual. (a) The FSF's Back-Cover Text is: "You have the freedom to copy and modify this GNU manual. Buying copies from the FSF supports it in developing GNU and promoting software freedom." This document is part of a collection distributed under the GNU Free Documentation License. If you want to distribute this document separately from the collection, you can do so by adding a copy of the license to the document, as described in section 6 of the license. INFO-DIR-SECTION Emacs START-INFO-DIR-ENTRY * nXML Mode: (nxml-mode). XML editing mode with RELAX NG support. END-INFO-DIR-ENTRY  File: nxml-mode, Node: Top, Next: Completion, Up: (dir) nXML Mode ********* This manual documents nxml-mode, an Emacs major mode for editing XML with RELAX NG support. Copyright (C) 2007, 2008, 2009, 2010 Free Software Foundation, Inc. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or any later version published by the Free Software Foundation; with no Invariant Sections, with the Front-Cover texts being "A GNU Manual," and with the Back-Cover Texts as in (a) below. A copy of the license is included in the section entitled "GNU Free Documentation License" in the Emacs manual. (a) The FSF's Back-Cover Text is: "You have the freedom to copy and modify this GNU manual. Buying copies from the FSF supports it in developing GNU and promoting software freedom." This document is part of a collection distributed under the GNU Free Documentation License. If you want to distribute this document separately from the collection, you can do so by adding a copy of the license to the document, as described in section 6 of the license. This manual is not yet complete. * Menu: * Completion:: * Inserting end-tags:: * Paragraphs:: * Outlining:: * Locating a schema:: * DTDs:: * Limitations::  File: nxml-mode, Node: Completion, Next: Inserting end-tags, Prev: Top, Up: Top 1 Completion ************ Apart from real-time validation, the most important feature that nxml-mode provides for assisting in document creation is "completion". Completion assists the user in inserting characters at point, based on knowledge of the schema and on the contents of the buffer before point. The traditional GNU Emacs key combination for completion in a buffer is `M-'. However, many window systems and window managers use this key combination themselves (typically for switching between windows) and do not pass it to applications. It's hard to find key combinations in GNU Emacs that are both easy to type and not taken by something else. `C-' (i.e. pressing the Enter or Return key, while the Ctrl key is held down) is available. It won't be available on a traditional terminal (because it is indistinguishable from Return), but it will work with a window system. Therefore we adopt the following solution by default: use `C-' when there's a window system and `M-' when there's not. In the following, I will assume that a window system is being used and will therefore refer to `C-'. Completion works by examining the symbol preceding point. This is the symbol to be completed. The symbol to be completed may be the empty. Completion considers what symbols starting with the symbol to be completed would be valid replacements for the symbol to be completed, given the schema and the contents of the buffer before point. These symbols are the possible completions. An example may make this clearer. Suppose the buffer looks like this (where -!- indicates point): <-!- In this case, the symbol to be completed is empty, and the possible completions are `base', `isindex', `link', `meta', `script', `style', `title'. Another example is: <-!- `C-' will yield ' will yield: ' again, which would have the result described in the next item. * If there is more than one possible completion, but the possible completions do not share a non-empty prefix, then Emacs will prompt you to input the symbol in the minibuffer, initializing the minibuffer with the symbol to be completed, and popping up a buffer showing the possible completions. You can now input the symbol to be inserted. The symbol you input will be inserted in the buffer instead of the symbol to be completed. Emacs will then insert any required characters after the symbol. For example, if it contains: This says to use the schema `xhtml.rnc' for a document with namespace `http://www.w3.org/1999/xhtml', and to use the schema `docbook.rnc' for a document whose local name is `book'. If the document element had both a namespace URI of `http://www.w3.org/1999/xhtml' and a local name of `book', then the matching rule that comes first will be used and so the schema `xhtml.rnc' would be used. There is no precedence between different types of rule; the first matching rule of any type is used. As usual with XML-related technologies, resources are identified by URIs. The `uri' attribute identifies the schema by specifying the URI. The URI may be relative. If so, it is resolved relative to the URI of the schema locating file that contains attribute. This means that if the value of `uri' attribute does not contain a `/', then it will refer to a filename in the same directory as the schema locating file.  File: nxml-mode, Node: Using the document's URI to locate a schema, Next: Using the document element to locate a schema, Prev: Schema locating file syntax basics, Up: Schema locating files 5.2.2 Using the document's URI to locate a schema ------------------------------------------------- A `uri' rule locates a schema based on the URI of the document. The `uri' attribute specifies the URI of the schema. The `resource' attribute can be used to specify the schema for a particular document. For example, specifies that the schema for `spec.xml' is `docbook.rnc'. The `pattern' attribute can be used instead of the `resource' attribute to specify the schema for any document whose URI matches a pattern. The pattern has the same syntax as an absolute or relative URI except that the path component of the URI can use a `*' character to stand for zero or more characters within a path segment (i.e. any character other `/'). Typically, the URI pattern looks like a relative URI, but, whereas a relative URI in the `resource' attribute is resolved into a particular absolute URI using the base URI of the schema locating file, a relative URI pattern matches if it matches some number of complete path segments of the document's URI ending with the last path segment of the document's URI. For example, specifies that the schema for documents with a URI whose path ends with `.xsl' is `xslt.rnc'. A `transformURI' rule locates a schema by transforming the URI of the document. The `fromPattern' attribute specifies a URI pattern with the same meaning as the `pattern' attribute of the `uri' element. The `toPattern' attribute is a URI pattern that is used to generate the URI of the schema. Each `*' in the `toPattern' is replaced by the string that matched the corresponding `*' in the `fromPattern'. The resulting string is appended to the initial part of the document's URI that was not explicitly matched by the `fromPattern'. The rule matches only if the transformed URI identifies an existing resource. For example, the rule would transform the URI `file:///home/jjc/docs/spec.xml' into the URI `file:///home/jjc/docs/spec.rnc'. Thus, this rule 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.  File: nxml-mode, Node: Using the document element to locate a schema, Next: Using type identifiers in schema locating files, Prev: Using the document's URI to locate a schema, Up: Schema locating files 5.2.3 Using the document element to locate a schema --------------------------------------------------- A `documentElement' rule locates a schema based on the local name and prefix of the document element. For example, a rule specifies that when the name of the document element is `xsl:stylesheet', then `xslt.rnc' should be used as the schema. Either the `prefix' or `localName' attribute may be omitted to allow any prefix or local name. A `namespace' rule locates a schema based on the namespace URI of the document element. For example, a rule specifies that when the namespace URI of the document is `http://www.w3.org/1999/XSL/Transform', then `xslt.rnc' should be used as the schema.  File: nxml-mode, Node: Using type identifiers in schema locating files, Next: Using multiple schema locating files, Prev: Using the document element to locate a schema, Up: Schema locating files 5.2.4 Using type identifiers in schema locating files ----------------------------------------------------- Type identifiers allow a level of indirection in locating the schema for a document. Instead of associating the document directly with a schema URI, the document is associated with a type identifier, which is in turn associated with a schema URI. nXML mode does not constrain the format of type identifiers. They can be simply strings without any formal structure or they can be public identifiers or URIs. Note that these type identifiers have nothing to do with the DOCTYPE declaration. When comparing type identifiers, whitespace is normalized in the same way as with the `xsd:token' datatype: leading and trailing whitespace is stripped; other sequences of whitespace are normalized to a single space character. Each of the rules described in previous sections that uses a `uri' attribute to specify a schema, can instead use a `typeId' attribute to specify a type identifier. The type identifier can be associated with a URI using a `typeId' element. For example, declares three type identifiers `XHTML' (representing the default variant of XHTML to be used), `XHTML Strict' and `XHTML Transitional'. Such a schema locating file would use `xhtml-strict.rnc' for a document whose namespace is `http://www.w3.org/1999/xhtml'. But it is considerably more flexible than a schema locating file that simply specified A user can easily use `C-c C-s C-t' to select between XHTML Strict and XHTML Transitional. Also, a user can easily add a catalog that makes the default variant of XHTML be XHTML Transitional.  File: nxml-mode, Node: Using multiple schema locating files, Prev: Using type identifiers in schema locating files, Up: Schema locating files 5.2.5 Using multiple schema locating files ------------------------------------------ The `include' element includes rules from another schema locating file. The behavior is exactly as if the rules from that file were included in place of the `include' element. Relative URIs are resolved into absolute URIs before the inclusion is performed. For example, includes the rules from `rules.xml'. The process of locating a schema takes as input a list of schema locating files. The rules in all these files and in the files they include are resolved into a single list of rules, which are applied strictly in order. Sometimes this order is not what is needed. For example, suppose you have two schema locating files, a private file followed by a public file The effect of these two files is that the XHTML `namespace' rule takes precedence over the `transformURI' rule, which is almost certainly not what is needed. This can be solved by adding an `applyFollowingRules' to the private file.  File: nxml-mode, Node: DTDs, Next: Limitations, Prev: Locating a schema, Up: Top 6 DTDs ****** nxml-mode is designed to support the creation of standalone XML documents that do not depend on a DTD. Although it is common practice to insert a DOCTYPE declaration referencing an external DTD, this has undesirable side-effects. It means that the document is no longer self-contained. It also means that different XML parsers may interpret the document in different ways, since the XML Recommendation does not require XML parsers to read the DTD. With DTDs, it was impractical to get validation without using an external DTD or reference to an parameter entity. With RELAX NG and other schema languages, you can simulataneously get the benefits of validation and standalone XML documents. Therefore, I recommend that you do not reference an external DOCTYPE in your XML documents. One problem is entities for characters. Typically, as well as providing validation, DTDs also provide a set of character entities for documents to use. Schemas cannot provide this functionality, because schema validation happens after XML parsing. The recommended solution is to either use the Unicode characters directly, or, if this is impractical, use character references. nXML mode supports this by providing commands for entering characters and character references using the Unicode names, and can display the glyph corresponding to a character reference.  File: nxml-mode, Node: Limitations, Prev: DTDs, Up: Top 7 Limitations ************* nXML mode has some limitations: * DTD support is limited. Internal parsed general entities declared in the internal subset are supported provided they do not contain elements. Other usage of DTDs is ignored. * The restrictions on RELAX NG schemas in section 7 of the RELAX NG specification are not enforced. * Unicode support has problems. This stems mostly from the fact that the XML (and RELAX NG) character model is based squarely on Unicode, whereas the Emacs character model is not. Emacs 22 is slated to have full Unicode support, which should improve the situation here.  Tag Table: Node: Top1356 Node: Completion2734 Node: Inserting end-tags7042 Node: Paragraphs8357 Node: Outlining10612 Node: Locating a schema16222 Node: Commands for locating a schema17664 Node: Schema locating files20282 Node: Schema locating file syntax basics21170 Node: Using the document's URI to locate a schema23057 Node: Using the document element to locate a schema25577 Node: Using type identifiers in schema locating files26638 Node: Using multiple schema locating files29049 Node: DTDs30872 Node: Limitations32332  End Tag Table