Hi Frank,

At 16.16 15/09/2004 -0700, Xiaofan Zhou wrote:
Hi, ALl,

I have following two questions regarding how to use InputSource with SAX parser in Xerces for C++.

I know I can do something like this:

     SAX2XMLReader* pParser = XMLReaderFactory::createXMLReader();
    pParser->parse(input);

Where input is an instance of InputSource. My question is: say I have a file, I can create a LocalFileInputSource, or read the whole file into memory buffer then create a MemBufInputSource, which one is better? I have big input file like 20M.

The better choice is to use the LocalFileInputSource; every InputSource-derived object will feed the data to the parser in small chunks, so LocalFileInputSource has the advantage that the file will never be completely loaded in memory. If you use MemBufInputSource, you have to allocate 20Mb of memory even before starting the parse phase.



Also, I've tried both DOM and SAX parser in Xerces c++ (1.7), from Windows Task Manager, I can see the memory usage by my process is significantly less in xml parsing phase whe SAX Parser is used,
however, it does not seem to me that SAX parser can handle larger input than DOM, in my case, when the input reach 30M, both parser blow out. Any thought?

The building of the DOM structure requires significantly more memory than pure SAX processing (unless you are allocating a DOM-like structure in the SAX callbacks). And I have parsed files bigger than 100Mb.
Please try the examples SAXCount and DOMCount on the same files: if they succeed, you have some extra code that is responsible for the crash.


Alberto



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



Reply via email to