views:

37

answers:

1

It seems I can't easily have an XSD declaration for this simple XML

<root>
    <weekday name="Sunday">1</weekday>
</root>

where weekday is a restricted int from 1 to 7 and has a name attribute of type string

Any advice?

Thanks for your support!

+1  A: 

Sure you can. You need a complex type (that adds the name attribute) derived from a simple type (that constrains the integer from one to 7):

<xs:simpleType name="NumericWeekday">
    <xs:restriction base="xs:int">
        <xs:minInclusive value="1"/>
        <xs:maxInclusive value="7"/>
    </xs:restriction>
</xs:simpleType>
<xs:complexType name="Weekday">
    <xs:simpleContent>
        <xs:extension base="NumericWeekday">
            <xs:attribute name="name" type="xs:string"/>
        </xs:extension>
    </xs:simpleContent>
</xs:complexType>

I will leave it to you to turn the name attribute into an enumeration.

xcut
Now I understand! Thanks a lot!
neurino