icu222much
Technical User
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
XSD
One record of XML doc
Entire XSD doc
XML
Code:
<collection xmlns="[URL unfurl="true"]http://www.w3schools.com"[/URL]
xmlns:xsi="[URL unfurl="true"]http://www.w3.org/2001/XMLSchema-instance"[/URL]
xsi:schemaLocation="mallSchema.xsd">
XSD
Code:
<xs:schema xmlns:xs="[URL unfurl="true"]http://www.w3.org/2001/XMLSchema"[/URL]
targetNamespace="[URL unfurl="true"]http://www.w3schools.com"[/URL]
xmlns="[URL unfurl="true"]http://www.w3schools.com"[/URL]
elementFormDefault="qualified">
One record of XML doc
Code:
<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet type="text/xsl" href="mallLayout.xsl"?>
<collection
xmlns="[URL unfurl="true"]http://www.w3schools.com"[/URL]
xmlns:xsi="[URL unfurl="true"]http://www.w3.org/2001/XMLSchema-instance"[/URL]
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="[URL unfurl="true"]http://www.aberdeencentre.com">www.aberdeencentre.com</website>[/URL]
<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>[URL unfurl="true"]http://www.sfu.ca/~jca41/iat352/assignment/01/img/aberdeen.jpg</mainPhoto>[/URL]
<photo id="5318145511" urlT="[URL unfurl="true"]http://farm6.static.flickr.com/5082/5318145511_0c53c48f3b_t.jpg"[/URL] widthT="100" heightT="67" urlM="[URL unfurl="true"]http://farm6.static.flickr.com/5082/5318145511_0c53c48f3b.jpg"[/URL] widthM="500" heightM="333" lat="49.183445" lon="-123.133424" />
<photo id="2126379146" urlT="[URL unfurl="true"]http://farm3.static.flickr.com/2384/2126379146_3295fcba83_t.jpg"[/URL] widthT="75" heightT="100" urlM="[URL unfurl="true"]http://farm3.static.flickr.com/2384/2126379146_3295fcba83.jpg"[/URL] widthM="375" heightM="500" lat="49.183445" lon="-123.133424" />
<photo id="2710310345" urlT="[URL unfurl="true"]http://farm4.static.flickr.com/3207/2710310345_4ecec6cb81_t.jpg"[/URL] widthT="100" heightT="75" urlM="[URL unfurl="true"]http://farm4.static.flickr.com/3207/2710310345_4ecec6cb81.jpg"[/URL] widthM="500" heightM="375" lat="49.183445" lon="-123.133424" />
<photo id="2710310277" urlT="[URL unfurl="true"]http://farm4.static.flickr.com/3069/2710310277_c63e2684e5_t.jpg"[/URL] widthT="100" heightT="75" urlM="[URL unfurl="true"]http://farm4.static.flickr.com/3069/2710310277_c63e2684e5.jpg"[/URL] widthM="500" heightM="375" lat="49.183445" lon="-123.133424" />
<photo id="2711122722" urlT="[URL unfurl="true"]http://farm4.static.flickr.com/3150/2711122722_1eef09103e_t.jpg"[/URL] widthT="100" heightT="75" urlM="[URL unfurl="true"]http://farm4.static.flickr.com/3150/2711122722_1eef09103e.jpg"[/URL] widthM="500" heightM="375" lat="49.183445" lon="-123.133424" />
</mall>
</collection>
Entire XSD doc
Code:
<?xml version ="1.0"?>
<xs:schema xmlns:xs="[URL unfurl="true"]http://www.w3.org/2001/XMLSchema"[/URL] targetNamespace="[URL unfurl="true"]http://www.w3schools.com"[/URL]
xmlns="[URL unfurl="true"]http://www.w3schools.com"[/URL] 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>