誰かが私のキーが強制されていない理由を説明できますか?xsdキーが検証されていない
<xs:element name="Cats">
<xs:complexType>
<xs:sequence maxOccurs="Unbounded">
<xs:element name="cat" type="cattype"/>
</xs:sequence>
</xs:complexType>
<xs:key name="CatsKey">
<xs:selector xpath="cat" />
<xs:field xpath="cat_id"/>
</xs:key>
</xs:element>
<xs:complexType name="cattype">
<xs:sequence>
<xs:element name="cat_id" type="xs:nonNegativeInteger"/>
</xs:sequence>
</xs:complexType>
今XML
<cats>
<cat>
<cat_id>1</cat_id>
</cat>
<cat>
<cat_id>1</cat_id> <-- this should fail, as cat_id 1 already exists
</cat>
</cats>
しかし、XMLParserのキーを強制されていません。私の理解には、重要な価値は必須かつユニークでなければなりません。私はkeyrefを必要とするか、またはキー制約を実施するためにパーサに固有のものか、根本的に何かを間違ってやっていますか?
いいえ、キーは一意である必要があります。 –
清算していただきありがとうございます。私は自分のレスポンスを編集して、他人に混乱させないようにします! –