Validating against xsd schema
Also, a commenter below points to this more complete wrapper utility.
You could also use xmllint, which is part of libxml. Example usage: One problem is that libxml doesn't implement all of the specification, so you may run into issues :( Alternatively, if you are on Windows, you can use msxml, but you will need some sort of wrapper to call it, such as the GUI one described in this DDJ article.
In addition you also get support for Schematron and Relax NG. Update 1/13/2012: The command line tool is free to use and uses Xerces as XML parser. But if you are missing an attribute in the XML you just get a message saying the element can not be validated.
The following code example adds an XML Schema, Head Count.xsd, to the Xml Schema Collection and validates Head
Message) End Sub ' Validation Handler End Class ' Sample End Namespace ' Validation Sample Dim tr As New Xml Text Reader("sample4.xml") Dim vr As New Xml Validating Reader(tr) vr.
XML Schema or Relax NG schema also allows you to embed Schematron rules.
For Schematron validations you can also select the validation phase.
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 Xerces, as it implements all of XSD, is cross-platform and widely used.
At the office we are currently writing an application that will generate XML files against a schema that we were given. 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.
Are there tool or libraries that we can use for automated testing to check that the generated XML matches the schema?
The schema type can be: XML Schema, Relax NG (full or compact syntax), Schematron, Document Type Definition (DTD), or Namespace-based Validation Dispatching Language (NVDL).Tags: Adult Dating, affair dating, sex dating