MinOccurs / maxOccurs in an XML Schema

Given this piece of XML Schema:

<xs:element name="data">
    <xs:complexType>
        <xs:sequence>
            <xs:element name="param" type="param" minOccurs="0" maxOccurs="unbounded" />
            <xs:element name="format" type="format" minOccurs="0" maxOccurs="unbounded" />
        </xs:sequence>
        <xs:attribute name="name" type="xs:string" />
    </xs:complexType>
</xs:element>

The intended result is valid. <data>elements may contain 0 or more elements <param>, followed by 0 or more elements <format>. I added the correct attributes minOccurs/ maxOccursor should they be applied to the containing <xs:sequence>?

Right or wrong, what would be the result of one way or another?

+3
source share
1 answer

You did it right, and you cannot add min / max to a sequence element. Using and an XML editor that supports XML Schema can help you confirm your assumptions if you are in doubt. Here is a good free product called XMLFox

+4
source

Source: https://habr.com/ru/post/1782810/


All Articles