Including Types Using Only XMLSpy

www.altova.com Print this Topic Previous Page Up One Level Next page

Home >  SchemaAgent Tutorial > Using XMLSpy as a SchemaAgent Client >

Including Types Using Only XMLSpy

In this section you will use only XMLSpy as a client connected to the SchemaAgent LocalServer to create an include relationship between the following schemas provided in the include2 sub-folder of the SchemaAgentExamples\Tutorial folder:

 

company1.xsd: This schema is structured to contain information about a company and its employees.
company2.xsd: This schema is structured to contain information about the products of a company.

 

In the course of this example, you will include the address and employee components from company1.xsd in company2.xsd.

 

 

To make the components to be included into global complex types:

1.Open the company1.xsd schema in XMLSpy.
2.Make sure that you are connected to the SchemaAgent LocalServer.
3.In XMLSpy, click the Display Diagram ic_component icon for the root element company1 to display its content model.

company1_content_model

4.Right-click the address element and select Make Global | Complex type from the context menu. A new global complex type called addressType is created.
5.Click the "+" icon to expand the employees element.

company1_content_model3

6.In the same way, make the employeeData element into a global complex type. This results in a type called employeeDataType.
7.Save the file.

 

 

To include global complex types in schemas using XMLSpy:

1.Open the target schema, company2.xsd in this example, in XMLSpy.
2.Make sure that you are connected to the SchemaAgent LocalServer.
3.In XMLSpy, click the Display Diagram ic_component icon for the root element company2 to display its content model.

company2_content_model

4.Right-click the sequence element and select Add child | Element from the context menu.
5.Enter "companyAddress" as the name for this element.
6.With this element still selected, in the Details entry helper, select addressType from the type drop-down list. The word "addressType" is in blue because there is no include, import or redefine relationship between the schemas.

spy_details-companyAddress

7.A dialog box opens where you can select which type of relationship you want to have between the two schemas.

dlg_relation

8.Select Include and confirm with OK. This inserts an include statement into the company2.xsd schema.
9.Repeat steps 3 to 5 to create a further element with the name "employee" and of type "employeeDataType". Notice that when in the Details entry helper you select employeeDataType from the type drop-down list, it is in black, because there is now an include relationship between the schemas.

company2_content_model3

10. Save the file.

 

You have now included two types from the schema company1.xsd in the schema company2.xsd.

 

 

To view the include statement that has been inserted:

Click the Display All Globals ic_schema-overview icon.

spy_schema-overview-company2


© 2019 Altova GmbH