user3663368
user3663368

Reputation: 3

XSD nested sequence tags. Is this valid XSD?

Is this XSD fragment valid?

  <xs:complexType name="ShippingPointStructure">
    <xs:sequence>
      <xs:element minOccurs="0" maxOccurs="unbounded" ref="DeliveryID" />
      <xs:element minOccurs="0" ref="DeliveryDate" />
      <xs:sequence minOccurs="0" maxOccurs="unbounded">
        <xs:element minOccurs="0" ref="WarehouseID" />
        <xs:element minOccurs="0" ref="LocationID" />
      </xs:sequence>
      <xs:element minOccurs="0" ref="Address" />
    </xs:sequence>
  </xs:complexType>

I have never seen a sequence node as a direct child of another sequence node. I've googled for awhile but can't find an answer. The XSD file has been run through some online validators with success - but I suspect they are only checking for XML validity.

Can anyone suggest what the XML may need to look like? Something like this perhaps:

<ShippingPointStructure>
    <DeliveryID></DeliveryID>
    <DeliveryDate></DeliveryDate>

    <WarehouseID></WarehouseID>
    <LocationID></LocationID>
    <WarehouseID></WarehouseID>
    <LocationID></LocationID>
    <WarehouseID></WarehouseID>
    <LocationID></LocationID>

    <Address></Address>
</ShippingPointStructure>

Any help appreciated.

Background:

This is fragment of an official XSD file provided by a European government department. I cannot contact the creator as it comes through several layers of clients.

Upvotes: 0

Views: 174

Answers (1)

Michael Kay
Michael Kay

Reputation: 163458

Yes, the schema is valid and your interpretation of its meaning is correct.

It's similar to a DTD content model

(ID?, Date?, (Warehouse?, Location?)? Address?)

The minOccurs=0 on the nested sequence is redundant, and makes the content model weakly ambiguous, because if a group can be empty then you can't really count how often it occurs. But that kind of weak ambiguity is permitted in XSD.

Upvotes: 2

Related Questions