Reputation: 23
I have classes generated from an xsd schema with xsd.exe. I don't have control over the schema. Reading, writing with XmlSerlializer and validation of the serialized data works just fine. I'd like to implement on-line error checking for my data what includes user input, based on the rules in the schema. Again I have no problem serializing and validating against, but then I see no easy way of tracking back the location of the fault, in which instance of which class did it occur. I found a comment mentioning that the reason for no XmlValidatingWriter exist is that the classes should already ensure schema compatibility, however this is not true for the xsd.exe generated classes. (structure and types are good but unique fields, patter matches etc. are not covered) There is a page about XmlSchemaValidator push-based validation but this seems super manual to me totally ignoring the fact that all of my classes are xml serializable.
I found similar questions but nobody seems to have this particular goal, nor I could find an answer that would lead me to a solution. I'm ok concluding this is not possible for some reason -as it looks to me now- but I'd like to understand the reason and get to know where my whole architecture went wrong.
Thank you.
Upvotes: 1
Views: 344
Reputation: 23
Ok, here is what I ended up doing. I'm not proud of it.
Probably highly inefficient but for the size of the data I'm working with it's ok.
Upvotes: 1