nXML mode

nXML mode is an addon for GNU Emacs, which makes GNU Emacs into a powerful XML editor. It's called nXML mode because in Emacs terminology addons that customize Emacs for editing text of a particular sort are called modes. Emacs already has a simple mode for XML; nXML mode is a new mode for XML.

You should realize that Emacs with nXML mode differs from most XML editors in that XML is edited as text. What you see while you are editing is similar to what you would see if you were using a non-XML aware text editor. nXML mode does not attempt to conceal the XML tags. The big advantage is that you do not lose any functionality in moving from a text editor to nXML mode. All normal text editing commands can be used with nXML mode without restriction. nXML mode does not require that the XML document always be valid or even well-formed.

nXML mode allows a schema to be associated with the XML document being edited. The schema is used to provide two key features:

Continuous validation. nXML validates as you type, highlighting any invalid parts of your document.

Completion. nXML can assist you in entering an element name, attribute name or data value by using information about what is allowed by the schema in that context.

nXML mode uses Relax NG as its schema language. Relax NG has two alternative syntaxes: an XML syntax and a more readable, non-XML compact syntax. nXML mode supports the compact syntax. There are tools available to translate from DTDs and other schema languages into Relax NG compact syntax. Schemas for DocBook, XHTML, XSLT, RDF and RELAX NG are included in the nXML mode download.

nXML mode can also be used without any schema. Features that work without any schema include support for inserting end-tags easily.

nXML mode is implemented entirely in Emacs Lisp (Emacs' builtin extension language). This allows nXML mode to work on any platform that Emacs supports, without any modifications to Emacs. It consists of approximately 17,000 lines of Emacs Lisp.

Requirements

GNU Emacs version 21.x is required, preferably 21.3. Emacs 20 will not work, nor will XEmacs.

Download

nXML mode can be downloaded from http://www.thaiopensource.com/download/. Look for a file with a name of the form nxml-mode- YYYYMMDD .tar.gz . After downloading, extract the files from the .tar.gz archive and read the README file for how to get started.

Mailing list

emacs-nxml-mode mailing list at Yahoo! Groups

Further information about nXML mode

Information about Relax NG

Packages

Debian unstable package from Chris Lawrence

RPMs from Tim Waugh

Fink package (for Darwin and Mac OS X) from Rohan Lloyd

TEI Emacs packages GNU Emacs, nxml-mode and other useful stuff in a single bundle suitable for installation on any Windows 32 or Unix/Linux system

GNU Emacs

Trang by James Clark allows RELAX NG XML syntax schemas and DTDs to be converted to the Relax NG compact syntax supported by nxml-mode; it can also infer a schema from an instance document

RNV by David Tolpin is a Relax NG validator in ANSI C, which supports the Relax NG Compact Syntax

XML Unicode by Norman Walsh is an Emacs package that provides some convenience methods for inserting Unicode charaters

nxml-script by Peter Heslin helps with editing code inside XHTML <script> elements by allowing you to narrow down to the script fragment, use the appropriate major mode, and then switch back

elements by allowing you to narrow down to the script fragment, use the appropriate major mode, and then switch back Relax NG grammar for XSLT 2.0 by Norman Walsh and a blog on how to use this to validate either XSLT 1.0 or XSLT 2.0 stylesheets

rngconv, by Kohsuke Kawaguchi, a tool based on the MSV library which can convert from XSD (W3C XML Schema) to RELAX NG XML syntax

RNC mode, by David Rosenborg, an Emacs mode for editing RELAX NG Compact Syntax schemas

Last updated: 2004-10-14