How to ask sax for the file encoding

Fredrik Lundh fredrik at pythonware.com
Thu Oct 5 01:12:27 EDT 2006


Martin v. Löwis wrote:

> A common problem is to save the data in the same encoding that they
> original had; this is what an editor typically does (you may know
> Edward Ream for writing editors). XML parsers are notoriously bad
> in supporting editors. There are too many lexical details that may
> need to be preserved (such as the order of the attributes, and the
> spaces inside the opening tag) to make it impractical to report all
> that to the application.

an editor designed to work on the XML serialization level shouldn't use 
a traditional XML parser at all, of course.  definitely not SAX or DOM, 
or any other infoset-or-higher-level API.

on the other hand, an editor that just happens to use XML as a 
serialization format might as well decide on a model representation
and an encoding and stick to it.  being tolerant in what it accepts
is a good idea, of course, but being consistent in what it generates
is an even better idea.

</F>




More information about the Python-list mailing list