XSD选择和枚举之间的区别是什么?

时间:2022-06-17 22:26:32

What is the difference between XSD choice and enumeration?

XSD选择和枚举之间的区别是什么?

3 个解决方案

#1


4  

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.

Choice表示在元素的内容模型中,可以使用几个子元素之一:例如,在文档中,可以选择章节或附录作为子元素。

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


2  

XSD choice allows you to choose between zero or one elements/attributes. These can be of any type.

XSD选择允许您在0或一个元素/属性之间进行选择。它们可以是任何类型的。

Enumeration are used in XSD simpleTypes to either restrict or extend one particular type to a set of values.

XSD simpleTypes中使用枚举限制或扩展一个特定类型到一组值。

#3


0  

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.

    选择允许零实例,而枚举需要一个实例。

#1


4  

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.

Choice表示在元素的内容模型中,可以使用几个子元素之一:例如,在文档中,可以选择章节或附录作为子元素。

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


2  

XSD choice allows you to choose between zero or one elements/attributes. These can be of any type.

XSD选择允许您在0或一个元素/属性之间进行选择。它们可以是任何类型的。

Enumeration are used in XSD simpleTypes to either restrict or extend one particular type to a set of values.

XSD simpleTypes中使用枚举限制或扩展一个特定类型到一组值。

#3


0  

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.

    选择允许零实例,而枚举需要一个实例。