Hi Simon,
the key is the use of the macro XERCES_CPP_NAMESPACE_USE; this will
allow your code to directly use the Xerces types without prefixing
them with their namespace "xerces_2_7::".
It is used in the next listing on the same page, but the one you
copied doesn't use it.
Alberto
At 05:33 PM 1/6/2006 +0100, Simon wrote:
Hi all,
I am a Xerces newbie and I am trying to write my first Sax handler.
I have copied the source code available at
http://xml.apache.org/xerces-c/program-sax.html
but I get the following error:
Compiling...
main.cpp
MySAXHandler.cpp
d:\masterarbeit simon perathoner\xerces_test\mysaxhandler.h(3) :
error C2504: 'HandlerBase' : base class undefined
d:\masterarbeit simon perathoner\xerces_test\mysaxhandler.h(5) :
error C2061: syntax error : identifier 'AttributeList'
d:\masterarbeit simon perathoner\xerces_test\mysaxhandler.h(6) :
error C2143: syntax error : missing ',' before '&'
d:\masterarbeit simon perathoner\xerces_test\mysaxhandler.h(6) :
error C2059: syntax error : '&'
d:\masterarbeit simon perathoner\xerces_test\mysaxhandler.cpp(6) :
error C2600: 'MySAXHandler::MySAXHandler' : cannot define a
compiler-generated special member function (must be declared in the
class first)
d:\masterarbeit simon perathoner\xerces_test\mysaxhandler.cpp(10) :
error C2061: syntax error : identifier 'AttributeList'
d:\masterarbeit simon perathoner\xerces_test\mysaxhandler.cpp(12) :
error C2653: 'XMLString' : is not a class or namespace name
d:\masterarbeit simon perathoner\xerces_test\mysaxhandler.cpp(12) :
error C2065: 'transcode' : undeclared identifier
d:\masterarbeit simon perathoner\xerces_test\mysaxhandler.cpp(12) :
error C2440: 'initializing' : cannot convert from 'int' to 'char *'
Conversion from integral type to pointer type requires
reinterpret_cast, C-style cast or function-style cast
d:\masterarbeit simon perathoner\xerces_test\mysaxhandler.cpp(14) :
error C2653: 'XMLString' : is not a class or namespace name
d:\masterarbeit simon perathoner\xerces_test\mysaxhandler.cpp(14) :
error C2065: 'release' : undeclared identifier
d:\masterarbeit simon perathoner\xerces_test\mysaxhandler.cpp(17) :
error C2143: syntax error : missing ',' before '&'
d:\masterarbeit simon perathoner\xerces_test\mysaxhandler.cpp(17) :
error C2059: syntax error : '&'
d:\masterarbeit simon perathoner\xerces_test\mysaxhandler.cpp(19) :
error C2653: 'XMLString' : is not a class or namespace name
d:\masterarbeit simon perathoner\xerces_test\mysaxhandler.cpp(19) :
error C2065: 'exception' : undeclared identifier
d:\masterarbeit simon perathoner\xerces_test\mysaxhandler.cpp(19) :
error C2228: left of '.getMessage' must have class/struct/union type
d:\masterarbeit simon perathoner\xerces_test\mysaxhandler.cpp(19) :
error C2440: 'initializing' : cannot convert from 'int' to 'char *'
Conversion from integral type to pointer type requires
reinterpret_cast, C-style cast or function-style cast
d:\masterarbeit simon perathoner\xerces_test\mysaxhandler.cpp(21) :
error C2228: left of '.getLineNumber' must have class/struct/union type
Error executing cl.exe.
xerces_test.exe - 18 error(s), 0 warning(s)
I am using Windows XP and Visual C++ 6.0. I have downloaded the file
'xerces-c_2_7_0-windows_2000-msvc_60.zip', unzipped it and added the
path to the Xerces 'bin' directory in the path system variable. In
my project I have set the path to the Xerces 'include' directory
under 'Additional include directories', the path to the Xerces 'lib'
directory under 'Additional library path'. Moreover I have added
'xerces-c_2.lib' to the list 'Object/library modules'.
I hope that somebody here can help me, it is quite urgent...
Thank you very much in advance for your help!
Simon
PS: With the same settings the initialization code provided at
http://xml.apache.org/xerces-c/program.html compiles without
errors... What is going wrong here?