开发者

What is the difference between XSD choice and enumeration?

开发者 https://www.devze.com 2023-02-17 23:19 出处:网络
What is the difference between XSD choice and 开发者_如何学Pythonenumeration?They are completely unrelated.

What is the difference between XSD choice and 开发者_如何学Pythonenumeration?


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.


Gathering from the previous answers, and putting them together in clear, concise way:

The differences are two-fold:

  • choice is for element tag, and enumeration is for a node's text or attribute.

  • choice allows for zero instances, while enumeration requires one.

0

精彩评论

暂无评论...
验证码 换一张
取 消