0
votes

I've been struggling with an xml validation against an xml schema for a day now! The answer may be easy but I can't seem to find it, so I would greatly appreciate your help.

Here is my xml:

<?xml version="1.0" encoding="utf-8"?>
<coder>
    <coderName>Mike89
        <points>500</points>
    </coderName>

    <coderName>TheCoder
        <points>1000</points>
    </coderName>

    <coderName>HelloAll
        <points>5000</points>
    </coderName>

    <coderName>Cristina
        <points>6000</points>
    </coderName>
</coder>

I have tried this for corresponding xsd:

 <?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
    <xs:element name="coder">
        <xs:complexType>
            <xs:sequence>
                <xs:element name="coderName" maxoccurs="unbounded">
                    <xs:complexType mixed="true">
                        <xs:sequence>
                            <xs:element name="points" type="xs:string"/>
                        </xs:sequence>
                    </xs:complexType>
                </xs:element>
            </xs:sequence>
        </xs:complexType>
    </xs:element>
</xs:schema>

I also have a this variant for the xsd:

  <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
    <xs:element name="coder">
        <xs:complexType>
            <xs:sequence>
                <xs:element name="coderName" type ="coderNameType" maxoccurs="unbounded"/>
            </xs:sequence>
        </xs:complexType>
    </xs:element>



    <xs:complexType name = "coderNameType" mixed="true">
        <xs:sequence>
            <xs:element name="points" type="xs:string"/>
        </xs:sequence>
    </xs:complexType>
</xs:schema>

Both don't work !

Reviewing other posts on this website, I tried without the maxoccurs="unbounded" attributes, it gave me this error :

Invalid content was found starting with element 'element'. No child element is expected at this point.

Then I tried with the maxoccurs="unbounded" attributes as shown in the code above, this time it gave me this error :

Attribute 'MaxOccurs' cannot appear in element 'element

So what should I do ? keep or delete the maxoccurs attributes ? If I remove them, what should I do instead ?

Thank you very much for your help, I'm going crazy with this !

1

1 Answers

0
votes

It is maxOccurs not maxoccurs.