Hello everyone,

Im trying to parse wikipedia XML with SAX2 parser of xerces-c 2_7_0.

When i set the parser to parse from MemBufInputSource I get error like
All the files in the collection come up with the same error.

Fatal Error at file R:\000\41000.xml, line 2, char 2
  Message: Expected comment or CDATA

But when I try 
parser->parse(filename) it does not give me any errors.

my prolem is im having to extend code that already reads the file in a
buffer.
so i want to use memort buffer so i can avoid disk IO again.
it looks like the following


filename = disk.get_first_filename(argv[param]); 
file = (unsigned char *)disk.read_entire_file();

//
// read_entire_file()  looks like the following
//if ((fp = fopen(filename, "rb")) == NULL) return NULL;
//if (fstat(fileno(fp), &details) == 0)
//      if ((*file_length = details.st_size) != 0)
//              if ((block = new (std::nothrow) char [(long)(details.st_size + 
1)]) !=
NULL) 
                                                                           
// +1 for the '\0' on the end
//                      if (fread(block, (long)details.st_size, 1, fp) == 1)
//                              block[details.st_size] = '\0';
//
============================================================================

 unsigned int zzz = strlen( (const char*)file); // verified this 
 MemBufInputSource* memIS = new MemBufInputSource ( 
                                (const XMLByte*)  file , 
                                                 zzz , 
                                 filename , 
                                 false   );

 // memIS->setEncoding(XMLUni::fgUTF8EncodingString); // tried turning this
on
                                                      // the file being load is 
UTF-8
                                                      // saved as UTF-8 encoding

 parser2->parse(*memIS);       // this fails and my handler's events are
never called 

 parser2->parse(filename);       // this works but i want to avoid this in
favor 
                                           // of parsing from the buffer.
                     

I tried searching for help but no luck as of yet. I would be very greatful
if you can provide me some insight on what is wrong here.

Best regards
-- 
View this message in context: 
http://www.nabble.com/MemBufInputSource--%22Expected-comment-or-CDATA%22-tp22676266p22676266.html
Sent from the Xerces - C - Users mailing list archive at Nabble.com.

Reply via email to