[xsd-users] How to export class with given namespace by CodeSynthesis XSD?

lEdUnkAnG ledunkang at 163.com
Mon Aug 29 09:27:50 EDT 2011


In my project I've many XSD files in following format,

file1.xsd
<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">  
    <xs:complexType name ="type1_t">
      <!-- some define here -->
    </xs:complexType>  
  <xs:element name="REQUEST" type="type1_t"/>
</xs:schema>

----
file2.xsd
<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">  
    <xs:complexType name ="type2_t">
      <!-- some define here -->
    </xs:complexType>  
  <xs:element name="REQUEST" type="type2_t"/>
</xs:schema>
----

Because the root elements of these XSD files have same name ''REQUEST'',
Code Synthesis XSD generates two C++ classes with same class name,REQUEST.
To avoid name-duplicating problem, I've to add namespace manually to generated C++ classes in file1.cxx/hxx and file2.cxx/hxx files. And it works.

What I'm wondering is that whether there is any convenient method to put generated C++ class in given namespace by XSD command line options.

Any help will be appreciated.
Thanks in advance!



More information about the xsd-users mailing list