INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

XML / XSD Validation Issue

XML / XSD Validation Issue

(OP)
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

CODE

<collection  xmlns="http://www.w3schools.com"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="mallSchema.xsd">

XSD

CODE

<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

CODE

<?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&amp;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

CODE

<?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>

RE: XML / XSD Validation Issue

What errors are you getting and how?

Cheers,
Dian

RE: XML / XSD Validation Issue

(OP)
Error in XML document:

8:37 - SchemaLocation: schemaLocation value = 'mallSchema.xsd' must have even number of URI's.

8:37 - cvc-elt.1: Cannot find the declaration of element 'collection'.


Error in XML document:

4:65 - argetNamespace.2: Expecting no namespace, but the schema document has a target namespace of 'http://www.w3schools.com'.

RE: XML / XSD Validation Issue

First one is very clear, isn't it? You need to parameters for schemaLocation as shown here.

 

Cheers,
Dian

RE: XML / XSD Validation Issue

(OP)
Didn't I provide the schemaLocation by saying xsi:schemaLocation="mallSchema.xsd" ?

I don't understand the second error either as I already declared <xs:element name="collection"> in my schema.

For the third point, I just copied what I found online at W3Schools, and I still receive an error.

RE: XML / XSD Validation Issue

SchemaLocation needs two parameters, you provided only one.

Cheers,
Dian

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close