0

Full error message:

[Error] try.xsd:5:15: cos-all-limited.2: The {max occurs} of an element in an 'all' model group must be 0 or 1. The value 'unbounded' for element 'Child2' is invalid.

I have the following XML documents:

One

<Parent>
       <Child1>value</Child1>
       <Child2>value</Child2>
       <Child3>value</Child3>
       <Child2>value</Child2>
       <Child3>value</Child3>
       <Child4>value</Child4>
       <Child5>value</Child5>
</Parent>   

Two

<Parent>
       <Child5>value</Child5>
       <Child1>value</Child1>
       <Child2>value</Child2>
       <Child3>value</Child3>
       <Child2>value</Child2>
       <Child3>value</Child3>
       <Child4>value</Child4>
</Parent>   

The elements appear in any order. So I defined the schema like this:

<xs:element name="Parent">
<xs:complexType>
    <xs:all>
      <xs:element name="Child1" type="xs:int"  minOccurs="0"/>
      <xs:element name="Child2" type="xs:string"  minOccurs="0" maxOccurs="unbounded"/>
      <xs:element name="Child3" type="xs:string"  minOccurs="0" maxOccurs="unbounded"/>
      <xs:element name="Child4" type="xs:string"  minOccurs="0"/>
      <xs:element name="Child5" type="xs:string"  minOccurs="0"/>
    </xs:all>
</xs:complexType>
</xs:element>

I am facing two issues:

  1. Unbounded is not allowed with xs:all.
  2. Is there any way to define a relationship between Child2 and Child3.
kjhughes
  • 106,133
  • 27
  • 181
  • 240

1 Answers1

0
  1. In XSD 1.0, children of xsd:all cannot be repeated. If Child2 and Child3 only can occur an unbounded number of times, use xs:sequence instead. In theory supporting unordered children under parent may match your actual constraints slightly better, but in practice, imposing an order rarely matters and often helps such as in cases like this.
  2. Yes, there are ways to define a relationship between Child2 and Child3, but to be more specific than that, you'd have to indicate the sort of relationship you have in mind.
kjhughes
  • 106,133
  • 27
  • 181
  • 240