Home > Articles > Web Services > XML

  • Print
  • + Share This
From the author of

Simple Content

A complex type that specifies simple content provides the ability to extend simple types, and to add attribute types to what might otherwise be a simple type. If the complex type is a restriction of another complex type, attribute types might be removed instead. The following complex type specifies that a priceType, which specifies a floating point number, has an attribute type that determines the currency units.






<xsd:complexType name="priceType">
  <xsd:simpleContent>
    <xsd:extension base="xsd:float">
      <xsd:attribute name="currency"
              type="xsd:token"/>
    </xsd:extension>
  </xsd:simpleContent>
</xsd:complexType>

An element type whose structure type is priceType might look like the following element:

<xsd:element name="price" type="priceType"/>

Given the preceding element type, the following element is valid in an XML instance:

<price currency="U S Dollars">38.00</price>
  • + Share This
  • 🔖 Save To Your Account