I have following Xml schema.
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:simpleType name="type">
<xs:restriction base="xs:string">
<xs:enumeration value="Type 1" />
<xs:enumeration value="Type 2" />
<xs:enumeration value="Type 3" />
</xs:restriction>
</xs:simpleType>
<xs:element name="Root">
<xs:complexType>
<xs:sequence>
<xs:element name="Element_1">
<xs:complexType>
<xs:sequence>
<xs:element name="TypeName" type="type" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="Element_2">
<xs:complexType>
<xs:sequence>
<xs:element name="TypeName" type="type" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
I am validating following xml against the above schema.
<?xml version="1.0" encoding="utf-8"?>
<Root>
<Element_1>
<TypeName>Type 4</TypeName>
</Element_1>
<Element_3>
<TypeName>Type 2</TypeName>
</Element_3>
</Root>
I am expecting a validation error and I get one: The 'TypeName' element is invalid - The value 'Type 4' is invalid according to its datatype 'type' - The Enumeration constraint failed. The element 'Root' has invalid child element 'Element_3'. List of possible elements expected: 'Element_2'.
The Error message clearly shows the invalid elements (Element_3) and also displays list of possible valid elements (Element_2). Is it possible to display the valid list of 'TypeName'.
Now, I want error message similar to the one below: The 'TypeName' element is invalid - The value 'Type 4' is invalid according to its datatype 'type'. List of possible values expected: 'Type 1, Type 2' - The Enumeration constraint failed. The element 'Root' has invalid child element 'Element_3'. List of possible elements expected: 'Element_2'.
Is it possible to get above error message (or similar). Does any other restrictions other than xs:enumeration show all the valid values?
System.Xml.Schema
namespace, but I'm not sure they're detailed enough to be able to get the possible values given a target element. I would be interested to see how you get onβ¦ β Richard