Rogue Wave banner
Previous fileTop of DocumentContentsIndex pageNext file
HydraExpress XML Binding Development Guide

8.6 Default Values

You can specify default values for attributes and elements. In both cases, the default value is generated as a public static constant within the generated class. HydraExpress generates the name of the constant by converting the first letter of the element or attribute name to upper case (if necessary) and appending the suffix DefaultValue. For example, the following schema fragment contains two default values:

This makes it convenient for you to see default values, in C++ form, for specific members and to adjust your logic to use the values appropriately by doing comparisons with these default value constants. An example of these public static constant identifiers is shown as they might appear in a generated header file:

The following example shows how you could use the default value logic:

The default constructor described in Section 8.5, "Complex Types," initializes the members that represent the element or attribute with the correct DefaultValue constant.

When marshaling, the marshaler performs a comparison with attributes that have default values associated with them. If the attribute value matches the default value constant, the marshaler does not include the attribute in the serialized document. Likewise, if an element has a default value and it is set to the default value, the marshaler serializes empty element content to recognize this.



Previous fileTop of DocumentContentsNo linkNext file

Copyright © Rogue Wave Software, Inc. All Rights Reserved.

The Rogue Wave name and logo are registered trademarks of Rogue Wave Software, and HydraExpress is a trademark of Rogue Wave Software. All other trademarks are the property of their respective owners.
Provide feedback to Rogue Wave about its documentation.