controlling maxOccurs for nested elements, without enforcing sequence

BuhesoreNer

New Member
I wish to define an XSD (v1.0 based) that enforces the following rules...I have a parent1 element, which can have the following child elements child1, child2, and child3.
  • parent1 can have 0-1 of child1
  • parent1 can have 0-1 of child2
  • parent1 can have 0 - unbounded of child3
The order of the items is not important. E.g.\[code\]<parent1> <child3/> <child1/> <child2/> <child3/> <child3/></parent1>\[/code\]I've gotten close, but no cigar. The closest I can get is the enforcing of the min and max occurs, but the order is enforced.\[code\]<xsd:element name="parent1" minOccurs="0" maxOccurs="unbounded"> <xsd:complexType> <xsd:sequence> <xsd:element name="child1" minOccurs="0" maxOccurs="1"/> <xsd:element name="child2" minOccurs="0" maxOccurs="1" /> <xsd:element name="child3" minOccurs="0" maxOccurs="unbounded"/> </xsd:sequence> </xsd:complexType></xsd:element>\[/code\]I've tried using all instead of sequence, but that limits maxOccurs to 1 for the child elements. I've also tried using choice with a maxOccurs to replace sequence, but that doesn't limit how many child1 or child2 elements you can have beneath parent1.Edit: this is for XSD v1.0I've found a solution that works for XSD 1.1, but when you see how well supported it is in the likes of Eclipse, I'll try and stick with 1.0.
 
Back
Top