473,385 Members | 1,647 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,385 software developers and data experts.

How do I allow both elements or No elements

I have a current xsd that allows the xml to have 0..1 chassisid element
and 0..1 terminalid element. But now I want to restrict these elements
in a way that either both chassisid and terminalid are supplied or
neither are supplies never just one of the elements is ever supplied.
I believe this can be done but the restriction I have is that I cannot
change the structure of the xml file, i.e. by nesting a new section for
chassisid/terminalid.

e.g.

xsd:
....
<xs:element name="chassisid" type="xs:string" minOccurs="0"
maxOccurs="1"/>
<xs:element name="terminalid" type="xs:string" minOccurs="0"
maxOccurs="1"/>
....

xml:
....
<chassisid>A123456789</chassisid>
<terminalid>A2345678</terminalid>
....

If you can help then many thanks.

Regards

Billy

Sep 9 '05 #1
4 1133
How about:

<xs:sequence minOccurs="0" maxOccurs="1">
<xs:element name="chassisid" type="xs:string"/>
<xs:element name="terminalid" type="xs:string"/>
</xs:sequence>

Hope that helps,
Priscilla

----------------------------------
Priscilla Walmsley
Author, Definitive XML Schema
http://www.datypic.com
----------------------------------

*** Sent via Developersdex http://www.developersdex.com ***
Sep 9 '05 #2
Billy wrote:
I have a current xsd that allows the xml to have 0..1 chassisid element
and 0..1 terminalid element. But now I want to restrict these elements
in a way that either both chassisid and terminalid are supplied or
neither are supplies never just one of the elements is ever supplied.


<xs:complexType>
<xs:sequence minOccurs="0" maxOccurs="1">
<xs:element ref="chassisid"/>
<xs:element ref="terminalid"/>
</xs:sequence>
</xs:complexType>

--
Klaus Johannes Rusch
Kl********@atmedia.net
http://www.atmedia.net/KlausRusch/
Sep 9 '05 #3
Thanks for your time,

It looks pretty simple and unsure why I haven't tried that already. I
will try it Monday when I get back to work.

Once again, thanks

Billy

*** Sent via Developersdex http://www.developersdex.com ***
Sep 11 '05 #4
It works a treat, many thanks Priscilla & Klaus.

Billy

Sep 12 '05 #5

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

Similar topics

10
by: KathyB | last post by:
Hi, I just can't get this quite right. I use the following function to validate a user entry. I need to allow negative numbers including those with decimals (e.g., -.5). The following allows the...
1
by: Jeremy Chapman | last post by:
I want to create an xsd so that I can validate xml against it. All I care is that the root node (named brl) exists in the document. Any other node can go inside it. If I validate an xml file...
4
by: moondaddy | last post by:
There are different times when I will have a group of checkboxes and need to force only one to be checked at a time. I would also like to do this client side and not require a postback. These...
6
by: jeet_sen | last post by:
Hi, I have generated a table and have attached a pop up to display at onmouseover event of each cell. For each cell the pop up will display cell specific detailed data. I have generated the pop...
11
by: Mr. Ken | last post by:
For example, int arr; arr = {1,2,3,4,5};
1
by: vikas.khengare | last post by:
Hi friends I want to allow left click only on some controls but not on all controls like textbox/span elements. I have near about 30+ HTML controls on my web page. then It's bad idea that I...
20
by: quantumred | last post by:
I found the following code floating around somewhere and I'd like to get some comments. unsigned char a1= { 5,10,15,20}; unsigned char a2= { 25,30,35,40}; *(unsigned int *)a1=*(unsigned int...
0
by: Douglas J. Badin | last post by:
Hi, The problem with Authorization is it stops at the first match and doesn't permit Grouping. On the Web Site, I am trying to Secure Page Access and SiteNaviagation by implementing the...
18
by: =?Utf-8?B?VG9t?= | last post by:
is it possible to add a bunch of users to group and only allow group to access the web page or do I need to add each user to the web.config file? Or is there another way to do this? I just took...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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...

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.