Element with maxlength restriction, with two attributes

E

executeinc

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?
 
U

usenet

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/
=============================================
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,823
Latest member
Nadia88

Latest Threads

Top