Element Declarations: Simple Type

A simple type element cannot contain child elements or attributes. The simple type element declaration is:

    <xs:element name="element_name" type="data_type"
    default/fixed="value" />

where:

  • element_name indicates the name of the element.
  • data_type indicates the data type specified for the element. XML schema provides built-in data types, such as xs:string, xs:date, xs:time, xs:decimal, and xs:boolean.
  • value indicates the default or fixed value for the element. The default/fixed keyword is optional.

For example, in the following code snippet, firstname is the name of an element and xs:string indicates that the string data type is specified for the firstname element. Therefore, the firstname element can contain only character strings.

    <xs:element name="firstname" type="xs:string" />

Similarly, the lastname element can be declared as:

    <xs:element name="lastname" type="xs:string" />

 

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:element name="EmpName">
    <xs:complexType>
      <xs:sequence>
        <xs:element name="firstname"
        type="xs:string" />
        <xs:element name="lastname"         type="xs:string" />

      </xs:sequence>
    </xs:complexType>
</xs:element>
// Additional declarations...

Click the Next button to continue.