Я создаю схему xsd для проверки некоторых xml
Я хотел бы ограничить xml, чтобы нельзя было вводить один и тот же элемент дважды:
<branches>
<branche>Bank</branche>
<branche>Bank</branche>
</branches>
Но должно быть возможно использовать 2 разных предмета:
<branches>
<branche>Bank</branche>
<branche>Insurance</branche>
</branches>
Итак, у меня есть следующий код:
<!-- definition of simple elements -->
<xs:simpleType name="branche">
<xs:restriction base="xs:string">
<xs:enumeration value="Bank" maxOccurs="1"/>
<xs:enumeration value="Insurance" maxOccurs="1"/>
</xs:restriction>
</xs:simpleType>
<xs:element name="branches" minOccurs="0"> <!-- minOccurs becouse i want it to be posible to leave out the whole <branches> tag -->
<xs:complexType>
<xs:sequence>
<xs:element name="branche" type="branche" minOccurs="0" maxOccurs="2" />
</xs:sequence>
</xs:complexType>
</xs:element>
использование maxOccurs="1"
не ограничивает его только одним значением, поскольку тег 'branche' может встречаться дважды.
Я хочу, чтобы значение (<branche>value</branche>
) было уникальным.
Thnx!