On Monday 18 February 2008 21:16, Sahoglu, Ozgur wrote:
> You exit :) Put exit(EXIT_FAILURE) call in your switch statement instead
> of returning false, when the case is a fatal error.
>
Uaah :-/ that would brake my system. I have to shut down the application 
clearly: disconnect from database, log exit message.

> I don't wanna interfere with your design decision, but mostly it's
> desirable to see all the errors in the document.
>
There is no problem to see all errors. But I want to know if any error was 
found.

In the main program execution the XML file is parsed with:

        XMLInit initXML;
        XMLCh tmpStr[100];
        XMLString::transcode( "LS", tmpStr, 99 );
        DOMImplementationLS* impl = 
DOMImplementationRegistry::getDOMImplementation( tmpStr );
        DOMBuilder* builder = 
dynamic_cast<DOMImplementationLS*>( impl )->createDOMBuilder( 
DOMImplementationLS::MODE_SYNCHRONOUS, 
0 );
        auto_ptr<DOMBuilder> parser( builder );
        // optionally you can set some features on this builder
        if (parser->canSetFeature(XMLUni::fgDOMValidation, true))
                parser->setFeature(XMLUni::fgDOMValidation, true);
        if (parser->canSetFeature(XMLUni::fgDOMNamespaces, true))
                parser->setFeature(XMLUni::fgDOMNamespaces, true);
        if (parser->canSetFeature(XMLUni::fgDOMDatatypeNormalization, true))
                        parser->setFeature(XMLUni::fgDOMDatatypeNormalization, 
true);
        if (parser->canSetFeature(XMLUni::fgXercesSchema, false))
                        parser->setFeature(XMLUni::fgXercesSchema, false);
        DOMDocument* doc;
        XmldbErrorHandler errorHandler;
        parser->setErrorHandler(&errorHandler);
        //! \todo create an entity resolver to load the XMLSchema
        //EntityResolver resolver;
        //parser->setEntityResolver( &resolver );
        doc = parser->parseURI( infile_.to_s().c_str() );
        if ( ! doc ) {
                throw XmlParseException( "Parsing of XML file failed!" );
        }

When the parsing is done, I want to know, if there any errors occured or not. 
If the XML file is invalid, no further processing should be done.

Greetz, Sven

Reply via email to