Check xsd for xml

I just finished learning xml and xsd. I made my first XML document and I just want to make sure I validate it correctly with xsd.

My XML Code:

<?xml version="1.0" encoding="UTF-8" ?>
<user xmlns="http://localhost" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://localhost user.xsd">
<name>
    <first>jack</first>
    <last>hals</last>
</name>
<name>
    <first>harry</first>
    <last>potter</last>
</name>
</user>

      

My xsd code:

<?xml vesion="1.0" encoding="UTF-8" ?><xs:schema xmlns:xs="http://WWW.W3.org/2001/XMLSchema" targetNamespace="http://localhost" xmlns="http://localhost" elementFormDefault="qualified">
<xs:element name="user" block="substitution" minOccurs="1" maxOccurs="1">
<xs:complexType>
    <xs:sequence>
        <xs:element name="name" minOccurs="1" maxOccurs="5" block="substitution">
            <xs:complexType>
                <xs:sequence>
                    <xs:element name="first" type="xs:string" default="jack" minOccurs="1" maxOccurs="1" block="substitution" />
                    <xs:element name="last" type="xs:string" default="hals" minOccurs="1" maxOccurs="1" block="substitution" />
                </xs:sequence>
            </xs:complexType>
        </xs:element>
    </xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>

      

I tried an online validator and it said: A pseudo attribute name is expected.

What now?

+3


source to share


1 answer


<?xml vesion="1.0"

      

it should be

<?xml version="1.0"

      

(you missed the "r"). Also, namespace URIs are case sensitive, so



xmlns:xs="http://WWW.W3.org/2001/XMLSchema"

      

needs to be changed to

xmlns:xs="http://WWW.W3.org/2001/XMLSchema"

      

+2


source







All Articles