[xsd-users] linking problem with generated cxx/hxx files
Ivo Luyckx
ILuyckx at benelux.tokheim.com
Wed Feb 25 10:37:53 EST 2015
Hello all,
I am using xsd to compile a set of XSD files into cxx/hxx files.
Command line:
xsd.exe cxx-tree --output-dir ./out/ --show-sloc --generate-serialization --generate-doxygen --type-naming ucc --function-naming java --char-type wchar_t --type-regex '/ (.+)_t/\u$1/' hello.xsd
xsd.exe cxx-tree --output-dir ./out/ --show-sloc --generate-serialization --generate-doxygen --type-naming ucc --function-naming java --char-type wchar_t --type-regex '/ (.+)_t/\u$1/' hello2.xsd
Them I am using the generated files in a Visual Studio 2010 project.
Compiling this project results in a number of the following errors while linking:
hello2.obj : error LNK2005: "public: class xsd::cxx::tree::string<wchar_t,class xsd::cxx::tree::simple_type<wchar_t,class xsd::cxx::tree::_type> > const & __thiscall Message::getGreeting(void)const " (?getGreeting at Message@@QBEABV?$string at _WV?$simple_type at _WV_type@tree at cxx@xsd@@@tree at cxx@xsd@@@tree at cxx@xsd@@XZ) already defined in hello.obj
The input XSD files are quite basic:
- hello.xsd:
<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="HelloRequest">
<xs:complexType>
<xs:sequence>
<xs:element name="Message">
<xs:complexType>
<xs:sequence>
<xs:element name="greeting" type="xs:string" />
<xs:element name="name" type="xs:string" maxOccurs="unbounded" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
- hello2.xsd:
<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="HelloResponse">
<xs:complexType>
<xs:sequence>
<xs:element name="Message">
<xs:complexType>
<xs:sequence>
<xs:element name="greeting" type="xs:string" />
<xs:element name="name" type="xs:string" maxOccurs="unbounded" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
The problem seems to be the nested <xs:element name="Message"> in both XSD's.
In both generated hxx files a class Message is generated:
class Message: public ::xml_schema::Type
{
This is causing the 'already defined' linking problem.
I am aware this problem can be solved by putting this complex type in an XSD which is included in hello.xsd and hello2.xsd.
The problem is that the XSD's are coming from a third party and I have no control whatsoever on them.
Is there a way to tell XSD (e.g. command line option) to generate a more complex class name (e.g. HelloResponse_Message) for these nested elements?
This would avoid naming clashes for locally defined elements.
Kind regards,
Ivo.
This e-mail and any attachments contain material that is confidential for the sole use of the intended recipient. Any review, reliance or distribution by others or forwarding without express permission is strictly prohibited. If you are not the intended recipient, please contact the sender and delete all copies.
This message has been scanned for malware by Websense. www.websense.com
More information about the xsd-users
mailing list