我有以下 XSD,我需要向其中添加另一个唯一约束。
我想让 Name 在其父 Groups 元素中唯一,但是可以在每个 WikiMeta 中重复一个组。
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="AllMeta">
<xs:complexType>
<xs:sequence>
<xs:element maxOccurs="unbounded" name="WikiMeta">
<xs:complexType>
<xs:sequence>
<xs:element name="Subject" type="xs:string" minOccurs="1" maxOccurs="1" />
<xs:element name="PageTitle" type="xs:string" minOccurs="1" maxOccurs="1" />
<xs:element name="PageMetaDescription" type="xs:string" minOccurs="1" maxOccurs="1" />
<xs:element name="Articles">
<xs:complexType>
<xs:sequence>
<xs:element name="WikiArticle" minOccurs="1" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="FileName" type="xs:string" minOccurs="1" maxOccurs="1" />
</xs:sequence>
</xs:complexType>
<xs:unique name="uniqueFileName">
<xs:selector xpath="WikiMeta"/>
<xs:field xpath="FileName"/>
</xs:unique>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="Groups">
<xs:complexType>
<xs:sequence>
<xs:element maxOccurs="unbounded" name="WikiGroup">
<xs:complexType>
<xs:sequence>
<xs:element name="Name" type="xs:string" minOccurs="1" maxOccurs="1" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
<xs:unique name="subject">
<xs:selector xpath="WikiMeta"/>
<xs:field xpath="Subject"/>
</xs:unique>
<xs:unique name="fileName">
<xs:selector xpath="WikiMeta/Articles/WikiArticle"/>
<xs:field xpath="FileName"/>
</xs:unique>
</xs:element>
</xs:schema>
有任何想法吗?