Sunday, January 2, 2011

Validating XML against a Schema (XSD)

Notepad++
Notepad++ has an optional plugin to allow you to validate an XML file against an XSD (this is good because it is a free "gratis" tool).

First, download and install Notepad ++ here

Download and add XML tools plugin for Notepad ++ here

Download the ExternalTools.zip as well from the sourceforge link above and extract the contents to the Notepad++ install folder.

Restart Notepad ++

Open XML file to validate, Click Plugins | XML Tools | Validate now

A window will pop up with errors or validation successfully completed message.


jEdit
jEdit also has optional plugin to validate XML against an XSD.

First download jEdit here

Open jEdit and click Plugins | Plugin Manager

Check the box for XML plugin, click install button

Open the XML file, validation errors appear as red underlines.

Also in jEdit you can open Plugins | XML | Parse as XML will open a window and show a tree navigation of the XML jumping to the first error found if any.

cygwin
An optional package to install in cygwin is called libXML2, this package includes a command line tool named xmllint which can also validate XML against an XSD
$ xmllint --schema /cygdrive/c/path/to/xsd/myschema.xsd /cygdrive/c/path/to/xml/myxml.xml

About Me

My photo
Lead Java Developer Husband and Father

Tags