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

Discussion in 'XML' started by Rich Weed, Jul 16, 2003.

  1. Rich Weed

    Rich Weed Guest

    <name1>Joe Blough</name1>
    <name2>c/o Blough, Inc</name2>
    <addr1>123 Happy St</addr1>
    <addr2>PO Box 1234</addr2>

    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


    Remove NO SPAM to reply
    Rich Weed, Jul 16, 2003
    1. Advertisements

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.