Home > Articles > Web Services > XML

  • Print
  • + Share This
From the author of

Shorthand Notation

A complex type always has an associated content specification (even empty content is an explicit content specification). Each complex type specifies its content as either simple or complex. The corollary XML representation is simpleContent or complexContent.

The XML Schema syntax permits a shorthand notation where a complexType element does not explicitly contain either a simpleContent or a complexContent element. With the shorthand notation—when the content type is not explicit—the processor infers complexContent that restricts a base of anyType.

The next two complex types are functionally equivalent. First, the shorthand XML representation of a slightly simplified partOptionType:

<xsd:complexType name="partOptionType">
  <xsd:all>
    <xsd:element name="color" type="xsd:token"/>
    <xsd:element name="size" type="xsd:token"/>
  </xsd:all>
</xsd:complexType>

Here is the longhand XML representation of the previous element:

<xsd:complexType name="partOptionType">
  <xsd:complexContent>
    <xsd:restriction base="xsd:anyType">
      <xsd:all>
        <xsd:element name="color"
               type="xsd:token"/>
        <xsd:element name="size"
               type="xsd:token"/>
      </xsd:all>
    </xsd:restriction>
  </xsd:complexContent>
</xsd:complexType>
  • + Share This
  • 🔖 Save To Your Account