XSD - define element and attribute with restrictions



I need to define XSD which has sequence of element with optional attribute. I also need to restrict string length of both element and attribute. Using following code I cannot seem to define 'restriction':



<xs:element name="PeopleMentioned" minOccurs="0">
<xs:complexType>
<xs:sequence>
<xs:element name="Person" minOccurs="1" maxOccurs="unbounded">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute name="PersonTopic" type="xs:string" />
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>


I need to restrict length of 'Person' and 'PersonTopic', like would normally do for simple type:



<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="18" />
</xs:restriction>
</xs:simpleType>

No comments:

Post a Comment