XML Tips

Validating with DTD

In Debian 5.0 (Lenny) install the sp package and use the nsgmls command.

In Emacs the sgml-mode (or xml-mode) has a sgml-validate command, which runs nsgmls from the sp package.

Validating with XSD

  1. Download msv.yyyymmdd.zip from the MSV Download site. The download link's are hidden away in the left side-bar, under 'Documents & files'

  2. Validate an XML file that uses an XSD with:

    $ java -jar msv.jar my.xsd my.xml


In Debian 5.0 (Lenny) install the nxml-mode package.

Next we need to convert XSD schemas to RELAX NG

  1. Download rngconv.zip from the MSV Download site. It's probably only available under Nightly builds

  2. Unzip it somewhere sensible and convert the XSD to RELAX NG as follows:

    $ java -jar rngconv.jar my.xsd >my.rng
  3. Download [Tring][] from the Jing/Trang project page

  4. Now convert it to the RELAX NG compact format

    $ java -jar trang.jar my.rng my.rnc
  5. Load an XML document to validate. Enter the Emacs command rng-set-schema-file-and-validate and select the location of the .rnc file.

Note: If you get file not found type errors when using these tools, read the error message carefully. It's quite likely an include file that is missing.


Related Topics: EmacsTips

-- Frank Dean - 17 Apr 2010