Anything wrong with this schema?

lozina

Lifer
Sep 10, 2001
11,711
8
81
I created a xml schema which we've been using for a while and now another application is looking to integrate with us and I sent them the schema and they are saying the schema is no good, that they cannot import it into their tool.

I am thinking their tool has a bug but I dont know, can you guys tell me if this schema syntax is no good? (renamed elements)

(see below next post)

They say everything imports fine until they get to the elements inside the choice section - that the address and group dont show up properly.

Basically the point of the way it is structured is that basicdata is required and shows up only once, while the stuff under the choice are optional, can occur one or more times, and the order does not matter.
 
Last edited:

lozina

Lifer
Sep 10, 2001
11,711
8
81
Code:
[FONT=&quot]<xs:element name="customers">
  <xs:complexType>
    <xs:sequence>  
      <xs:element name="customer" minOccurs="1">  
        <xs:complexType>    
          <xs:sequence>      
            <xs:element ref="[/FONT]basicdata[FONT=&quot]"/>
            <xs:choice minOccurs="0" maxOccurs="unbounded">
              <xs:element ref="address" minOccurs="0"/>
              <xs:element ref="group" minOccurs="0"/>
            </xs:choice>
          </xs:sequence>
          <xs:attribute name="id" type="xs:int"/>
        </xs:complexType>
      </xs:element>
    </xs:sequence>
  </xs:complexType>
</xs:element>[/FONT]

whoops meant to edit OP sorry
 

MrChad

Lifer
Aug 22, 2001
13,507
3
81
I don't think xs:choice works that way. What you want is:

Code:
<xs:element name="customers">
  <xs:complexType>
    <xs:sequence>  
      <xs:element name="customer" minOccurs="1">  
        <xs:complexType>    
          <xs:sequence>      
            <xs:element ref="basicdata"/>
            <xs:element ref="address" minOccurs="0" maxOccurs="unbounded"/>
            <xs:element ref="group" minOccurs="0" maxOccurs="unbounded"/>
          </xs:sequence>
          <xs:attribute name="id" type="xs:int"/>
        </xs:complexType>
      </xs:element>
    </xs:sequence>
  </xs:complexType>
</xs:element>
 
Last edited: