Stefan Behnel added the comment:

> TreeBuilder doesn't do parsing, it takes already parsed data: it has a
> start() method to open a tag, and a data() method to add raw text
> inside that tag.

That is correct. However, the XMLParser has a feed() method that sends new data 
into the parser, and a close() method that tells the parser that it's done. So 
there already is an incremental parsing interface, and your change is 
duplicating that interface under a different name. Specifically, 
IncrementalParser has exactly the same interface as XMLParser when it comes to 
entering data, but uses different method names for it. This is a Bad Design 
because it introduces an unnecessary inconsistency in the API.

However, what you are trying to change is not the way data is *entered* into 
the parser. What you are after is to change the way the *parsed* data is 
*presented* to the user. That is not the responsibility of the parser, it's the 
responsibility of the TreeBuilder.

In your code, the TreeBuilder builds a tree, and the new interface 
*additionally* collects parse events in a list. So, the right way to do it 
would be to change the parser *target* to do both, i.e. to build a tree and 
collect events at the same time.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue17741>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to