11.12. The choice Element

The choice element provides an XML representation for describing a selection from a set of element types. An XML instance contains elements whose element types are the set specified by the choice element in an XML schema document. The minOccurs and maxOccurs attributes may permit the XML instance to select several (for example, between two and four) occurrences of element types from the set. Listing 11.16 demonstrates the use of a choice element whose description is part of the global priceGroup. A XML instance must contain one of the following: a fullPrice element, a salePrice element, a clearancePrice element, or a freePrice element.

Listing 11.16. Selecting from a Set of Elements (pricing.xsd)
 <xsd:group name="priceGroup" ...

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.