Human_BetaRelease
Human_BetaRelease

Reputation: 317

xsd Schema validation; xs:choice and min/max-occurs

We have an xml file that consists of one root element, a directly following element and after that 0 to 255 other elements of one specific type.

Currently, our XSD file looks like this:

<xs:element name="TIM">
    ...
    <xs:complexType>
        <xs:choice minOccurs="0" maxOccurs="unbounded">
            <xs:element ref="POINT" minOccurs="0" maxOccurs="1">
                <xs:annotation>
                    <xs:documentation xml:lang="en">
                        Point
                    </xs:documentation>
                </xs:annotation>
            </xs:element>
            <xs:element ref="VALUE" minOccurs="0" maxOccurs="255">
                <xs:annotation>
                    <xs:documentation xml:lang="en">
                        Value
                    </xs:documentation>
                </xs:annotation>
            </xs:element>
        </xs:choice>
...
</xs:element>

How would I have to change this to say "Element Point once at the top, afterwards only ElementValue"?

Upvotes: 0

Views: 204

Answers (1)

Martin Honnen
Martin Honnen

Reputation: 167401

Sounds like you want a simple sequence xs:sequence i.e. <xs:sequence><xs:element ref="POINT">..</xs:element><xs:element ref="VALUE" minOccurs="0" maxOccurs="255">..</xs:element></xs:sequence>.

Upvotes: 1

Related Questions