Content model ambiguity in a schema

kustom

New Member
Maybe I've been staring at this problem for too long, maybe there isn't an answer; either way I'm here now.I'm trying to permit a set of possible combinations in an XSD, but I can't seem to find an approach that doesn't result in ambiguity.Quick regexy respresentation:\[code\]foo+ ( bar baz* | bar? baz+ qux* )\[/code\]
  • \[code\]foo\[/code\] is required (one-or-more)
  • If \[code\]bar\[/code\] exists, \[code\]baz\[/code\] is optional (zero-or-more)
  • If \[code\]baz\[/code\] exists, \[code\]bar\[/code\] is optional (zero-or-one) and \[code\]qux\[/code\] is optional (zero-or-more)
  • \[code\]qux\[/code\] can not exist if \[code\]baz\[/code\] does not exist
Ambiguity arises given \[code\]foo bar baz\[/code\].Ambiguous XSD document:\[code\]<xs:element name="parent"> <xs:complexType> <xs:sequence> <xs:element name="foo" minOccurs="1" maxOccurs="unbounded" /> <xs:choice> <xs:sequence> <xs:element name="bar" minOccurs="1" maxOccurs="1" /> <xs:element name="baz" minOccurs="0" maxOccurs="unbounded" /> </xs:sequence> <xs:sequence> <xs:element name="bar" minOccurs="0" maxOccurs="1" /> <xs:element name="baz" minOccurs="1" maxOccurs="unbounded" /> <xs:element name="qux" minOccurs="0" maxOccurs="unbounded" /> </xs:sequence> </xs:choice> </xs:sequence> </xs:complexType></xs:element>\[/code\]Screen capture for good measure:
rYqMF.png
Now, I'm beginning to realize that perhaps this is simply a constraint of the XSD content model. The reason for ambiguity is obvious; the solution not so.Can anyone see a means with which I can permit this; by re-ordering the elements, through use of some schema design pattern to alleviate ambiguous scenarios like this?The condition dependency of \[code\]bar\[/code\] and \[code\]baz\[/code\] is clearly the problem, but I can't think of any other way to do this.Thanks so much in advance folks.Edit: Currently reading "Schema Component Constraint: Unique Particle Attribution" in an attempt to find a loop-hole. Any other suggested reading welcome.
 
Back
Top