|
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
The xsd file :
<?xml version="1.0"
encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/1999/XMLSchema">
<xsd:annotation>
<xsd:documentation> Census form for the Republic of Oz Department of Paperwork, Emerald City </xsd:documentation> </xsd:annotation> <xsd:element name="census"
type="CensusType"/>
<xsd:complexType
name="CensusType">
<xsd:element name="censustaker" type="xsd:decimal" minoccurs="0"/> <xsd:element name="address" type="Address"/> <xsd:element name="occupants" type="Occupants"/> </xsd:complexType> <xsd:complexType
name="Address">
<xsd:element name="number" type="xsd:decimal"/> <xsd:element name="street" type="xsd:string"/> <xsd:element name="city" type="xsd:string"/> <xsd:element name="province" type="xsd:string"/> <xsd:attribute name="postalcode" type="PCode"/> </xsd:complexType> <xsd:simpleType name="PCode"
base="xsd:string">
<xsd:pattern value="[A-Z]-d{3}"/> </xsd:simpleType> <xsd:complexType
name="Occupants">
<xsd:element name="occupant" minOccurs="1" maxOccurs="50"> <xsd:complexType> <xsd:element name="firstname" type="xsd:string"/> <xsd:element name="surname" type="xsd:string"/> <xsd:element name="age"> <xsd:simpleType base="xsd:positive-integer"> <xsd:maxExclusive value="200"/> </xsd:simpleType> </xsd:element> </xsd:complexType> </xsd:element> </xsd:complexType> </xsd:schema>
The xml file :
<census xmlns:xsd="http://www.w3.org/1999/XMLSchema-instance"
xsd:noNamespaceSchemaLocation="census.xsd"> <censustaker>738</censustaker> <address> <number>510</number> <street>Yellowbrick Road</street> <city>Munchkinville</city> <province>Negbo</province> </address> <occupants> <occupant status="adult"> <firstname>Floyd</firstname> <surname>Fleegle</surname> <age>61</age> </occupant> <occupant> <firstname>Phylis</firstname> <surname>Fleegle</surname> <age>52</age> </occupant> <occupant> <firstname>Filbert</firstname> <surname>Fleegle</surname> <age>22</age> </occupants> </census> |
- RE: An example of schema Ramin Raybod
- RE: An example of schema Pavitra Jain
