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

5.3 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 class names. The mappings element in the project file allows you to customize the names of the classes that the code generator generates. The name of this file is passed to HydraExpress when the code generator is invoked.

The SOAP schema defines datatypes and elements that have identical names, as shown in the schema fragment below:

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 the HydraExpress project file below:

The contents of the mappings element tells 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 SchemaDefault Class NameClass 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

By including the customized mapping, we remove any ambiguity as to whether a class represents a datatype or an element.



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.