2 messages in org.python.python-bugs-list[ python-Bugs-923697 ] SAX2 'property...
FromSent OnAttachments
SourceForge.netMar 26, 2004 1:39 am 
SourceForge.netMar 26, 2004 1:41 am 
Actions with this message:
Paste this link in email or IM:
Paste this link in email or IM:
Atom feed for this thread
Paste this URL into your reader:
Subject:[ python-Bugs-923697 ] SAX2 'property_encoding' feature not supportedActions...
From:SourceForge.net (nore@sourceforge.net)
Date:Mar 26, 2004 1:39:45 am
List:org.python.python-bugs-list

Bugs item #923697, was opened at 2004-03-26 06:39 Message generated for change (Tracker Item Submitted) made by Item Submitter You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=105470&aid=923697&group_id=5470

Category: XML Group: None Status: Open Resolution: None Priority: 5 Submitted By: Joseph Walton (josephw) Assigned to: Nobody/Anonymous (nobody) Summary: SAX2 'property_encoding' feature not supported

Initial Comment: I need to parse a byte stream as an XML document and, afterwards, access the same document as a Unicode string. I would prefer to rely on the parser's charset-determining logic, and the 'property_encoding' feature ("http://www.python.org/sax/properties/encoding") seems to offer exactly this information.

However, the default Expat parser doesn't support this feature.

--- from xml.sax import make_parser, handler from xml.sax.xmlreader import InputSource from sys import stdin

p = make_parser()

# Should not fail. Should it return None, or UTF-8? assert(p.getProperty(handler.property_encoding) == None)

source = InputSource() source.setByteStream(stdin)

p.parse(source)

# Should now be the name of the actual encoding used assert(p.getProperty(handler.property_encoding) != None) ---

This raises SAXNotRecognizedException.

Is there another SAX parser I could use instead?

----------------------------------------------------------------------