I like it because it contains just 3 small (less than 30 lines total) helper methods, one helper schema and most of the unit tests are just 2-3 lines.
So, let’s say we need to write a schema for Xml files that have a structure like this: and that both Service Provider and Factory elements are optional. For new schemas I usually create a sample Xml file, open it in Visual Studio and use Xml → Create Schema.
The schema created by the VS is not really usable but gives me something I can iterate on.
The main problem with the generated schema is that all the types are defined inline.
It was a good starting point but then I asked myself – “how do I test this”.
I needed something lightweight that would fit in our unit tests.
I briefly searched the Internet but could not find anything that would be suitable.
As the old saying goes, necessity is mother of invention, so I came up with my own way of testing the schema.
Once in a while a new task no-one is really eager to work on pops-up.
From my experience in teams that are not focusing on or use extensively Xml related technologies most (if not all) tasks that have anything to do with XSD schemas belong to this group.
This was the case in our team recently and I ended up to be a “volunteer” since the schedule was tight and I previously worked on the managed Xml team.
So, I started refreshing my rusted XSD skills and soon I got something that more or less worked.