What is the difference between XSD choice and enumeration?
Enumerations are a base simple type in the XSD specification containing a list of possible values. Single-valued enumerations are shown as restrictions of the base simple type xs:token , as illustrated below: ? < xs:simpleType name=”GraduationPlanTypeMapType”>
<xsd:choice> ElementAllows one and only one of the elements contained in the selected group to be present within the containing element. Copy. <choice id = ID maxOccurs= (nonNegativeInteger | unbounded) : 1 minOccurs= nonNegativeInteger : 1 {any attributes with non-schema Namespace}...> Content: (annotation?, (
Using <xsd:choice> in an XSD It has to be defined in XML schema definition of a nested XML content. The element in the root schema has to be optional. Add attribute minOccurs="0" on the element to make it optional.
Definition and UsageThe complexType element defines a complex type. A complex type element is an XML element that contains other elements and/or attributes.
They are completely unrelated.
Choice indicates that within the content model of an element, you can use one of several child elements: for example within a document you have a choice of chapter or appendix as child elements.
Enumeration is used to restrict the values that can appear in a text or attribute node, for example to say that the value of a color attribute must be red, green, or blue.
XSD choice allows you to choose between zero or one elements/attributes. These can be of any type.
Enumeration are used in XSD simpleTypes to either restrict or extend one particular type to a set of values.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With