Importing Types
The tutorial schemas book_store.xsd and library.xsd have different target namespaces. You can easily view this if you drag both schemas from the "import" folder into the main SchemaAgent window and expand their namespaces:
According to the diagram above:
•The schema book_store.xsd has the target namespace http://www.xmlspy.com/schemas/orgchart. This is also the default namespace. The prefix xsd is mapped to the namespace http://www.w3.org/2001/XMLSchema.
•The schema library.xsd has the target namespace https://www.altova.com/IPO. This is also the default namespace. The prefix xs is mapped to the namespace http://www.w3.org/2001/XMLSchema. The prefix ns1 is mapped to the namespace http://www.xmlspy.com/schemas/orgchart.
Let's suppose that, while working with the library.xsd schema, you need the type bookType from the namespace http://www.xmlspy.com/schemas/orgchart (which is the target namespace of book_store.xsd). To combine schema documents that have different target namespaces like in this case, an import relationship must be used. The import relationship between the two schemas has already been added in a previous step of the tutorial, see Creating an Import Relationship. In this part of the tutorial, you will be using a type from the imported namespace. First, you will turn the local type bookType into a global complex type. Once this is done, you will be able to declare a new element of this type in the library.xsd schema.
To turn the "book" component into a global complex type:
1.In SchemaAgent Client, right-click book_store.xsd and select Edit in XMLSpy (Ctrl+Y) from the context menu.
2.In XMLSpy, click the Display Diagram icon for the element book_store to display its content model.
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:
1.In SchemaAgent Client, right-click library.xsd and select Edit in XMLSpy (Ctrl+Y) from the context menu.
2.In XMLSpy, click the Display Diagram icon for the element library to show its content model.
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 ns1:bookType from the type drop-down list.
7.Save and close the file.
You have now imported a type from the schema book_store.xsd into the schema library.xsd.