I\'m having quite a hard time on constructing my 1st XML Schema. I need it to verify the correctness of an XML document that forms a questionnaire.
So here\'s the sectio
I don't know, what should be validated exactly, but the following xml schema would validate for three value tags within a values tag within a root tag. The values has to be strings:
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://yourSchema">
<xsd:element name="root">
<xsd:complexType>
<xsd:sequence>
<xsd:element ref="values" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="values">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="3" maxOccurs="3" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
This should do it for the 1st xml:
<xs:complexType name="Values">
<xs:sequence>
<xs:element name="value" minOccurs="0" maxOccurs="200">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute name="isOnlyOption" type="xs:boolean"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
<xs:element name="values" type="Values" minOccurs="0"/>
The 2nd one looks like this:
<xs:element name="requires" minOccurs="0">
<xs:complexType>
<xs:sequence>
<xs:element name="require" minOccurs="1" maxOccurs="200">
<xs:complexType>
<xs:attribute name="requires-id" type="xs:IDREF"/>
<xs:attribute name="type" type="RequiresType"/>
<xs:all>
<xs:element name="values" type="Values" minOccurs="0" maxOccurs="1"/>
</xs:all>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
Note the reference to the custom data type 'Values' from the 1st snippet.
Thanks,
Steff