Click to See Complete Forum and Search --> : Problem with Enumerations.


lclarkjr
November 11th, 2003, 12:14 PM
If I try to validate the xml listed below with the xsd listed below using MSXML 4.0 (sp2 or sp1) and SAX2 the validation fails. It appears that MSXML 4.0 does not like the fact that two of the enumerations defined in the xsd have double spaces in them. If i remove one of the double spaces in "Test 2" and "Test 3" enumeration values the file validates just fine.

Has anyone else seen this behaviour and is there a way to fix it other than changing the XSD file. I have do not have much if any control over the xml and xsd file that i will be parsing.

Note that XML SPY does not have a problem validating this example.

XML:

<?xml version="1.0" encoding="UTF-8"?>
<!--Sample XML file generated by XMLSPY v5 rel. 4 U (http://www.xmlspy.com)-->
<element1 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="C:\Temp\oos\Untitled11.xsd">
<test1>Test 1</test1>
<testelement>test</testelement>
</element1>


XSD:

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:simpleType name="TestEnumType">
<xs:restriction base="xs:token">
<xs:enumeration value="Test 1"/>
<xs:enumeration value="Test 2"/>
<xs:enumeration value="Test 3"/>
</xs:restriction>
</xs:simpleType>
<xs:element name="element1">
<xs:annotation>
<xs:documentation>Comment describing your root element</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:all>
<xs:element name="testelement"/>
<xs:element name="test1" type="TestEnumType"/>
</xs:all>
</xs:complexType>
</xs:element>
</xs:schema>

erwin_78
November 12th, 2003, 02:49 AM
That's because you're using xs:token as a base for your accepted data (<xs:restriction base="xs:token">). If i remember correctly a token may not contain spaces try using xs:string instead.