icu222much
25 Sep 2011, 02:03 PM
I've created a XML + Schema and am trying to validate it but I keep on receiving errors that I do not understand. I believe I have done what w3schools has done, but for some reason it is not valid.
XML
<collection xmlns="http://www.w3schools.com"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="mallSchema.xsd">
XSD
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.w3schools.com"
xmlns="http://www.w3schools.com"
elementFormDefault="qualified">
One record of XML doc
<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet type="text/xsl" href="mallLayout.xsl"?>
<collection
xmlns="http://www.w3schools.com"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="mallSchema.xsd">
<mall>
<title>Aberdeen</title>
<hours>
<daysOfTheWeek>Mon-Wed</daysOfTheWeek>
<hoursEachDay>11am-7pm</hoursEachDay>
</hours>
<hours>
<daysOfTheWeek>Thu-Sat</daysOfTheWeek>
<hoursEachDay>11am-9pm</hoursEachDay>
</hours>
<hours>
<daysOfTheWeek>Sun&Holi</daysOfTheWeek>
<hoursEachDay>11am-7pm</hoursEachDay>
</hours>
<address>
<street>4151 Hazelbridge Way</street>
<city>Richmond</city>
</address>
<phone>604.270.1234</phone>
<website url="http://www.aberdeencentre.com">www.aberdeencentre.com</website>
<description>When we built Aberdeen Centre back in 1989, our goal was to create the first truly Asian shopping experience in the Lower Mainland. Our success has inspired us to look beyond cultures, to re-imagine and redefine a new type of retail and entertainment experience. One that embraces the best of East and West. A celebration of multiculturalism. To achieve this we are building a state-of-the-art shopping and entertainment complex triple the size of the original. My vision for the new Aberdeen Centre is to see it become Greater Vancouver pre-eminent cosmopolitan shopping destination. The first Asian/Western centre of its kind, anywhere.</description>
<dateSubmitted>September 20, 2011</dateSubmitted>
<coordinates lat="49.183445" lon="-123.133424"/>
<mainPhoto>http://www.sfu.ca/~jca41/iat352/assignment/01/img/aberdeen.jpg</mainPhoto>
<photo id="5318145511" urlT="http://farm6.static.flickr.com/5082/5318145511_0c53c48f3b_t.jpg" widthT="100" heightT="67" urlM="http://farm6.static.flickr.com/5082/5318145511_0c53c48f3b.jpg" widthM="500" heightM="333" lat="49.183445" lon="-123.133424" />
<photo id="2126379146" urlT="http://farm3.static.flickr.com/2384/2126379146_3295fcba83_t.jpg" widthT="75" heightT="100" urlM="http://farm3.static.flickr.com/2384/2126379146_3295fcba83.jpg" widthM="375" heightM="500" lat="49.183445" lon="-123.133424" />
<photo id="2710310345" urlT="http://farm4.static.flickr.com/3207/2710310345_4ecec6cb81_t.jpg" widthT="100" heightT="75" urlM="http://farm4.static.flickr.com/3207/2710310345_4ecec6cb81.jpg" widthM="500" heightM="375" lat="49.183445" lon="-123.133424" />
<photo id="2710310277" urlT="http://farm4.static.flickr.com/3069/2710310277_c63e2684e5_t.jpg" widthT="100" heightT="75" urlM="http://farm4.static.flickr.com/3069/2710310277_c63e2684e5.jpg" widthM="500" heightM="375" lat="49.183445" lon="-123.133424" />
<photo id="2711122722" urlT="http://farm4.static.flickr.com/3150/2711122722_1eef09103e_t.jpg" widthT="100" heightT="75" urlM="http://farm4.static.flickr.com/3150/2711122722_1eef09103e.jpg" widthM="500" heightM="375" lat="49.183445" lon="-123.133424" />
</mall>
</collection>
Entire XSD doc
<?xml version ="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.w3schools.com"
xmlns="http://www.w3schools.com" elementFormDefault="qualified">
<xs:element name="collection">
<xs:complexType>
<xs:sequence>
<xs:element name="mall">
<xs:complexType>
<xs:sequence>
<xs:element name="title" type="xs:string" />
<xs:element name="hours">
<xs:complexType>
<xs:sequence>
<xs:element name="daysOfTheWeek" type="xs:string" />
<xs:element name="hoursEachDay" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="address">
<xs:complexType>
<xs:sequence>
<xs:element name="street" type="xs:string" />
<xs:element name="city" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="phone" type="xs:string" />
<xs:element name="website">
<xs:complexType>
<xs:attribute name="url" type="xs:string" />
</xs:complexType>
</xs:element>
<xs:element name="description">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:minLength value="300"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="dateSubmitted" type="xs:string" />
<xs:element name="coordinates">
<xs:complexType>
<xs:attribute name="lat" type="xs:string" use="required" />
<xs:attribute name="lon" type="xs:string" use="required" />
</xs:complexType>
</xs:element>
<xs:element name="mainPhoto" type="xs:string" />
<xs:element name="photo">
<xs:complexType>
<xs:attribute name="id" type="xs:string" use="required" />
<xs:attribute name="urlT" type="xs:string" use="required" />
<xs:attribute name="widthT" type="xs:string" use="required" />
<xs:attribute name="heightT" type="xs:string" use="required" />
<xs:attribute name="urlM" type="xs:string" use="required" />
<xs:attribute name="widthM" type="xs:string" use="required" />
<xs:attribute name="heightM" type="xs:string" use="required" />
<xs:attribute name="lat" type="xs:string" use="required" />
<xs:attribute name="lon" type="xs:string" use="required" />
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
XML
<collection xmlns="http://www.w3schools.com"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="mallSchema.xsd">
XSD
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.w3schools.com"
xmlns="http://www.w3schools.com"
elementFormDefault="qualified">
One record of XML doc
<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet type="text/xsl" href="mallLayout.xsl"?>
<collection
xmlns="http://www.w3schools.com"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="mallSchema.xsd">
<mall>
<title>Aberdeen</title>
<hours>
<daysOfTheWeek>Mon-Wed</daysOfTheWeek>
<hoursEachDay>11am-7pm</hoursEachDay>
</hours>
<hours>
<daysOfTheWeek>Thu-Sat</daysOfTheWeek>
<hoursEachDay>11am-9pm</hoursEachDay>
</hours>
<hours>
<daysOfTheWeek>Sun&Holi</daysOfTheWeek>
<hoursEachDay>11am-7pm</hoursEachDay>
</hours>
<address>
<street>4151 Hazelbridge Way</street>
<city>Richmond</city>
</address>
<phone>604.270.1234</phone>
<website url="http://www.aberdeencentre.com">www.aberdeencentre.com</website>
<description>When we built Aberdeen Centre back in 1989, our goal was to create the first truly Asian shopping experience in the Lower Mainland. Our success has inspired us to look beyond cultures, to re-imagine and redefine a new type of retail and entertainment experience. One that embraces the best of East and West. A celebration of multiculturalism. To achieve this we are building a state-of-the-art shopping and entertainment complex triple the size of the original. My vision for the new Aberdeen Centre is to see it become Greater Vancouver pre-eminent cosmopolitan shopping destination. The first Asian/Western centre of its kind, anywhere.</description>
<dateSubmitted>September 20, 2011</dateSubmitted>
<coordinates lat="49.183445" lon="-123.133424"/>
<mainPhoto>http://www.sfu.ca/~jca41/iat352/assignment/01/img/aberdeen.jpg</mainPhoto>
<photo id="5318145511" urlT="http://farm6.static.flickr.com/5082/5318145511_0c53c48f3b_t.jpg" widthT="100" heightT="67" urlM="http://farm6.static.flickr.com/5082/5318145511_0c53c48f3b.jpg" widthM="500" heightM="333" lat="49.183445" lon="-123.133424" />
<photo id="2126379146" urlT="http://farm3.static.flickr.com/2384/2126379146_3295fcba83_t.jpg" widthT="75" heightT="100" urlM="http://farm3.static.flickr.com/2384/2126379146_3295fcba83.jpg" widthM="375" heightM="500" lat="49.183445" lon="-123.133424" />
<photo id="2710310345" urlT="http://farm4.static.flickr.com/3207/2710310345_4ecec6cb81_t.jpg" widthT="100" heightT="75" urlM="http://farm4.static.flickr.com/3207/2710310345_4ecec6cb81.jpg" widthM="500" heightM="375" lat="49.183445" lon="-123.133424" />
<photo id="2710310277" urlT="http://farm4.static.flickr.com/3069/2710310277_c63e2684e5_t.jpg" widthT="100" heightT="75" urlM="http://farm4.static.flickr.com/3069/2710310277_c63e2684e5.jpg" widthM="500" heightM="375" lat="49.183445" lon="-123.133424" />
<photo id="2711122722" urlT="http://farm4.static.flickr.com/3150/2711122722_1eef09103e_t.jpg" widthT="100" heightT="75" urlM="http://farm4.static.flickr.com/3150/2711122722_1eef09103e.jpg" widthM="500" heightM="375" lat="49.183445" lon="-123.133424" />
</mall>
</collection>
Entire XSD doc
<?xml version ="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.w3schools.com"
xmlns="http://www.w3schools.com" elementFormDefault="qualified">
<xs:element name="collection">
<xs:complexType>
<xs:sequence>
<xs:element name="mall">
<xs:complexType>
<xs:sequence>
<xs:element name="title" type="xs:string" />
<xs:element name="hours">
<xs:complexType>
<xs:sequence>
<xs:element name="daysOfTheWeek" type="xs:string" />
<xs:element name="hoursEachDay" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="address">
<xs:complexType>
<xs:sequence>
<xs:element name="street" type="xs:string" />
<xs:element name="city" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="phone" type="xs:string" />
<xs:element name="website">
<xs:complexType>
<xs:attribute name="url" type="xs:string" />
</xs:complexType>
</xs:element>
<xs:element name="description">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:minLength value="300"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="dateSubmitted" type="xs:string" />
<xs:element name="coordinates">
<xs:complexType>
<xs:attribute name="lat" type="xs:string" use="required" />
<xs:attribute name="lon" type="xs:string" use="required" />
</xs:complexType>
</xs:element>
<xs:element name="mainPhoto" type="xs:string" />
<xs:element name="photo">
<xs:complexType>
<xs:attribute name="id" type="xs:string" use="required" />
<xs:attribute name="urlT" type="xs:string" use="required" />
<xs:attribute name="widthT" type="xs:string" use="required" />
<xs:attribute name="heightT" type="xs:string" use="required" />
<xs:attribute name="urlM" type="xs:string" use="required" />
<xs:attribute name="widthM" type="xs:string" use="required" />
<xs:attribute name="heightM" type="xs:string" use="required" />
<xs:attribute name="lat" type="xs:string" use="required" />
<xs:attribute name="lon" type="xs:string" use="required" />
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>