I have an element that can have a different structure depending on certain constraints. The element is defined as:
<xs:complexType name="MyElement">
<xs:sequence>
<xs:element name="Child"/>
<xs:element name="Child1" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
I also have an element that has several MyElement
. But I want to be able to say that
I don’t want a solution; I want to know what technology you would use to solve this kind of problem. Schema only or Schema and Schematron? I am interested in knowing the scope of XML Schema and Schematron.
You would need to use Schematron with Schema 1.0.
Schema does not have the facility to express the conditional logic that you describe. Schematron is perfect for this scenario and could easily be used to encode and validate these validation rules.
It may be possible to define such restrictions/validations using Schema 1.1 assertions.