XSD Shema with unique id as attribute
I want to write a XSD Schema for the follwing XML:
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<siss-statusquery xmlns="http://www.example.de/test">
<myhash id="1">DG5F6DFG13DFG5641DG5F6DFG13DFG56411337AS</myhash>
<myhash id="2">123AWDFG13DFG5641DG5F6DFG13GFG56411337AS</myhash>
<myhash id="3">DG5F6DFG13DFG5641DG5F6325DFG13DFG5641143</myhash>
</siss-statusquery>
Conditions:
<myhash /> tag, minoccur: 1 , maxoccur: unbounded
id attribute, type: unsignedInt, is unique, is required
<sah1hash /> tag value pattern: [0-9A-Z]{40,40}
My try:
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema attributeFormDefault="unqualified"
elementFormDefault="qualified"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.example.de/test"
xmlns:lhs="http://www.example.de/test">
<xs:simpleType name="myhashType">
<xs:restriction base="xs:string">
<xs:pattern value="[0-9A-Z]{40,40}" />
</xs:restriction>
</xs:simpleType>
<xs:element name="siss-statusquery">
<xs:complexType>
<xs:sequence>
<xs:element name="myhash" maxOccurs="unbounded"
minOccurs="1">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="lhs:myhashType">
<xs:attribute type="xs:unsignedInt"
name="id" use="required" />
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
How can i constrict/restrict the id attribute as unique.
No comments:
Post a Comment