Should I use a unit testing framework to validate XML documents?
Posted
by
christofr
on Programmers
See other posts from Programmers
or by christofr
Published on 2012-03-21T12:02:10Z
Indexed on
2012/03/21
17:38 UTC
Read the original article
Hit count: 215
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.
© Programmers or respective owner