I want to validate an xml document with an xsd reference document. I am
able to validate the tags but not the values. Here is an example:
I define the following type:
<xsd:simpleType name="Sample">
<xsd:restriction base="xsd:string">
<xsd:enumeration value="Double" />
<xsd:enumeration value="Integer" />
</xsd:restriction>
</xsd:simpleType>
That type I use later like this:
<xsd:element name="Type" type="Sample" minOccurs="1" maxOccurs="1" />
Validating <BadTag>Double</Typefails because of the opening tag.
Validating <Type>BadValue</Typesucceeds.
With the restriction for the type "Sample" should this not give an
error? How do I validate the actual values?
Here is the code I am using for validation:
XmlReaderSettings settings = new XmlReaderSettings();
settings.Schemas.Add("Sample.xsd", xsdFile);
settings.ValidationEventHandler += new
ValidationEventHandler(OnValidationError);
settings.ValidationType = ValidationType.Schema;
XmlDocument doc = new XmlDocument();
doc.Load(XmlReader.Create(xmlFile, settings));
Thanks