I've been looking at this issue for too long. I suspect I'm missing something obvious because I'm overfamiliar with it.
I have a schema that suffers from a unique particle violation error. I can see why but I've spent too long fiddling with it to be able to step back and solve the problem.
How do I phrase this schema so that it can validate the content I need to model?
The content model looks something like:
<document>
<extract>...</extract>
<structure>...</structure>
<structure>...</structure>
</document>
OR
<document>
<structure>...</structure>
<structure>...</structure>
</document>
OR
<document>
<extract>...</extract>
<extract>...</extract>
</document>
That is a document element can contain either one or more extract elements or one or more structure elements or it can contain a single extract element followed by one or more structure elements.
I have an (incorrect) schema that looks like:
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="document" type="Document"/>
<xs:complexType name="Document">
<xs:choice>
<xs:sequence>
<xs:element ref="extract" minOccurs="0"/>
<xs:element ref="structure" minOccurs="1" maxOccurs="unbounded"/>
</xs:sequence>
<xs:element maxOccurs="unbounded" ref='extract'/>
</xs:choice>
</xs:complexType>
<xs:element name="extract" type="xs:string"/>
<xs:element name="structure" type="xs:string"/>
</xs:schema>
(This is a stripped down verision of a much more complex schema).
cheers
nic