Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > Making atleast one of multiple optional elements mandatory

Reply
Thread Tools

Making atleast one of multiple optional elements mandatory

 
 
ANoobee
Guest
Posts: n/a
 
      03-02-2007
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.

 
Reply With Quote
 
 
 
 
ANoobee
Guest
Posts: n/a
 
      03-02-2007
On Mar 2, 12:46 pm, "ANoobee" <avach...@gmail.com> wrote:
> 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.

 
Reply With Quote
 
 
 
 
Boris Kolpackov
Guest
Posts: n/a
 
      03-02-2007
"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>


hth,
-boris

--
Boris Kolpackov
Code Synthesis Tools CC
http://www.codesynthesis.com
Open-Source, Cross-Platform C++ XML Data Binding
 
Reply With Quote
 
usenet@tech-know-ware.com
Guest
Posts: n/a
 
      03-02-2007
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/
=============================================

 
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
OptionParser mandatory versus optional arguments byrnejb Ruby 0 07-15-2010 04:22 PM
XSD: complexType with mandatory and optional elements in arbitraryorder? Thomas Wittek XML 4 09-13-2007 12:04 PM
1st HD DVD Players To Decode All Mandatory, Optional Audio Codecs Allan DVD Video 0 04-10-2006 08:14 PM
XML Schema : How to ensure atleast one child element present ? Abhinav XML 1 07-22-2004 12:00 PM
Schema question regarding some mandatory/some optional values Piers Chivers XML 2 03-02-2004 09:49 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57