On 12 Feb, 11:33, voorth <voo...@xs4all.nlwrote:
I was wondering if it is possible to define an restricted attribute
such that the following forms are both valid:
<myElement value="hi"/<!-- value should be "hi" or "lo" -->
<myElement value="100"/><!-- value should be between 50-150 -->
You can use XML schema xs:union construct to do this. Something along
the lines of:
<xs:attribute name="value">
<xs:simpleType>
<xs:union>
<xs:simpleType>
<xs:restriction base="xs:int">
<xs:minInclusive value="50"/>
<xs:maxInclusive value="150"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="hi"/>
</xs:restriction>
</xs:simpleType>
</xs:union>
</xs:simpleType>
</xs:attribute>
Although you probably don't want the string part as restricted as
this!
HTH,
Pete Cordell
Codalogic
Visit
http://www.codalogic.com/lmx/ for XML C++ data binding