Ok, so I’m trying to validate a xml against a DataSet that represents properties for my project.
The schema addition is done like this:
dataSet d = new dataSet();
schema.add("http://tempuri.org/settings.xsd", XmlReader.Create(new StringReader(d.GetXmlSchema())));
Let’s say my DataSet has two Columns “path” and “version”. Then if I try to validate a xml:
<settings>
<paht>c:\</path>
</settings>
That will validate fine. And I don’t want it to… I wan’t to get an error since there is no “version” entry. So I have looked at what I get from the d.GetXmlSchema() and it looks like a xsd. And all entries contains a property: minOccurs="0"
I’m guessing that I wan’t that to be ="1" but how do I set such an option to the DataSet?
Ok so this solves the problem, but it’s not a nice solution…
So what we need is
"minOccurs="1"but what we have is...="0"so we just do a replace at the string we get from the xml and tada!As I said, not that nice, if you have better suggestions please feel free to add in.