Hi, 

I am migrating from xerces 2.8 to latest version of xerces 3.1. 

I was using SAX2XMLReader in the following way. 

class XercesRequestParser : public DefaultHandler 
{ 
             XercesRequestParser(); 
             ~XercesRequestParser(); 

             long parseRequest(ispData *ispdata); 
             void warning(const SAXParseException& e); 
             void error(const SAXParseException& e); 
             void fatalError(const SAXParseException& e); 
             void resetErrors(); 

        /* Callback registered to Xerces SAX Parser */ 
             void startElement(const XMLCh *const uri, const XMLCh *const
localname, 
                                     const XMLCh *const qname, const
Attributes &attrs); 
             void endElement(const XMLCh *const uri, const XMLCh *const
localname, 
                                    const XMLCh *const qname); 
             void endDocument(); 
             void characters(const XMLCh* const chars, const unsigned int
length); 
             void ignorableWhitespace(const XMLCh* const chars, const
unsigned int length); 

private: 
             .................. 
}; 


I am Creating the SAX2XMLReader as below inside the cpp file. 

             SAX2XMLReader *parser; // our request parser object 
        MemBufInputSource *inputsource; // input source for xml request 
            
             try 
        { 
                // create parser and set up default values 
                parser = XMLReaderFactory::createXMLReader(); 

                parser->setFeature(XMLUni::fgSAX2CoreValidation, false); 
                parser->setFeature(XMLUni::fgSAX2CoreNameSpaces, true); 
                
                          // set error handler to ourself 
                          parser->setErrorHandler(this); 
                parser->setContentHandler(this); 
        } 
        catch (...) 
        { 
                printf("XercesRequestParser::Parse(): exception setting up
parser\n"); 
                return 404; 
        } 

        try 
        { 
                inputsource = new MemBufInputSource((const
XMLByte*)data->GetXmlRequest(), 
                                            
strlen(m_ispdata->GetXmlRequest()), // length 
                                             "Data m_xmlrequest",               
   
// id 
                                             false); 
             } 
             catch (...) 
        { 
                printf("XercesRequestParser::Parse(ispdata): exception
setting up inputsource\n"); 
                delete parser; 
                return 404; 
        } 
              
             bool errorsOccured = false; 
             try 
             { 
                       parser->parse(*inputsource); 
             } 
             catch (const XMLException &e) 
             { 
                   printf("XercesRequestParser::Parse(ispdata): An error
occured during parsing [%s]\n", 
                                Char(e.getMessage())); 
                        errorsOccured = true; 
             } 
             catch (...) 
             { 
                printf( "XercesRequestParser::Parse(ispdata): Unknown error
occured during parsing\n"); 
                         errorsOccured = true; 
             } 

             delete parser; 
        delete inputsource; 

        


Suppose If the XML data  is as follows 

<Sample Version="2.0">sampledata</Sample>

The registered callbacks startElement and endElement are called during the
processing when xerces encounters "Sample" Element tag.But "characters" call
back method is not called when the xerces encounters the  element value 
"sampledata". 

I am unable to get the value inside the Xml tag ie. in this case it is
"sampledata". 

This is not the case with usage of 2.8 but facing problem when I am using
Xercces 3.1. 

Do I need to add or make any changes to get this problem solved in my code. 
Please help me. 

Thanks, 
Rao. 


-- 
View this message in context: 
http://old.nabble.com/Having-a-SAX2-parser-parsing-problem-during-the-code-migration-from-Xerces-2.8-to-3.1-tp30331054p30331054.html
Sent from the Xerces - C - Users mailing list archive at Nabble.com.

Reply via email to