I have XML that includes an element that has the attribute: xsi:type="AnswerBool". My xsd has that element and has set up an attribute with the name="type" and then restricts the enumeration values to "AnswerBool" (and others). However, when I try to validate the XML it fails. If I change the XML so that the element uses type rather than xsi:type all is well.
XML:
<Answer xsi:type="AnswerBool">
-1
XSD:
<xs:element name="Answer" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="Value">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute name="type">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="xsd:int"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="type" use="optional">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="AnswerBool"/>
<xs:enumeration value="AnswerMsc2DTO"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:complexType>
</xs:element>
I tried to name the "type" attribute to "xsi:type" but I am not allowed to have a ':' in the name. Unfortunately I cannot update the XML to NOT use "xsi:" before "type". I know what I am doing is basically some sort of work around to allow multiple different types for my "Answer" element. So I might be pushing things too far to get this all to work. However...
Does anyone have any ideas as to how I can get my XML to validate?
I mean is there a way to include the "xsi:" in my attribute's name or perhaps is there a way to have the validation process only look at the "type" part and ignore the "xsi:"?