10.8. The union Element

A simple type can specify a union of other simple types. The contents in the XML instance of an element constructed from a union can be any of the valid types. A union can be thought of as an “or” construct. That is, “a union b union c” is the conceptual representation of “a or b or c.”

Tip

A union may contain member types that have completely distinct base types, as demonstrated in Listing 10.8.

Listing 10.8 demonstrates the XML representation of the colorOptionType, which is a union of the anonymously declared standardColorOptionType, fancifulColorOptionType, and codedColorOptionType enumerations.

Listing 10.8. A union Specifying Local simpleType Elements (catalog.xsd)
 <xsd:simpleType name="colorOptionType" id="catalog.colorOption.union.sType"> ...

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.