Adding import elements

As schemas become larger, it is often desirable to divide their content among several schema documents for purposes such as ease of maintenance, reuse, and readability. You can use an import element to bring in definitions and declarations from an imported schema into the current schema.

The imported schema can come from a different namespace than the current schema does. You can add multiple import elements to an XML schema, however, prefixes and namespaces have to unique amongst the imported schemas.

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

To add an import element, complete the following steps:

  1. Open your XML schema in the XML schema editor. In the Outline view, select your schema. The entire schema and its contents should be displayed in the Design view.
  2. In the Design view, right click in the Directives section and click Add Import.
  3. In the Properties view, click the General tab and click the Browse This
graphic is the Browse button button to the right of the Schema location field.
  4. If you want to import an XML schema located in the workbench:
    1. Select Workbench projects and click Next.
    2. Select the schema you want to import and click Finish.
  5. If you want to import an XML schema located on the Web:
    1. Select HTTP and click Next.
    2. Type the URL of the XML schema and click Finish.
      Note: A local copy of the schema will not be stored in the workbench. Every time you validate your schema, the schema's contents will be checked from the URL you specify.
  6. The XML schema editor will retrieve the namespace for the imported XML schema file and display it as read-only in the Namespace field.
  7. If necessary, type a unique prefix for this namespace in the Prefix field.
  8. Click the Documentation tab if you want to provide any information about this import element. The Documentation page is used for human readable material, such as a description.
  9. 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.

Once you have added an import element to your XML schema, when you define new elements, attributes, complex types, or simple types where you can specify type information, any declarations from the included schema will be available in the Type list for the element, attribute, complex or simple type.

Related reference
XML namespaces