Hi all

I'm looking for a shema solution since a while. The idea is to have one parent element which stores 2 elements of different name. At least one of them must occur, but it is not defined which. It must not be possible to repeat one element twice (child1 should occurs maximum once).

My idea is something like this:
Code:
<xs:element name="parent">
	<xs:complexType>
		<xs:sequence>
			<xs:choice maxOccurs="2">
				<xs:element name="child1" minOccurs="0"/>
				<xs:element name="child2" minOccurs="0"/>
			</xs:choice>
		</xs:sequence>
	</xs:complexType>
</xs:element>
Generating a sample xml with XMLSpy shows, that this doesn't work.
Code:
<parent>
	<child1>text</child1>
	<child1>text</child1>
</parent>
Wrong in the example xml is:
it is
  • possible to repeat child1 (or child2) two times
  • it is possible to declare a parent without child elements


Do you have an idea how to solve this problem?

Thank you.

Kind regards