XML Schema Tutorials - Herong's Tutorial Examples
Dr. Herong Yang, Version 4.10

Schema Component Reuse - "include", "redefine" or "import"

This section compares 3 different ways of linking multiple schema documents together: include, redefine and import.

XML Schema specification offers 3 different special components to link multiple schema definition documents together for different purposes:

1. "include" Component - This component brings all declarations and definitions of an external schema document into the current schema. The external schema document must have the same target namespace as the current schema. "include" components are usually used to build a new schema by extending existing schema documents.

2. "redefine" Component - This component offers the same functions as the "include" component. But a "redefine" component also allows you redefine some datatypes provided in the included schema document. "redefine" components are usually used to revise a schema by redefining datatype definitions of existing schema documents.

3. "import" Component - This component offers the same functions as the "include" component except that the included schema document has a different target namespace. "import" components are usually used to build a new schema by borrowing element declarations from existing schema documents from other namespaces.

XML representations of "include", "redefine" and "import" components must appear at the beginning of a schema document before any element declarations or type definitions.

Tutorial examples of "include", "redefine" and "import" components are provided in other sections of this chapter.

Sections in This Chapter

Schema Component Reuse - "include", "redefine" or "import"

Including Old Schema Documents - "include" Component

Including Old Schema Documents - Examples

Including Old Schema Documents - Errors

Redefining Old Datatypes - "redefine" Component

Redefining Old Datatypes - XML Examples

Redefining Old Datatypes - Errors

Importing Declarations Across Namespaces - "import" Component

Importing Declarations Across Namespaces - Examples

Using Elements Declared in Different Namespaces

Using Elements Declared in Different Namespaces - Errors

Dr. Herong Yang, updated in 2007
Schema Component Reuse - "include", "redefine" or "import"