Reputation: 3239
I would like to define the XSD for:
<Group id="someid" parent="someid">some string</Group>
This is what I tried:
<xs:element name="Group" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:simpleContent>
<xs:restriction base="xs:string">
<xs:attribute name="id" type="xs:ID" use="required"/>
<xs:attribute name="parent" type="xs:IDREF" use="optional"/>
</xs:restriction>
</xs:simpleContent>
</xs:complexType>
</xs:element>
I use Visual Studio for the XSD design. The validator tells me (while underlining "<xs:restriction"): "Undefined complexType 'http://w3.org/2001/XMLSchema:string' is used as base for a complex type restriction."
Upvotes: 0
Views: 228
Reputation: 3239
It's needed to use <xs:extension>
instead of <xs:restriction>
:
<xs:element name="Group" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute name="id" type="xs:ID" use="required"/>
<xs:attribute name="parent" type="xs:IDREF" use="optional"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
Upvotes: 1