Should I use a unit testing framework to validate XML documents?
- by christofr
From http://www.w3.org/XML/Schema:
[XML Schemas] provide a means for defining the structure, content and semantics of XML documents.
I'm using an XML Schema (XSD) to validate several large XML documents. While I'm finding plenty of support within XSD for checking the structure of my documents, there are no procedural if/else features that allow me to say, for instance,
If Country is USA, then Zipcode cannot be empty.
I'm comfortable using unit testing frameworks, and could quite happily use a framework to test content integrity.
Am I asking for trouble doing it this way, rather than an alternative approach? Has anybody tried this with good / bad results?
--
Edit: I didn't include this information to keep it technology agnostic, but I would be using C# / Linq / xUnit for deserialization / testing.