On 18 Oct, 15:04, execute...@gmail.com wrote:
Could you some help to define
1. An element with restriction on it's base type (xs:string), limiting
maxlength
2. That element also needs two attributes defined on it.
Simple restriction is easy:
<xs:element name="kirk" minOccurs="0" maxOccurs="1">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="2"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
But doesn't allow for the attribute definition. I've tried
complexcontent, etc. and can't quite get it.
Help?
You need to do this in two steps. First define a simple type that has
a climited length string, and then another type that adds the two
attributes to it.
e.g.
<xs:simpleType name="shortString">
<xs:restriction base="xs:string">
<xs:maxLength value="2"/>
</xs:restriction>
</xs:simpleType>
<xs:element name="kirk" minOccurs="0" maxOccurs="1">
<xs:complexType>
<xs:simpleContent>
<xs:extension base='shortString'>
<xs:attribute name='a1' type='xs:int'/>
<xs:attribute name='a2' type='xs:int'/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
Ah, the beauty of XML schema - not!
HTH,
Pete.
=============================================
Pete Cordell
Codalogic
for XML Schema to C++ data binding visit
http://www.codalogic.com/lmx/
=============================================