Reputation: 10205
Having a XmlDocument loaded with a XSD schema, how do I get the restrictions for a given node in the document?
I would like to iterate through the document, and automatically correct errors where possible (eg: truncate strings that are too long, remove empty nodes that shouldn't be, etc.)
I am doing this because xsd.exe does not take into account string length restrictions or differentiate between null and empty strings. I'm finding that doing this "post-processing" is simpler than manually trying to ensure these restrictions before serialization.
Upvotes: 1
Views: 227
Reputation: 395
The XmlSchemaValidator class gives you this information. Look at the GetExpectedParticles & GetExpectedAttributes methods of this class.
Upvotes: 1