24.11. choice Element

The choice element restricts an XML instance to choose one element type from a set of element types. From a database schema perspective, this restricts a set of columns to have one non-null value. This is similar to how unions are implemented in Section 23.5.3.2. Choices, by default, have one element type but can have a minOccurs attribute and a maxOccurs attribute. Listing 24.10 creates a colorSizeChoicesType setting the minOccurs to 0 and maxOccurs to 4. The colorSizeChoicesType allows up to four choices, and they can be of color and/or size.

Listing 24.10. A Complex colorSizeChoicesType XML Document Fragment
 <xsd:complexType name="colorSizeChoicesType" block="#all" final="#all" id="colorSizeChoicesType.catalog.cType"> ...

Get XML Schema Complete Reference, The now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.