xml spy
Previous  Top  Next

Specifying the Type of an Element


The child elements of Address displayed in Grid View are those defined for the global complex type AddressType (content model of which is shown in screenshot below).

 

tut_18a

 

We would, however, like to use a specific US or UK address type rather than the generic address type. You will recall that, in the AddressLast.xsd schema, we created global complex types for US-Address and UK-Address by extending the AddressType complex type. The content model of US-Address is shown below.

 

us_address_type

 

In the XML document, in order to specify that the Address element must conform to one of the extended Address types (US-Address or UK-Address) rather than the generic AddressType, we must specify the required extended complex type as an attribute of the Address element.

 

Do the following:

 

1.Right-click the Name element, and select Insert | Attribute from the context menu.

 

insert_attribute

 

An attribute field is added to the Address element.

2.Ensure that xsi:type is entered as the name of the attribute (screenshot below).
3.Press Tab to move into the next (value) field.

 

tut_37bMod

 

4.Enter US-Address as the value of the attribute.

 

Please note: The xsi prefix allows you to use special XML Schema related commands in your XML document instance. In the above case, you have specified a type for the Address element. See the XML Schema specification for more information.


Previous  Top  Next

© 2008 Altova