Reputation: 11
Hi guys I have a simple XML file with this structure
... ...
<Fields>
<Field name="MainJob.Id" value="t066_id">
<Description nullable="false" type="System.Int32" />
</Field>
What I have actually is this XSD file description:
<xs:element minOccurs="0" maxOccurs="unbounded" name="Fields">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" maxOccurs="unbounded" name="Field">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" maxOccurs="unbounded" name="Description">
<xs:complexType>
<xs:attribute name="nullable" type="xs:string" use="required" /> <xs:attribute name="type" type="xs:string" use="required" />
<xs:attribute name="minLength" type="xs:string" use="optional" />
<xs:attribute name="maxLength" type="xs:string" use="optional" />
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="name" type="xs:string" />
<xs:attribute name="value" type="xs:string" />
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
How I can define two only available values for the attribute nullable, like 'true' and 'false'? If I nest a SimpleType inside the attribute the .XSD file is not valid anymore. thank you
Upvotes: 1
Views: 914
Reputation: 754993
You can add a simpleType like so:
<xs:simpleType name="TrueOrFalse">
<xs:restriction base="xs:string">
<xs:enumeration value="false"/>
<xs:enumeration value="true"/>
</xs:restriction>
</xs:simpleType>
and then change your nullable to:
<xs:attribute name="nullable" type="TrueOrFalse" use="required" />
Marc
Upvotes: 0
Reputation: 2353
Type should be not xs:string
but xs:boolean
for your example, or you can use enumeration (example).
Upvotes: 1