가정 ID는 "컨테이너"의 반복 내용에 대한 고유 식별자입니다, 당신은 XS를 설정할 수 있습니다 : 키 제약 조건을이 같은 XYZ를 위해 :
<?xml version="1.0" encoding="utf-8" ?>
<xs:schema elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="abc">
<xs:complexType>
<xs:sequence>
<xs:element maxOccurs="unbounded" ref="ele1"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="xyz">
<xs:complexType>
<xs:sequence>
<xs:element maxOccurs="unbounded" ref="ele1"/>
</xs:sequence>
</xs:complexType>
<xs:key name="PK_xyz">
<xs:selector xpath="ele1"/>
<xs:field xpath="@ID"/>
</xs:key>
</xs:element>
<xs:element name="ele1">
<xs:complexType>
<xs:attribute name="ID" type="xs:integer"/>
</xs:complexType>
</xs:element>
</xs:schema>
그런 잘못된 XML을 ID가 없기 때문에 :
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<!-- Sample XML generated by QTAssistant (http://www.paschidev.com) -->
<xyz xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<ele1 ID="1"/>
<ele1 />
</xyz>
오류 메시지 :이 (이 중복 때문에
Error occurred while loading [], line 5 position 3
The identity constraint 'PK_xyz' validation has failed. Either a key is missing or the existing key has an empty node.
Document3.xml is invalid.
잘못된 고유성에 위의 가정이 사실 서 있지 않는 경우 단점은)입니다 :
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<!-- Sample XML generated by QTAssistant (http://www.paschidev.com) -->
<xyz xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<ele1 ID="1"/>
<ele1 ID="1"/>
</xyz>
오류 :
Error occurred while loading [], line 5 position 3
There is a duplicate key sequence '1' for the 'PK_xyz' key or unique identity constraint.
Document3.xml is invalid.
하는 작업을 샘플 :
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<!-- Sample XML generated by QTAssistant (http://www.paschidev.com) -->
<xyz xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<ele1 ID="1"/>
<ele1 ID="2"/>
</xyz>