The DefaultElementName Data Member
Each class generated by HydraExpress has a data member called DefaultElementName. This data member is an instance of rwsf::XmlName.
The DefaultElementName for a class is determined as follows:
*For top-level elements, the DefaultElementName is the element name.
If the top-level element name would result in a file that conflicts with another file name in the default namespace, HydraExpress renames it elementnameElement.
*For named complex types, the DefaultElementName is the complex type name.
*For anonymous complex types, the DefaultElementName is the name of the containing element.
The marshal() and unmarshal() methods for a class use the DefaultElementName by default. This allows you to simply call marshal() or unmarshal() on a class, usually with good results. For example, if the schema defines a top-level element named purchaseOrder, the following code usually works as expected:
PurchaseOrder po;
This code should produce, as expected, an XML document with a top-level element <purchaseOrder>.
There is one case, however, where the default use of the DefaultElementName does not work as you might expect:
<element name="foo" type="bar"/>
<complexType name="bar">
In this case, if the following code were used:
Bar b;
the result would be an XML document containing a top-level element called <bar>, when it would make better sense for the name of the element to be <foo>. To obtain this better result, the second line above would need to be: