XML Schema validation tool?

At the office we are currently writing an application that will generate XML files against a schema that we were given. We have the schema in an .XSD file.

Are there tool or libraries that we can use for automated testing to check that the generated XML matches the schema?

We would prefer free tools that are appropriate for commercial use although we won’t be bundling the schema checker so it only needs to be usable by devs during development.

Our development language is C++ if that makes any difference, although I don’t think it should as we could generate the xml file and then do validation by calling a separate program in the test.

After some research, I think the best answer is stdinparse utility can be used to call Xerces from the command line.

I assume the Java and C versions of Xerces agree on validation.

Alternatively, if you are on Windows, you can use [DDJ article]( If someone has a simple script that can be called from a DOS prompt, perhaps they'd like to post it.

You could also use xmllint, which is part of [libxml]( You may well already have it installed. It can be used like:

xmllint --noout --schema XSD_FILE XML_FILE

One problem is that libxml doesn't implement all of the specification, so you may run into issues :(

Finally, you'll find different programs will, unfortunately, give different results. This is largely due to the complexity of the XSD spec. You may want to test your schema with several tools.