В моей схеме, у меня есть список из colorName
перечислимых, а <color name="one_of_colorName"/>
элемента, и <colorsUsed/>
элемента с уникальным списком <color/>
с используемым, таким образом, :Составьте список хза: перечисление появляется в <menuChoices /> элемент XML, не повторяя их
<!-- 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
?
Спасибо за ответ или ссылку на существующий ответ, который я не могу найти.