Validate XMLs against XSDs
Posted: Sat Jul 23, 2016 11:16 pm
This HowTo describes how to validate XML files, using XML Schema Definition (XSD) files, using "xmllint".
Here's the basic commandline:
To make things more interesting, I'll use a somewhat real-world example of a METS Metadata XML export - cmmon in long-term preservation context.
Let's say we have the following set of files:
If everything is fine, the result should be:
Here's the basic commandline:
Code: Select all
$ xmllint --noout --schema $XSD_FILE $XML_FILE
To make things more interesting, I'll use a somewhat real-world example of a METS Metadata XML export - cmmon in long-term preservation context.
Let's say we have the following set of files:
- metadata_mets.xml
- mets.xsd
Code: Select all
$ xmllint --noout --schema mets.xsd metadata_mets.xml
If not, you will receive information about what/where in the XML file does not validate against the given XSD.metadata_mets.xml validates