See my comments inlined below.

> Hi, I've got a very easy xerces-c implementation:
>
> If the DOCTYPE statement is included in my XML file, the code crashes,
> if not, it works perfecty.
>
> I cannot find any reason, why my code crashes!? Given that I don't do
> the catch(...) stuff, and I don' set an ErrorHandler, I get a
> segmentation faul. If I set the ErroHandler, it's "only" aborted.
> Uncommenting the catch(...) part again, catches this exception of course.

I do not get a segmentation fault. I do get a SAXParseException on the dtd
(see below).

>
> The filenames are not misspelled and the program, the dtd and the xml
> files are in the same directory. May cwd is the same as the directory
> conaing those three files when executing the program.
>
>
> I've compiled xerces-c myself on my Fedora Core 2 Distro with gcc 3.3.3,
> why I am not blaming any binary incompatibilities.
>
>
> Thanks for any hint !
>
> Boris
>
> Here's my code:
>
>
>
> ######### test.cpp ##########
>
>
> #include <iostream>
> #include <xercesc/dom/DOM.hpp>
> #include <xercesc/parsers/XercesDOMParser.hpp>
> #include <xercesc/sax/HandlerBase.hpp>
> #include <xercesc/util/XMLString.hpp>
> #include <xercesc/util/PlatformUtils.hpp>
>
> using namespace std;
> using namespace xercesc;
>
> int main(){
>
>     try {
>         XMLPlatformUtils::Initialize();
>     }
>     catch(const XMLException& exc){
>         char* message = XMLString::transcode(exc.getMessage());
>         cerr << "Error: " << message << endl;
>         XMLString::release(&message);
>         return 1;
>     }
>
>     XercesDOMParser *parser = new XercesDOMParser();
>     parser->setValidationScheme(XercesDOMParser::Val_Always);
>
>     ErrorHandler *errHandler = new HandlerBase();
>     parser->setErrorHandler(errHandler);
>
>     char *filename = "samplemap.xml";
>
>     try{
>         cout << "I'm alive" << endl;
>         parser->parse(filename);
>         cout << "I'm still alive" << endl;
>     }
>     catch(const XMLException& exc){
>         char* message = XMLString::transcode(exc.getMessage());
>         cerr << "Exception occured: " << message << endl;
>         XMLString::release(&message);
>         return 1;
>     }
>     catch(const DOMException& exc){
>         char* message = XMLString::transcode(exc.msg);
>         cerr << "Exception occured: " << message << endl;
>         XMLString::release(&message);
>         return 1;
>     }
>     catch(...){
>         cerr << "unexpected exception !!" << endl;
>         return 1;
>     }
>
>     delete parser;
>     delete errHandler;
>
>     return 0;
>
> }
>
>
>
> ################ thd DTD #######################
>
>
> <?xml version="1.0" encoding="UTF-8" ?>
>
>     ELEMENT map (street)
>     ATTLIST map
         proportions CDATA #REQUIRED
>     >
>
>     ELEMENT street(#PCDATA)

The SAXParseException I get states that there should be a space between
'street' and '(#PCDATA)'. After adding this space, the program runs
without errors.

>     ATTLIST street
         width CDATA #REQUIRED
>     >
>
>
>
> ############ The sample xml file ##########
>
> <?xml version="1.0" encoding="UTF-8" ?>
>
> <!-- crashes if not commented out -->
> <!DOCTYPE map SYSTEM "TrafficRoadmap.dtd" []>
>
> <map proportions="640x480">
>     <street width="20" >
>     </street>
> </map>
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to