I would like to use conditions in my XSD schema for my XML document.
I used restrictions but it's not quite powerful.
Here is an example of what I did so far:
<xs:element name="Matricule">
<xs:complexType>
<xs:sequence>
<xs:element name="valeur">
<xs:simpleType>
<xs:restriction base="xs:integer">
<xs:minInclusive value="0"></xs:minInclusive>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element type="xs:string" name="backgroundcolor"/>
</xs:sequence>
</xs:complexType>
</xs:element>
This example works fine but I check just if the value is greater than 0. But I would like to verify if the value is an Integer AND if the value is empty.
Maybe something like that:
If (value > 0 AND value < 100 AND value = '')
I found on Google a subject who calls about assertion, so I read the document and I did that
<xs:element name="Matricule">
<xs:complexType>
<xs:sequence>
<xs:element name="valeur">
<xs:simpleType>
<xs:restriction base="xs:integer">
<xs:minInclusive value="0"></xs:minInclusive>
**<xs:assertion test="($value mod 10) = 0"/>**
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element type="xs:string" name="backgroundcolor"/>
</xs:sequence>
</xs:complexType>
</xs:element>
But it doesn't work, I always have an error.
Exemple 1 with value :
<racine>
<row>
<Matricule>
<valeur>55</valeur>
<backgroundcolor></backgroundcolor>
</Matricule>
</row>
</racine>
Exemple 2 without value :
<racine>
<row>
<Matricule>
<valeur></valeur>
<backgroundcolor></backgroundcolor>
</Matricule>
</row>
</racine>
These two examples need to be correct but this one no :
<racine>
<row>
<Matricule>
<valeur>gfd</valeur>
<backgroundcolor></backgroundcolor>
</Matricule>
</row>
</racine>