I want to create a XSD schema which is valid for both type of XML file:
<caption>
<tt>blah</tt>
</caption>
and
<tt>blah</tt>
And I tried minOccurs
for caption but as it is the root it can't be minOccurs = 0
times. So, how to achieve this?
Just a tip
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified">
<!-- First possible root element -->
<xs:element name="tt" type="xs:string"/>
<!-- Second possible root element-->
<xs:element name="caption">
<xs:complexType>
<xs:sequence>
<!-- just reference to first defined element - when something change there, it won't be necessary to change it everywhere -->
<xs:element ref="tt" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
Obviously there are other ways how to reach the same effect.