Rogue Wave banner
Previous fileTop of DocumentContentsIndex pageNext file
HydraExpress XML Binding Development Guide
Rogue Wave web site:  Home Page  |  Main Documentation Page

6.6 Accessing the Address

When you run the sample main, complexContent_main, the output shows a zip code and a complete XML document. This document is created by unmarshaling the input file complexContent.xml, changing a piece of data, and then marshaling the result to the output.

The beginning of the sample application is just like the previous examples:

Next the sample application manipulates the billTo element, which as we know can be either a USAddress or a UKAddress. In the code below, the retrieval of the billTo address returns an rwsf::XmlBindingHandle, but we do not know its actual type. To find out, we call getTypeId() on the billTo object, which returns the value of the xsi:type attribute of the billTo element in the instance document. Based on this value, we can determine the actual type of billTo and produce the output appropriately.

//1Returns a rwsf::XmlBindingHandle which contains an Address, but whether a USAddress or a UKAddress is unknown.
//2Uses getTypeId() method to determine the actual type and creates appropriate output based on the result.

Next the example code changes the shipTo address to be the same as the billTo address, and writes out the modified document.

//1Sets the shipTo address to be the same as the billTo address.
//2Instantiates a writer and sets it to preserve whitespace.
//3Calls the marshal() method that marshals the data to a supplied writer.
//4Writes out the XML document.


Previous fileTop of DocumentContentsIndex pageNext file

©2004-2007 Copyright Quovadx, Inc. All Rights Reserved.
Quovadx and Rogue Wave are registered trademarks of Quovadx, Inc. in the United States and other countries. All other trademarks are the property of their respective owners.
Contact Rogue Wave about documentation or support issues.