Can not find the declaration of element "globalHotels"

35 Views Asked by At

I'm trying to write XML Schema for an XML Document. But unable to create element. Here is my XML Schema

<?xml version="1.0" encoding="UTF-8"?>
    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
    targetNamespace="https://www.w3schools.com"
    xmlns="https://www.w3schools.com"
    elementFormDefault="qualified">

        <xs:complexType name="hotelsType">
            <xs:sequence>
                <xs:element name="hotel" type="hotelType" maxOccurs="1" minOccurs="1"></xs:element>
            </xs:sequence>
        </xs:complexType>

        <xs:complexType name="hotelType">
            <xs:sequence>
                <xs:element name="name" type="xs:string"></xs:element>
                <xs:element name="rating" type="xs:integer"></xs:element>
                <xs:element name="facilities" type="facilitiesType"></xs:element>
                <xs:element name="address" type="xs:string"></xs:element>
                <xs:element name="distance" type="xs:integer"></xs:element>
                <xs:element name="availability" type="xs:boolean"></xs:element>
            </xs:sequence>
            <xs:attribute name="id" type="xs:ID" use="required"></xs:attribute>
        </xs:complexType>

        <xs:complexType name="facilitiesType">
            <xs:sequence>
                <xs:element name="facility" type="xs:string"></xs:element>
            </xs:sequence>
        </xs:complexType>

        <xs:element name="globalHotels" type="hotelsType"></xs:element>

    </xs:schema>

Here is XML Document

<?xml version="1.0"?>

<globalHotels
    xmlns="https://www.w3schools.com"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="C:\Users\Mohsi\XMLSchema\schema.xsd">

</globalHotels>

The error is "Can not find the declaration of element globalHOtels". Kindly tell me where I'm committing mistake and how I can get rid of this. Thanks !

0

There are 0 best solutions below