How do I allow both elements or No elements

B

Billy

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
 
P

Priscilla Walmsley

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
 
K

Klaus Johannes Rusch

Billy said:
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>
 
B

Billy boy

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
 

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

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,013
Latest member
KatriceSwa

Latest Threads

Top