Re: [xml] What is the advantage of a Reader vs a Parser?



On Wed, 2004-03-31 at 19:18, Daniel Veillard wrote:
On Wed, Mar 31, 2004 at 04:36:26PM +1200, BJ Chippindale wrote:
Hello All

I read the code examples and documentation, implemented a reader and I
am implementing a parser, and I STILL have to ask.  It looks as though
the parser and the reader both walk the tree with the reader doing it
more "hands off", and I can't find anything to tell me why/when I should
use one and not the other.  Can anyone point me at something that will
tell me?  ... or am I about to find out as I do the parser? 

  The Reader will use low memory. It will never need a full version of the
tree in memory, i.e. it's a streaming parser...

It also appears that if the XML is a control message in which the
meaning of lower levels depends on the context set in upper ones, the
reader is inconvenient.  Message "state" information has to be retained
and/or discarded for each node as it is processed.  For example:  An
address that is a "destination" is not treated the same as a "source"
but the node name is identical. So I have to retain state information
throughout the processing and it quickly becomes intractably dense code
(Which is why I started exploring the parsing in the first instance).  
It appears that the standard parsing model is better suited to this sort
of work, as the context is implicit in the position on the tree.  

If it makes sense?  :-)

Thanks
respectfully 
BJ

Point taken about our standard e-mail disclaimer.  Thanks twice. BJ




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]