I need to create a XSD 1.0 that validates a XML file.
The validation will use lxml.etree from python, and this tool is supporting just XML Schema 1.0 (lxml with schema 1.1)
The structure that I need to use is of type:
item
| owners*
| config+
| | config_id
| | tests*
| | picked?
| | capability*
| | | name
| | | value
Used notation are:
*
The element can occur zero or more times.+
The element can occur one or more times.?
The element is optional.
Elements in config tag can be in any order, this means that I can't use <sequence>
indicator. <all>
indicator is giving me the random order, but in this case the maxOccurs
is 1. <choice>
indicator with maxOccurs="unbounded"
will give me the random order and the multiple number of elements, but there will be no bottom limit for elements.
My XSD file looks something like:
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!--Schema version: 1.0, date: 29-02-2016-->
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<!-- definition of complex types -->
<xs:complexType name="capability_type">
<xs:sequence>
<xs:element name="name" type="xs:string" />
<xs:element name="value" type="xs:string" />
</xs:sequence>
</xs:complexType>
<xs:complexType name="config_type">
<xs:all>
<xs:element name="config_id" type="xs:string" />
<xs:element name="tests" type="xs:string" minOccurs="0"
maxOccurs="unbounded" />
<xs:element name="picked" type="xs:string" minOccurs="0" />
<xs:element name="capability" type="capability_type"
minOccurs="0" maxOccurs="unbounded" />
</xs:all>
</xs:complexType>
<xs:complexType name="item_type">
<xs:sequence>
<xs:element name="owners" type="xs:string" minOccurs="0"
maxOccurs="unbounded" />
<xs:element name="config" type="config_type" minOccurs="1"
maxOccurs="unbounded" />
</xs:sequence>
</xs:complexType>
<!-- definition of schema -->
<xs:element name="item" type="item_type" />
</xs:schema>
Using this schema I receive error:
element element: Schemas parser error : Element '{http://www.w3.org/2001/XMLSchema}element': Invalid value for maxOccurs (must be 0 or 1).
Is there any alternatives for my problem ?