누군가 내 키가 적용되지 않는 이유를 설명 할 수 있습니까?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가 키를 적용하지 않습니다. 내 이해하려면 핵심 가치는 필수적이고 고유해야합니다. 핵심 제약 조건을 적용하기 위해 파서 (parser)를 위해 keyref 또는 unique가 필요합니까? 아니면 근본적으로 잘못된 것을하고 있습니까?
아니요, 키는 고유해야합니다. –
설명 주셔서 감사합니다. 내 답변을 편집하여 다른 사람들에게 혼란을주지 않도록하십시오! –