--- expatreader.py.orig 2009-08-12 21:40:30.000000000 +0100 +++ expatreader.py 2009-08-12 21:52:14.000000000 +0100 @@ -167,7 +167,7 @@ elif name == property_xml_string: if self._parser: if hasattr(self._parser, "GetInputContext"): - return self._parser.GetInputContext() + return self._parser.GetInputContext().decode (self._encoding) else: raise SAXNotRecognizedException( "This version of expat does not support getting" @@ -259,6 +259,12 @@ self._parser.NotationDeclHandler = self.notation_decl self._parser.StartNamespaceDeclHandler = self.start_namespace_decl self._parser.EndNamespaceDeclHandler = self.end_namespace_decl + self._parser.XmlDeclHandler = self.xml_decl + + # Reset document specific information + self._encoding = "utf-8" + self._version = "1.0" + self._standalone = -1 self._decl_handler_prop = None if self._lex_handler_prop: @@ -297,6 +303,11 @@ return self._source.getSystemId() # event handlers + def xml_decl (self, version, encoding, standalone): + self._version = version if version is not None else "1.0" + self._encoding = encoding if encoding is not None else "utf-8" + self._standalone = standalone if standalone is not None else -1 + def start_element(self, name, attrs): self._cont_handler.startElement(name, AttributesImpl(attrs))