Question

I've created a XML Schema that features MaxOccurs and MinOccurs on some of my elements, however when i try to validate it comes up with the errors of "91 s4s-att-not-allowed: Attribute 'MaxOccurs' cannot appear in element 'element'."

Below is an example of one of my elements:

From previous posts they mention that it needs to be in a sequence. Which I'm pretty sure i have done.

Était-ce utile?

La solution

You have two problems, at least:

1) The error

Attribute 'MaxOccurs' cannot appear in element 'element'." 

Explains it all. It's maxOccurs. Case matters.

2) You are defining your enginesize element as a simple type (type="integer") while at the same time defining it as a complex type (nested <complexType>). You can't have them both.

If you want an enginesize element that has an attribute and also accepts an integer as simple content, you have to define it as having simple content, and use an extension to add the attribute.

What I believe you want to achieve is something like this:

<xsd:element name="enginesize" maxOccurs="2">
    <xsd:complexType mixed="true">
        <xsd:simpleContent>
            <xsd:extension base="xsd:integer">
                <xsd:attribute name="unit" use="required">
                    <xsd:simpleType>
                        <xsd:restriction base="xsd:string">
                            <xsd:enumeration value="CC"/>
                            <xsd:enumeration value="CL"/>
                        </xsd:restriction>
                    </xsd:simpleType>
                </xsd:attribute>
            </xsd:extension>
        </xsd:simpleContent>
    </xsd:complexType>
</xsd:element>
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top