# Adding an import element

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. XML schema defines two constructs to support this: include and import. The include element brings in definitions and declarations from the included schema into the current schema. It requires the included schema to be in the same target namespace as the including schema. The import element behaves in a similar way, with the exception that the imported schema can come from a different namespace.

In the XML schema editor, you can add an import element to an XML schema. Before you can do this, you must create an XML schema and open it in the XML schema editor (you can open an XML schema in the XML schema editor by double-clicking it).

You can add multiple import elements to an XML schema, however, prefixes and namespaces have to unique amongst the imported schemas.

An import element is always added to the top of the schema file, as it must appear as the first children of the schema element.

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

To add an import element, follow these steps:

1. Open your XML schema in the XML schema editor.
2. In the Outline view, select your schema. The entire schema and its contents should be displayed in the Graph view.
3. In the Graph view, right click in the Directives section and click Add Import.
4. In the Properties view, click the General tab and click the More button to the right of the Schema location field.
5. If you want to import an XML schema located in the workbench, select the Workbench projects radio button and click Next.
   1. Select the schema you want to import and click Finish.
6. If you want to import an XML schema located on the Web, select the HTTP radio button and click Next.
   1. 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.
7. The XML schema editor will retrieve the namespace for the imported XML schema file and display it as read-only in the Namespace field.
8. If necessary, type a unique prefix for this namespace in the Prefix field.
9. 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, and the App Info page can be used to provide information for applications.

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 tasks
Adding an include element
Adding a redefine element

Related reference
XML namespaces

(C) Copyright IBM Corporation 2000, 2005. All Rights Reserved.