使 xs:enumeration 的列表出现在 <menuChoices/> XML 元素中而不重复它们

Make a list of xs:enumeration appear in <menuChoices/> XML element without repeating them

在我的架构中,我有一个 colorName 枚举列表、一个 <color name="one_of_colorName"/> 元素和一个 <colorsUsed/> 元素,其中使用了一个唯一的 <color/> 列表,因此:

<!-- color name list -->
<xs:simpleType name="colorName">
  <xs:restriction base="xs:string">
    <xs:enumeration value="red"/>
    <xs:enumeration value="green" />  <!-- etc. -->
  </xs:restriction>
</xs:simpleType>

<!-- color element, just go with the col: namespace -->
<xs:element name="color">
  <xs:complexType>
    <xs:attribute name="name" type="col:colorName" use="required"/>
  </xs:complexType>
</xs:element>

<!-- unique list of colors used -->
<xs:element name="colorsUsed">
  <xs:complexType>
    <xs:sequence>
      <!-- let's hold off on max which must be the length of the color name list -->
      <xs:element ref="col:color" maxOccurs="unbounded"/>
    </xs:sequence>
  </xs:complexType>

  <!-- enforce unique color name in the list -->
  <xs:unique name="uniqueColorName">
    <xs:selector xpath="col:color"/>
    <xs:field xpath="@name"/>
  </xs:unique>
</xs:element>

问题 1:我想让 <colorChoices/> 菜单填充颜色名称列表中的所有颜色,而不重复它们,无论是在架构中还是在 XML 文件,沿着这些行:

<xs:element name="colorChoices">
  <xs:complexType>
    <xs:all>                         <!-- need the name list, one each -->
      <xs:element ref="col:color"/>  <!-- ?? what how ?? -->
    </xs:all>
  </xs:complexType>
</xs:element>

问题 2:我有一个可行的解决方案,但最好有:在 <colorsUsed/> 元素中,我可以限制 maxOccurs=length_of_colorName_list 吗?

感谢您的回答或 link 现有答案,但我似乎找不到。

在菜单元素 <colorChoices/> 中列出类型为 xs:string 的所有 <color> 个选项,并删除枚举列表。然后在 <colorChoices/><colorsUsed/> 中强制执行 <color name="???"/> 的唯一性。如果您知道更好的答案,请更新。谢谢。