I want to make sure, that <specials/>
can be optional, but when it occurs, I want to make sure, that it has at least one <special>
.
Imagine the following XML:
<software>
<programm id="123">
<name>Editor</name>
<specials>
<special>Something really special here</special>
<special>Something special as well</special>
</specials>
</programm>
<programm id="456">
<name>Another Editor</name>
</programm>
</software>
My tried XSD for this is. This won't throw a validation error, if there is just <specials></specials>
but no children inside.
<xs:element name="software">
<xs:complexType>
<xs:sequence>
<xs:element name="programm" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="name" type="xs:string" minOccurs="1"/>
<xs:element name="specials" minOccurs="0">
<xs:complexType>
<xs:sequence minOccurs="1">
<xs:element name="special" type="xs:string" minOccurs="1"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="id" type="programmID"/>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>