473,406 Members | 2,620 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Element with maxlength restriction, with two attributes

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?

Oct 18 '07 #1
1 4030
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/
=============================================

Oct 19 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Matthet | last post by:
Hi, I'm defining an element that is based on simpleType named "myPatternType" <xsd:element name="MyElement"> <xsd:complexType> <xsd:simpleContent> <xsd:extension base="myPatternType">...
1
by: Don Adams | last post by:
I would like to have the following XML: <phone type="work">555-123-1234</phone> <phone type="home">555-123-4321</phone> Is it possible to write a schema to restrict the contents of the type...
4
by: MichaelD | last post by:
Hi! How do I combine an element pattern with attributes? I can validate <phone>111-111-1111</phone> using pattern
6
by: Michael Hill | last post by:
I have this code that adds a table row and within the cells I create some input elements. When I go back using javascript the functionaliuty is seeing the form element. Anyone tell why I can see...
1
by: Sudhesh | last post by:
Hi, I understand I can write an XSD file like... <xs:attribute name = "value1" use="required"> <xs:simpleType> <xs:restriction base="xs:string"> <xs:maxLength value="30"/> </xs:restriction>...
2
by: Mark Bosley | last post by:
Well, despite reading an excellent article on ComplexTypes, I am unsure on the quickest way to express the following <myElem myAttrib="noMoreThan30chars"> No More than 30 chars </myElem> Both on...
0
by: Sudhesh | last post by:
Hi, I understand I can write an XSD file like... <xs:attribute name = "value1" use="required"> <xs:simpleType> <xs:restriction base="xs:string"> <xs:maxLength value="30"/> </xs:restriction>...
1
by: DrDavey | last post by:
What are the advantages/disadvantages of using a choice of a several "sub-"elements with empty content (and no attributes) vs. simple content. Here's an example: Using simple content:...
1
by: JavaXMLDev | last post by:
Hi I'm new to XML schema work, but wondered how, if at all possible, can you specify a relationship between the values of an element's attributes. Essentially I want context sensitive...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.