XML Schema Q: Preventing an empty element of a complex type

R

Rich Weed

<root>
<contact>
<name1>Joe Blough</name1>
<name2>c/o Blough, Inc</name2>
<addr1>123 Happy St</addr1>
<addr2>PO Box 1234</addr2>
<city>Anywhere</city>
<state>GA</state>
<zip>12345</zip>
</contact>
</root>

I have an XML Schema for the above structure. All the child elements of
<contact> are optional (minOccurs=0), of type string, and not allowed to be
empty (minLength=1) (whitespace is allowed...so a single space is valid).

Since the child elements are all optional, the schema does currently allow
an empty <contact> element as '<contact />' or '<contact></contact>'.

Q: How do I prevent the appearance of <contact /> from being valid? In
other words how do I force at least one child element to be present when
<contact> is present?

TIA, RW
 

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
474,001
Messages
2,570,254
Members
46,850
Latest member
VMRKlaus8

Latest Threads

Top