What is the difference between XSD choice and enumeration?

跟風遠走 提交于 2020-01-03 08:40:16

问题


What is the difference between XSD choice and enumeration?


回答1:


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.




回答2:


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.




回答3:


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.



来源:https://stackoverflow.com/questions/5358132/what-is-the-difference-between-xsd-choice-and-enumeration

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!