I have a problem with an XML schema. I need inside one element of an element of three types, but without any other restrictions, followed by exactly one occurrence of the element output:
<command path="app.exe" workingDir="/usr/local/bin">
<param name="--name" assign="=">anyName</param>
<switch name="--verbose"/>
<param name="--config">/etc/app/conf.txt</param>
<param name="--overriding">~/app/conf.txt</param>
<switch name="-d"/>
<param name="--report" assign="=">~/app/report.txt</param>
<param name="--template">~/app/templates/default.tt</param>
<string>../t/${testName}/log.txt</string>
<output>
<out path="stdout.txt"/>
<err path="stderr.txt"/>
</output>
</command>
I can use only sequence, allor choice, but none of them satisfies my requirement. Sequence - any number of times in the exact order. Everything is zero or once in any order. The choice is only one of them. I found one solution on this network , but it does not work with Xerces. I try this:
<xs:complexType name="commandType">
<xs:sequence>
<xs:group ref="gupa"/>
<xs:element name="output" type="outputType" minOccurs="1" maxOccurs="1"/>
</xs:sequence>
<xs:attribute name="path" use="required" type="value"/>
<xs:attribute name="workingDir" use="required" type="value"/>
</xs:complexType>
<xs:group name="gupa">
<xs:choice>
<xs:element name="env" type="pair" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="param" type="paramType" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="switch" type="switchType" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="string" type="value" minOccurs="0" maxOccurs="unbounded"/>
</xs:choice>
</xs:group>
But I get an error: Inappropriate content was found, starting with the 'switch' element. One of "{param, output}" is expected. There is a trick.
maxOccurs="unbounded" choice , .
, , : "maxOccurs" ""
, , .