Hi all!

I'm trying to parse an xml-file using the SAX2-interface, but I have problems
with the errorhandling. It seems I can't get Xerces to report the errors until
the complete file have been parsed. I call different functions depending on the
element read. I guess I actually might have to parse the file once without a
contenthandler registered if the program cannot handle the fact that some parts
of the file are correct and not others, but that is a later problem. So my main
problem is that encountered errors are reported "too late".

I have created an errorhandler which does nothing except writing out line
number, column number etc when an error is encountered. Three functions have
been overloaded (warning(), error() and fatalError()). I have written a short
xml-file and a dtd to test the parsing.

If I comment out the setting of the feature fgSAX2CoreValidation the
errorhandler is not able to report any validation error at all (which is
strange cause the default value is supposed to be true??).

Can anybody see what's wrong? I suppose errors should be reported when
encountered? Have I missed some feature? I have read the programming guide, but
nothing seems to be missing.

I'm using xerces 2.3.0 on a UNIX machine.

--------- program snippet -----------------

XMLPlatformUtils::Initialize();
SAX2XMLReader* parser = 0;

try {
    parser = XMLReaderFactory::createXMLReader();
    TestAppErrorHandler errhandler;  // my errorhandler
    //
    // set features on parser
    //
    parser->setFeature(XMLUni::fgSAX2CoreNameSpaces, false);
    parser->setFeature(XMLUni::fgSAX2CoreValidation, true);
    parser->setFeature(XMLUni::fgXercesValidationErrorAsFatal, true);
    //
    // Set handlers.
    //
    parser->setContentHandler(&handler);    // real content handler
    parser->setErrorHandler(&errhandler);
    //
    // Parse document.
    //
    parser->parse(file);

   //
   // program continues.
   //

---------------------------X----------------------------------

The dtd looks like:

-----------------dtd snippet --------------------------

<!ELEMENT data (function)+>

<!ELEMENT function (arg|struct|vector)*>
<!ATTLIST function name CDATA #REQUIRED>

<!ELEMENT arg       (#PCDATA) >

<!ELEMENT struct    ( (arg)+ | (vector|struct)+ )*>
<!ELEMENT vector    ( (arg)+ | (vector|struct)+ )*>
----------------------------X---------------------------------

Thank you

//daniel

__________________________________________________________
RFV Data/Produktenheten     E-post: [EMAIL PROTECTED]
Daniel Gr�ndal              Tfn: 060-187126
S:a J�rnv�gsgatan 41        Mobil: 070-3016517
851 93 Sundsvall            Fax: 060-147870
__________________________________________________________



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

Reply via email to