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:complexType>
 
<xs:element name="Header" type="tns:Header" />
<xs:complexType name="Header" >
...
</xs:complexType>
<xs:element name="Body" type="tns:Body" />
<xs:complexType name="Body" >
...
</xs:complexType>
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:
 
<rwsf-codegen-project>
<options>
<option name='project-name' value='soapExample'/>
<option name='stl' value='true'/>
<option name='whitespace' value='true'/>
</options>
<mappings>
<name xsdname="Body" xsdtype="element" name="BodyElement"/>
<name xsdname="Envelope" xsdtype="element" name="EnvelopeElement"/>
<name xsdname="Header" xsdtype="element" name="HeaderElement"/>
<namespace uri="http://schemas.xmlsoap.org/soap/envelope/"
name="tns"/>
</mappings>
<files>
<inputSchema file='soap.xsd'/>
<inputSchema file='trade.xsd'/>
</files>
</rwsf-codegen-project>
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
EnvelopeElement
Envelope complexType
EnvelopeType
EnvelopeType
Header element
Header
HeaderElement
Header complexType
HeaderType
HeaderType
Body element
Body
BodyElement
Body complexType
BodyType
BodyType
Including the customized mapping removes any ambiguity as to whether a class represents a datatype or an element.