我想为以下 XML 编写 XSD 架构:
<?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>
条件:
<myhash />
标签,最小出现次数:1
,最大出现次数:unbounded
id
属性, 类型:unsignedInt
, isunique
, isrequired
<myhash />
标签值模式:[0-9A-Z]{40,40}
我的尝试:
<?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>
如何将id
属性限制/限制为唯一?