Validating XML against XSD on a Mac

Nobody likes to document APIs and webservices. It looks like that a typical set of SOAP documentation contains of just two things: an URL pointing to a WSDL document and an XSD schema file. Sometimes it also includes a good luck wish but not always. It usually works fine although it takes more time to figure out how to approach it without having documentation ready, so I am just ranting.

So, you dug all the smelly legacy data you want to use and transformed it into something edible.
You are almost there. Your XML file looks fine at first sight and you want to start pounding the webservice with your requests. How can you be sure that your XML meets the schema requirements? OS X includes libxml which comes with xmllint to help you.

To validate your XML:

1. Open your terminal application
2. Run xmllint (use your own xml and xsd filenames):

xmllint --noout --schema soap.xsd soap.xml

If your XML fails you will see something like that:

3. Fix your XML and make sure it doesn’t fail.
4. You are set