An International Purchase Order Instance Document
We begin with a simple instance document.
<ipo:purchaseOrder xmlns:ipo=""
<shipTo exportCode="1" xsi:type="ipo:UKAddress"
<name>Helen Zoe</name>
<street>47 Eden Street</street>
<postcode>CB1 1JR</postcode>
<billTo xsi:type="ipo:USAddress"
<name>Robert Smith</name>
<street>8 Oak Avenue</street>
<city>Old Town</city>
<item partNum="833-AA">
<productName>Lapis necklace</productName>
<ipo:comment>Want this for the holidays!</ipo:comment>
The instance document contains a billTo element. As you can see from the schema in the preceding section, a billTo is an Address. The Address type has two extensions, USAddress and UKAddress, and a billTo element can be either of these types. Elements with substitutable types are required to have an xsi:type attribute that clarifies the actual type of the element.
When unmarshaling an instance document that contains substitutable elements, HydraExpress uses the xsi:type attribute to determine the correct class type to create. In your application code, you can use the class getTypeId() method to determine its type.