Customizing Mappings Using the Project File
The SOAP example uses the HydraExpress project file example-project.xml to specify the way HydraExpress maps names in the schema to C++ class names. This file can be a parameter to the code generator command line. The project file can also define a mappings element, which allows you to customize the names of the classes that the code generator generates.
The SOAP schema defines datatypes and elements that have identical names, as shown in the schema fragment below:
<xs:element name="Envelope" type="tns:Envelope" />
<xs:complexType name="Envelope" >
<xs:element name="Header" type="tns:Header" />
<xs:complexType name="Header" >
<xs:element name="Body" type="tns:Body" />
<xs:complexType name="Body" >
In general, the code generator creates the name of a class from the name attribute of the element that defines the schema feature represented by the class. In this case, following that strategy would result in two classes with the same name. To avoid the name conflict, the compiler adds the word Type to the name of the class that represents the datatype. For example, the compiler generates class EnvelopeType to represent the datatype Envelope and generates class Envelope to represent the top-level element Envelope.
The mappings element of the HydraExpress project file offers added flexibility. The SOAP example uses the customized mappings included in the HydraExpress project file below:
<option name='project-name' value='soapExample'/>
<option name='stl' value='true'/>
<option name='whitespace' value='true'/>
<name xsdname="Body" xsdtype="element" name="BodyElement"/>
<name xsdname="Envelope" xsdtype="element" name="EnvelopeElement"/>
<name xsdname="Header" xsdtype="element" name="HeaderElement"/>
<namespace uri=""
<inputSchema file='soap.xsd'/>
<inputSchema file='trade.xsd'/>
The contents of the mappings element tell the compiler to create class HeaderElement to represent the element Header, to create class BodyElement to represent the element Body, and to create class EnvelopeElement to represent the element Envelope.
Note that this customized mapping does not affect the names that the compiler uses for the datatype classes. As Table 3 shows, the code generator adds the Type suffix in response to name conflicts in the schema document, regardless of whether an actual class name conflict exists:
Table 3 – Generated class names for SOAP example 
Name in Schema
Default Class Name
Class Name With Configuration File
Envelope element
Envelope complexType
Header element
Header complexType
Body element
Body complexType
Including the customized mapping removes any ambiguity as to whether a class represents a datatype or an element.