473,659 Members | 2,965 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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:simpleTyp e>
<xs:restricti on 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 4050
On 18 Oct, 15:04, execute...@gmai l.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:simpleTyp e>
<xs:restricti on 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:simpleTyp e name="shortStri ng">
<xs:restricti on base="xs:string ">
<xs:maxLength value="2"/>
</xs:restriction>
</xs:simpleType>

<xs:element name="kirk" minOccurs="0" maxOccurs="1">
<xs:complexType >
<xs:simpleConte nt>
<xs:extension base='shortStri ng'>
<xs:attribute name='a1' type='xs:int'/>
<xs:attribute name='a2' type='xs:int'/>
</xs:extension>
</xs:simpleConten t>
</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
3591
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"> <xsd:attribute name="myAttr" type="myAttrType"
1
1570
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 attribute to be enumerated ("work" or "home") AND restrict the contents of the <phone> element to match the pattern \d\d\d-\d\d\d-\d\d\d\d ? I know how to do one or the other, but I haven't figured out a way
4
6631
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
2019
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 them? <form name='update'> myTR=document.createElement("TR"); myTR.setAttribute("id","RESULTS4"); // create cell 1 and content myTD=document.createElement("TD");
1
406
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> </xs:simpleType>
2
1075
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 the string are SimpleContent, right? Thanks, Mark BTW the article is
0
966
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> </xs:simpleType> </xs:attribute>
1
1699
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: <process>xyz</process> Using empty content sub-element: <process><xyz/></process>
1
1994
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 auto-complete for the attribute values of an element when creating an XML document. I dont know how to define the relationship ! Scenario: When using a location element and selecting the school value for the type attribute I would like to restrict...
0
8428
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8335
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8851
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8528
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6179
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5649
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4335
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1976
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1737
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.