Adding complex types

A complex type allows elements in its content and can carry attributes. Complex types can be used to help determine the appropriate content for any instance documents generated from or associated with your XML schema.

You can add as many complex types as you want to an XML schema.

The following instructions were written for the Resource perspective, but they will also work in many other perspectives.

To add a complex type to an XML schema, complete the following steps:

  1. Open your XML schema in the XML schema editor.
  2. Right-click the Types category in the Design view, and click Add Complex Type.
  3. In the Properties view, type a new name for the complex type in the Name field.
  4. Select Browse in the Inherited From drop down to select a base type for your complex type. You can either set a base type for your complex type, or you can add a content model to it (which represents any data that can be contained inside an element), but you cannot do both. For more information about content models, see Adding content models.
  5. Select restriction or extension from the Inherited By list. This specifies whether your type is derived from its base type by restriction or extension.
  6. The Design view will display the attributes within the complex type. You can also use this view to add attributes to your complex type. An attribute associates an attribute name with a specific type and value. To add an attribute, in the Design view, right click your complex type and select Add Attribute.
    • name. In the Design view, click the name of the attribute to make a change.
    • type. In the Design view, click the type of the attribute to make a change. The drop-down menu provides commonly used types. For more options, simply select Browse from the menu.
    For information about adding attributes, attribute references, and any attributes, see Adding attribute groups.
  7. Click the Documentation tab if you want to provide any information about this complex type. The Documentation page is used for human readable material, such as a description.
  8. Click the Extensions tab if you want to add application information elements to your annotations of schema components. The Extensions page allows you to specify the schema and add XML content to your annotations.
Related tasks
Adding content models