Hi,

I think the problem is that XERCES supports
http://www.w3.org/2001/XMLSchema-instance and u are using 1999 version

I generated a new schema through XMLSPy tool. Just add the following line to
ur xml at census tag
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
xsi:noNamespaceSchemaLocation="census1.xsd"

Now your validation code should work. Baring that a occupant tag is not
closed so, if u are catching Fatalerrors in your ErrorHandler it will
generate the exception you. The new schema is pasted below:

<?xml version="1.0" encoding="UTF-8"?>
<!--W3C Schema generated by XML Spy v4.3 U (http://www.xmlspy.com)-->
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema";
elementFormDefault="qualified">
<xs:complexType name="addressType">
<xs:sequence>
<xs:element ref="number"/>
<xs:element ref="street"/>
<xs:element ref="city"/>
<xs:element ref="province"/>
</xs:sequence>
</xs:complexType>
<xs:element name="age">
<xs:simpleType>
<xs:restriction base="xs:byte">
<xs:enumeration value="22"/>
<xs:enumeration value="52"/>
<xs:enumeration value="61"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="census">
<xs:complexType>
<xs:sequence>
<xs:element ref="censustaker"/>
<xs:element name="address" type="addressType"/>
<xs:element name="occupants" type="occupantsType"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="censustaker" type="xs:short"/>
<xs:element name="city" type="xs:string"/>
<xs:element name="firstname">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="Filbert"/>
<xs:enumeration value="Floyd"/>
<xs:enumeration value="Phylis"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="number" type="xs:short"/>
<xs:complexType name="occupantType">
<xs:sequence>
<xs:element ref="firstname"/>
<xs:element ref="surname"/>
<xs:element ref="age"/>
</xs:sequence>
<xs:attribute name="status" type="xs:string"/>
</xs:complexType>
<xs:complexType name="occupantsType">
<xs:sequence>
<xs:element name="occupant" type="occupantType" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
<xs:element name="province" type="xs:string"/>
<xs:element name="street" type="xs:string"/>
<xs:element name="surname" type="xs:string"/>
</xs:schema>

Regards,
Pavitra Jain

-----Original Message-----
From: Ramin Raybod [mailto:[EMAIL PROTECTED]
Sent: Monday, April 29, 2002 9:22 AM
To: xerces
Subject: An example of schema


Hi,
I'm so new to xml schema and am reading Oreilly "Learning XML" e-book from
"Safari Tech Books Online". There is an example of a schema at the end of
chapter 5 of the book. I tried to validate it by xerces through a sample
validation program called sax.SAXCount. It has too many errors like it is
not a valid schema at all. I guess it is because of version used in this
example - 1999. I compared this with another schema a sample coming with
xerces set - 2001 version . Wow too much difference. How? Is there really no
support for such schema mentioned in this book? or I have problems in using
something?
Anyway I have written the sample schema and the related xml doc here. Oh yes
I had to add some additional code to XML file for linking to the schema
file... I have deleted an attribute also... These are the differences I've
made to the original example of the book :)
Thanks
Ramin


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to