App developer

How I Validate XML Files on a Mac

There’s no other way to state this: validating XML files manually is a massive pain in the ass. Luckily, you can use xmllint to validate an XML file against an XSD. This is what I used when coding FATCA Metadata Creator to ensure that the generated XML file was valid.

The process is simple, just run this command in terminal:

xmllint --noout --schema ~/PATH/Schema.xsd file.xml

If the file validates successfully, you’ll see a message that reads file.xml validates. Otherwise, if the file doesn’t validate, you’ll see an error message telling you where the failure occurred:

Schemas validity error : Element '{urn:fatca:idessenderfilemetadata}FileRevisionInd': 'falsey' is not a valid value of the atomic type 'xs:boolean'.
file.xml fails to validate