Get exactly one choice element

M

Mario

Hi;

I try to limit the selection of elements to exactly one. I have to do
it by using elements, attributes are no alternativ.
If I use the configuration shown below, it is also possible to select
no element. If I set minOccurs to 1 at both elements, I have to select
both. How I can can define that just one and no more than one element
are allowed?

Thx for your help!


If I have the following xsd:
----------------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="test">
<xs:complexType>
<xs:choice>
<xs:element name="element1" minOccurs="0"/>
<xs:element name="element2" minOccurs="0"/>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>

and the following xml should not be allowed:
 
P

Priscilla Walmsley

Hi,

If you use minOccurs="1", you don't need to have both elements present.
Because you're using the <choice> group, it's a choice of one (and only
one) of those elements.


Hope that helps,
Priscilla
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,233
Members
46,821
Latest member
AleidaSchi

Latest Threads

Top