# patches for 2.2 # add support for the xml: namespace from xml.dom.pulldom import PullDOM if not PullDOM()._ns_contexts[0]: def _init(self, documentFactory=None): from xml.dom import XML_NAMESPACE self.documentFactory = documentFactory self.firstEvent = [None, None] self.lastEvent = self.firstEvent self.elementStack = [] self.push = self.elementStack.append try: self.pop = self.elementStack.pop except AttributeError: pass self._ns_contexts = [{XML_NAMESPACE:'xml'}] self._current_context = self._ns_contexts[-1] self.pending_events = [] import new PullDOM.__init__ = new.instancemethod(_init, None, PullDOM) # reversable htmlentitydefs mappings try: from htmlentitydefs import name2codepoint, codepoint2name except: import htmlentitydefs htmlentitydefs.name2codepoint={} htmlentitydefs.codepoint2name={} for (name,codepoint) in htmlentitydefs.entitydefs.iteritems(): if codepoint.startswith('&#'): codepoint=unichr(int(codepoint[2:-1])) htmlentitydefs.name2codepoint[name]=ord(codepoint) htmlentitydefs.codepoint2name[ord(codepoint)]=name