Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > Element with maxlength restriction, with two attributes

Reply
Thread Tools

Element with maxlength restriction, with two attributes

 
 
executeinc@gmail.com
Guest
Posts: n/a
 
      10-18-2007
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?

 
Reply With Quote
 
 
 
 
usenet@tech-know-ware.com
Guest
Posts: n/a
 
      10-19-2007
On 18 Oct, 15:04, (E-Mail Removed) 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/
=============================================

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
xtml: combining attributes from one element into a different element Mike N. XML 3 03-17-2008 01:30 PM
how to Update/insert an xml element's text----> (<element>text</element>) HANM XML 2 01-29-2008 03:31 PM
Query : Number of Attributes under an element & atleast 1 occurence of element/Attribute kosaraju.puneeth@gmail.com XML 0 10-26-2005 07:09 AM
TextBox - MaxLength property =?Utf-8?B?bWc=?= ASP .Net 1 04-11-2004 02:29 PM
Textbox maxlength..... Why doesnt that ever work??? Darren Clark ASP .Net 1 04-10-2004 02:56 AM



Advertisments