
I will on this page describe how I use GNU Emacs as a powerful XML editor using the excellent nxml-mode.
On this page, you'll learn how you can:
Get on the fly syntax checking of your XML code.
Out of the box,nxml-mode will do auto completion
for XHTML and Docbook documents. It can support any other XML
format, as long as it can find anRNC file to
describe it. Here, I'm getting auto completion of elements in
a Mavenpom.xml file:

Emacs will also give you on the fly syntax checking. Here, I am editing an Ant build file, where I've added an illegal attribute:

nxml-mode instists on using the RNC
format. Hence, you need to convert your XSDs and DTDs to RNC,
whichnxml-mode can use.
You need two pieces of software, rngconv
to convert fromXSD to
RNG and trang
to convert fromRNG (or
DTD) to
RNC. As you might have guessed,
rngconv is only needed if you've got an
XSD as Trang can deal with DTDs.
Trang & RNGConv might be available in your system's software repository, such as Debian SID, if not, this is how to install it manually:
$ cd /tmp/
$ wget http://jing-trang.googlecode.com/files/trang-20081028.zip
$ wget https://msv.dev.java.net/files/documents/61/31333/rngconv.20060319.zip
$ cd /opt/
$ unzip /tmp/trang-20081028.zip
$ ln -s trang-20081028 trang
$ unzip /tmp/rngconv.20060319.zip
$ ln -s rngconv.20060319 rngconv
This is how I convert the Maven POM XML Schema to RNC:
$ cd ~/library/xml/
$ wget http://maven.apache.org/maven-v4_0_0.xsd
$ java -jar /opt/rngconv/rngconv.jar maven-v4_0_0.xsd > maven-v4_0_0.rnc
$ java -jar /opt/trang/trang.jar \
-I rng \
-O rnc \
maven-v4_0_0.rng maven-v4_0_0.rnc
This is how I created an RNC for Antbuild.xml
files. First, I created a DTD from wiki.apache.org
$ java -jar /opt/trang/trang.jar -I dtd -O rnc ant-1.6.dtd ant-1.6.rnc
To save you some hassle, you may download my RNC files here.
This is my ~/.emacs.d/schemas.xml
which nxml-mode will look in to find schema mappings outside its
standard set (which includes Docbook, XHTML).