XML Schema Restriction With Attribute
xml, xsd
Solution
This is called a "complex type with simple content". Here's an example:
<xs:complexType>
<xs:simpleContent>
<xs:extension base="one-to-ten">
<xs:attribute name="type" type="xs:string" use="required"/>
</
</
</
<xs:simpleType name="one-to-ten">
<xs:restriction base="xs:integer">
<xs:minInclusive value="1"/>
<xs:maxInclusive value="10"/>
</
</
Problem
In XML Schema, how to make element `Age` to have `restriction` to allow writing integer with maximum value of 10 and minimum of 1, inside element `Age` but also element `Age` to have attribute ? ``` <xsd:element name="Age"> <xsd:complexType> here i want to have restriction to control max and min value inside Age element <xsd:attribute name="type" type="xsd:string" use="required" /> </xsd:complexType> </xsd:element> ``` XML Code with no warning ``` <Age type="sth"> 5 </Age> ``` XML Code with warning ``` <Age type="sth"> 22 </Age> ```