Restricted Type Names in WSDL and XML Schema

Article ID: 1193
Last updated: 15 Sep, 2009
Article ID: 1193
Last updated: 15 Sep, 2009
Revision: 1
Views: 2108
Posted: 01 Jan, 2000
by --
Updated: 15 Sep, 2009
by

Problem


The use of restricted Type  names in a WSDL or XML Schema will result in naming collisions and compilation errors such as: ?Error: Multiple declaration for <type name>? or ?Error: Redefinition of formal parameter <type name>.?


Cause


Naming collisions may occur due to the way that LEIF and Hydra map XML names to C++.  The Code Generator (leifgen and rwsfgen respectfully) attempts to work around some of these naming collisions, but the compiler does not always find a satisfactory resolution.  This article is relevant to both LEIF and Hydra, however for reasons of simplicity the term ?Hydra? will be used solely in the Action section.  The solutions are applicable to LEIF as well as Hydra.


Action


The easiest solution is to simply rename the offending Type to something different.  For example, <complexType name=?Attribute?> could be changed to <complexType name="myAttribute">.

 

If this solution is not viable, it then becomes necessary to utilize the mappings element of the Hydra project file.  More information on the project file can be found in the Hydra Web Services Fabrication Guide.

 

The mappings section of the project file allows for name mapping.  A sample mapping to resolve <complexType name=?Attribute?> might look like:

 

<mappings>

      <name xsdname="attribute" xsdtype="" name="myAttribute" namespace=""/>

</mappings>

 

The mappings element may contain any number of name elements.  Please note that by default Hydra will add a mapping for ?choice? to all project files.  <name xsdname="choice" xsdtype="" name="ChoiceElement" namespace=""/>.  This removes all naming conflicts with Type names of ?choice.?

 

Please note that LEIF and Hydra will capitalize the first letter of the Type name within the generated code.  This is helpful in that it potentially avoids naming collisions with C++ data types and keywords.  For example, <complexType name=?void?> will actually generate, class Void;

 

Capitalizing the entire Type name will negate this benefit and potentially lead to errors if the Type name is the same as a primitive data type.  A typical error is: ?Fatal Error: INTERNAL COMPILER ERROR.?

 

The following Type names will result in naming collisions: Attribute, attribute, BOOL, BYTE, CHAR, DOUBLE, FLOAT, INT, LONG, SHORT, VOID, WCHAR

This article was:   Helpful | Not helpful
Report an issue
Article ID: 1193
Last updated: 15 Sep, 2009
Revision: 1
Views: 2108
Posted: 01 Jan, 2000 by --
Updated: 15 Sep, 2009 by
Also listed in


Others in this category