B
bogus1one
To all you XML experts, let's say I have the following in an XML doc:
<heading units="TRUE">55</heading>
I would like to develop a schema that will both provide for an
enumeration for the attribute and restrict the input to some range of
values. In the example above, I want the enumeration to be restricted
to TRUE and MAG. And, I want the valid values the text to be 0 through
359. I seem to be able to get one or the other but not both. This is
what I have currently:
<xs:element name="heading">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:unsignedShort">
<xs:attribute name="units" use="required">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="TRUE"/>
<xs:enumeration value="MAG"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
It is my understanding that facets can only be applied to simple types
and that once you add an attribute to an element, it becomes a complex
type. So, how do you work around this?
Thanks for your help.
<heading units="TRUE">55</heading>
I would like to develop a schema that will both provide for an
enumeration for the attribute and restrict the input to some range of
values. In the example above, I want the enumeration to be restricted
to TRUE and MAG. And, I want the valid values the text to be 0 through
359. I seem to be able to get one or the other but not both. This is
what I have currently:
<xs:element name="heading">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:unsignedShort">
<xs:attribute name="units" use="required">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="TRUE"/>
<xs:enumeration value="MAG"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
It is my understanding that facets can only be applied to simple types
and that once you add an attribute to an element, it becomes a complex
type. So, how do you work around this?
Thanks for your help.