The child elements of Address are those defined for the global complex type AddressType (the content model of which is defined in the XML Schema AddressLast.xsd shown in the Schema View screenshot below).
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.
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.||In the XML document, right-click the Name element, and select Insert | Attribute from the context menu.|
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.|
|4.||Enter US-Address as the value of the attribute.|
|Note:||The xsi prefix allows you to use special XML Schema related commands in your XML document instance. Notice that the the namespace for the xsi prefix was automatically added to the document element when you assigned a schema to your XML file. In the above case, you have specified a type for the Address element. See the XML Schema specification for more information.|
© 2019 Altova GmbH