1

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 !

  • 1
    Thank you so much. Actually I was not getting the actual problem. That's why I was unable to search the solution, so I posted the question. Thank you so much to refer me to the problem. – Mohsin Ahmed Apr 01 '19 at 20:30

0 Answers0