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

Making atleast one of multiple optional elements mandatory

What is the best approach to force atleast one of a few optional
elements required in an XSD?
This is what I'm tring to do:

<email>
<to>
<cc>
<bcc>
</email>

where to, cc and bcc are optional but email should contain atleast one
of them.

Thanks for any inputs.

Mar 2 '07 #1
3 2062
On Mar 2, 12:46 pm, "ANoobee" <avach...@gmail.comwrote:
What is the best approach to force atleast one of a few optional
elements required in an XSD?
This is what I'm tring to do:

<email>
<to>
<cc>
<bcc>
</email>

where to, cc and bcc are optional but email should contain atleast one
of them.

Thanks for any inputs.
Additional information...
The order in which the to, cc and bcc occur does not matter and each
of them will be un-bounded.

Mar 2 '07 #2
"ANoobee" <av******@gmail.comwrites:
What is the best approach to force atleast one of a few optional
elements required in an XSD?
This is what I'm tring to do:

<email>
<to>
<cc>
<bcc>
</email>

where to, cc and bcc are optional but email should contain atleast one
of them.

Additional information...
The order in which the to, cc and bcc occur does not matter and each
of them will be un-bounded.

You can use sequence of choice's for that:

<complexType name="email">
<sequence maxOccurs="unbounded">
<choice>
<element name="to" type="string"/>
<element name="cc" type="string"/>
<element name="bcc" type="string"/>
</choice>
</sequence>
</complexType>
hth,
-boris

--
Boris Kolpackov
Code Synthesis Tools CC
http://www.codesynthesis.com
Open-Source, Cross-Platform C++ XML Data Binding
Mar 2 '07 #3
On 2 Mar, 19:49, Boris Kolpackov wrote:
"ANoobee" writes:
What is the best approach to force atleast one of a few optional
elements required in an XSD?
This is what I'm tring to do:
<email>
<to>
<cc>
<bcc>
</email>
where to, cc and bcc are optional but email should contain atleast one
of them.
Additional information...
The order in which the to, cc and bcc occur does not matter and each
of them will be un-bounded.

You can use sequence of choice's for that:

<complexType name="email">
<sequence maxOccurs="unbounded">
<choice>
<element name="to" type="string"/>
<element name="cc" type="string"/>
<element name="bcc" type="string"/>
</choice>
</sequence>
</complexType>
Or even:

<complexType name="email">
<choice maxOccurs="unbounded">
<element name="to" type="string"/>
<element name="cc" type="string"/>
<element name="bcc" type="string"/>
</choice>
</complexType>

Pete.
--
=============================================
Pete Cordell
Tech-Know-Ware Ltd
for XML to C++ data binding visit
http://www.tech-know-ware.com/lmx/
http://www.codalogic.com/lmx/
=============================================

Mar 2 '07 #4

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

Similar topics

3
by: Phil Powell | last post by:
Has anyone here ever done a case where you have a select multiple form element and you have to do both server-side and client-side validation? I am honestly not sure how to do it in Javascript (I...
1
by: Kenneth McDonald | last post by:
I'm working on the 0.8 release of my 'rex' module, and would appreciate feedback, suggestions, and criticism as I work towards finalizing the API and feature sets. rex is a module intended to make...
3
by: Pablo Gomes Ludermir | last post by:
Hello, I have the following case that I am trying to put in XML Schema. I have the classes HelpItem, Document and Message that work as follows: One HelpItem contains several Document and...
4
by: MT | last post by:
Hi all, this sounds like an easy enough thing to do, but after spending 45 minutes searching google and various javascript sites I can't find out how to make a textfield (textbox or whatever you...
0
by: kosaraju.puneeth | last post by:
I am using Xml schema based validation for XML files. * I have attributes of Required,optional and anyAttribute type. Now can i validate my XML file in such a way that under a particular...
2
by: Lisa | last post by:
I have to work with an existing xml where there is a root element and all other elements are children of the root (in other words there is no nesting or hierarchy), e.g. <myroot> <A>adata</A>...
6
by: Daniel Nichols | last post by:
I've noticed that in a C module (.c, .h file combination) that if you create a function's definition before it is used in other functions than a declaration is not necessary. I believe if the...
1
by: Le Tubs | last post by:
Hi I am wondering if anybody has come accross this problem before, basically I have to validate a xml schema (not the data, this is done at a later stage). The only problem is that there are...
1
by: Tookelso | last post by:
Hello, I would like to have a group of elements which are *required* in one context, but each one is *optional* in another context. For example: I have a configuration file which has a...
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: 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?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
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...

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.