Ricky Ho wrote:

Got it ! Thanks

At 04:39 PM 2/21/2003 +0000, you wrote:

Ricky Ho wrote:

At the "Parser side, in both XPP and SAX code case, the parser deliver the same number of elements to the application "sequentially" (regardless of whether the application ask for it or the parser callback the application). So the Parser is doing same amount of work. Memory usage is minimum in both cases.

No it's not, and they're not doing the same amount of work. The SAX parser sends String and Attributes objects every time it does a startElement(). java.lang.String does an arraycopy of the characters that make up the string when it is constructed, even if the SAX parser later calls intern(). XPP only returns an event id. Internally, XPP need only maintain some pointers into a character buffer until you ask for the specific string you need.

hi,

FYI: this is exactly how it is implemented in XPP3: no String is allocated for element TEXT content until you call getText moreover parser will minimize buffering as much as possible. however it is no longer possible to completely defer attributes creation (one very good implementation of it is in James Clark XP parser but it is a bit old and does not support namespaces in API) as we have now XML namespaces so you need to parse namespace declarations *and* to check that attributes are not duplicates (x:foo and y:foo can be duplicates if prefixes x and y are bound t the same namespace and x can be rebound to new namespace when declared on element with xmlns:x).

if you have more questions about XmlPull API and XPP3 please send your questions to xmlpull-user mailing list (http://www.xmlpull.org/discussion.shtml).

thanks,

alek

--
"Mr. Pauli, we in the audience are all agreed that your theory is crazy. What divides us is whether it is crazy enough to be true." Niels H. D. Bohr



Reply via email to