![]() |
| Previous Top Next |
Importing Types |
In our tutorial example, the schema book_store.xsd has a different namespace from the schema library.xsd. Therefore, to use elements from book_store.xsd in library.xsd, these elements must be imported. In this section, you will learn how to import a type that stores information about books from book_store.xsd to library.xsd.

Notice that the schema contains an import statement, which was automatically added when you connected the two schemas in the Import section discussed previously. Also note that the namespace is specified in the ns field of the import statement. In this section, you will use a type from the imported schema in the importing schema.
To make the component book into a global complex type:
| 2. | In XMLSpy, click the Display Diagram |
| 3. | Click the "+" icon to expand the bookInfo element. |

| 4. | Right-click the book element and select Make Global | Complex type from the context menu. |
| 5. | Save the file. |
To import bookType to library.xsd:
| 2. | In XMLSpy, click the Display Diagram |

| 3. | Click the "+" icon to expand the bookInfo element. |

| 4. | Right-click the sequence icon after the bookInfo element and select Add child | Element from the context menu. |
| 5. | Enter "bookDetails" as the name for the element. |
| 6. | With this element still selected, in the Details entry helper, select ns2:bookType from the type drop-down list. Components from both schemas are in black, all others are in blue. |

| 7. | Save and close all files that are currently open in XMLSpy. |
You have now imported a type from the schema book_store.xsd to the schema library.xsd.

|