is it possible to create a schema where the children of an element would be partialy in a sequence and partiali not? something like this:
<xs:element name="rootElement">
<xs:complexType>
<xs:all>
<xs:element name="value1" type="xs:string"/>
<xs:element name="value2" type="xs:string"/>
</xs:all>
<xs:sequence>
<xs:element name="value3" type="xs:string"/>
<xs:element name="value4" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
Thanks in advance!
OK. I think I understand you know. Your XML looks like:
You want the
ownerNameandownerLastNameelements to occur in any order although they must both be present. It’s not clear from your description it the position of theroomselement is important. I have assumed it is. It’s import that the child elements ofroomsremain in order.Splitting this up, we can define a
complexTypefor rooms (so the model is complete)This gives us the sequence of rooms in order.
There are quite a few limitations on the use of
xs:allso I’ve avoided it here (you can’t use in a sequence, for example). In order to allow the owner names to occur in any order, I’ve used a choice of two sequences. The choice is embedded in another sequence to ensure that theroomselement comes last.Now, if you actually don’t care about the order or
ownerLastName,ownerNameandhousethen you can usexs:allwithout a problem:which requires that you have all three elements present in any order.