Element 'element' is invalid, misplaced, or occurs too often

11,790

make sure you have xs:sequence or something else

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
    <xs:element name="List_Of_Skills">
        <xs:complexType>
            <xs:sequence>
                <xs:element name="Skill" maxOccurs="unbounded">
                    <xs:complexType>
                        <xs:sequence>
                            <xs:element name="Name" type="xs:string"/>
                            <xs:element name="ID" type="xs:integer"/>
                            <xs:element name="Description" type="xs:string"/>
                        </xs:sequence>
                    </xs:complexType>
                </xs:element>
            </xs:sequence>
        </xs:complexType>
    </xs:element>
</xs:schema>
Share:
11,790
Mayeul sgc
Author by

Mayeul sgc

Updated on October 20, 2022

Comments

  • Mayeul sgc
    Mayeul sgc over 1 year

    I'm just trying to do a little xmll file with its xsd file but i don't understand the errors I get in the w3c code validator. My xml code is valid. My xsd code was valid but when I checked the code together, I got errors, I found that my errors were that I was using the even when I only had 1 element. I corrected this. Now my xsd code in not valid anymore (just by erasng the ) and I can't find why I get this error.

    Here is my xml code :

    <?xml version="1.0" encoding="UTF-8"?>
    <List_Of_Skills>
    <Skill>
    <Name> PHP </Name>
    <ID> 1 </ID>
    <Description> Able to code in PHP </Description> 
    </Skill>
    
    <Skill>
    <Name> XML </Name> 
    <ID> 2 </ID>
    <Description> Able to code in XML </Description>
    </Skill>
    
    <Skill> 
    <Name> C# </Name > 
    <ID> 3 </ID>
    <Description> Able to code applications windows or web in C#</Description>
    </Skill>
    
    <Skill> 
    <Name> JavaScript </Name>
    <ID> 4 </ID> 
    <Description> Able to create web applications and animations in JavaScript </Description>
    </Skill>
    
    <Skill>
    <Name> Python </Name>
    <ID> 5 </ID>
    <Description> Able to code applications in Python </Description>
    </Skill>
    
    <Skill>
    <Name> Ajax </Name>
    <ID> 6 </ID>
    <Description> Able to code web applications in Ajax </Description>
    </Skill>
    
    
    </List_Of_Skills>
    

    Here is my xsd code :

    <?xml version="1.0" encoding="UTF-8"?>
    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
    
    <xs:element name="List_Of_Skills">
    <xs:complexType>
    
        <xs:element name="Skill">
        <xs:complexType>
        <xs:sequence>
            <xs:element name="Name" type="xs:string"/> 
            <xs:element name="ID" type="xs:integer"/> 
            <xs:element name="Description" type="xs:string"/> 
        </xs:sequence>
        </xs:complexType>
        </xs:element>
    
    </xs:complexType>
    </xs:element>
    
    </xs:schema>
    

    and here is the error : Error - Line 8, 27: org.xml.sax.SAXParseException; lineNumber: 8; columnNumber: 27; s4s-elt-invalid-content.1: The content of '#AnonType_List_Of_Skills' is invalid. Element 'element' is invalid, misplaced, or occurs too often.

    If someone has any information thank you

    Mayeul