LibraryLink ToToggle FramesPrintFeedback

Defining types by extension

Like most major coding languages, XML Schema allows you to create data types that inherit some of their elements from other data types. This is called defining a type by extension. For example, you could create a new type called alienInfo, that extends the personalInfo structure defined in Example 2.4 by adding a new element called planet.

Types defined by extension have four parts:

  1. The name of the type is defined by the name attribute of the complexType element.

  2. The complexContent element specifies that the new type will have more than one element.


    If you are only adding new attributes to the complex type, you can use a simpleContent element.

  3. The type from which the new type is derived, called the base type, is specified in the base attribute of the extension element.

  4. The new type’s elements and attributes are defined in the extension element, the same as they are for a regular complex type.

For example, alienInfo is defined as shown in Example 2.13.

Example 2.13. Type defined by extension

<complexType name="alienInfo">
    <extension base="personalInfo">
        <element name="planet" type="xsd:string"/>