[Python-checkins] python/dist/src/Lib/xml/sax expatreader.py,1.25.16.3,1.25.16.4

fdrake@users.sourceforge.net fdrake@users.sourceforge.net
2002年10月08日 12:49:39 -0700


Update of /cvsroot/python/python/dist/src/Lib/xml/sax
In directory usw-pr-cvs1:/tmp/cvs-serv17520/Lib/xml/sax
Modified Files:
 Tag: release22-maint
	expatreader.py 
Log Message:
Fix some code that was added to the r22-maint branch to allow it to work with
arbitrary versions of Expat.
Not applicable to Python 2.3, which will incorporate an Expat that does not
need this crutch.
Index: expatreader.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/xml/sax/expatreader.py,v
retrieving revision 1.25.16.3
retrieving revision 1.25.16.4
diff -C2 -d -r1.25.16.3 -r1.25.16.4
*** expatreader.py	26 Sep 2002 15:24:40 -0000	1.25.16.3
--- expatreader.py	8 Oct 2002 19:49:36 -0000	1.25.16.4
***************
*** 225,230 ****
--- 225,236 ----
 if len(pair) == 1:
 pair = (None, name)
+ qname = name
 else:
 pair = tuple(pair)
+ qname = pair[1]
+ if self._ns_stack:
+ prefix = self._ns_stack[-1][pair[0]][-1]
+ if prefix:
+ qname = "%s:%s" % (prefix, pair[1])
 
 newattrs = {}
***************
*** 234,248 ****
 if len(apair) == 1:
 apair = (None, aname)
! qname = aname
 else:
 apair = tuple(apair)
 # XXX need to guess the prefix
 prefix = self._ns_stack[-1][apair[0]][-1]
! qname = "%s:%s" % (prefix, apair[1])
 
 newattrs[apair] = value
! qnames[apair] = qname
 
! self._cont_handler.startElementNS(pair, None,
 AttributesNSImpl(newattrs, qnames))
 
--- 240,254 ----
 if len(apair) == 1:
 apair = (None, aname)
! aqname = aname
 else:
 apair = tuple(apair)
 # XXX need to guess the prefix
 prefix = self._ns_stack[-1][apair[0]][-1]
! aqname = "%s:%s" % (prefix, apair[1])
 
 newattrs[apair] = value
! qnames[apair] = aqname
 
! self._cont_handler.startElementNS(pair, qname,
 AttributesNSImpl(newattrs, qnames))
 
***************
*** 251,258 ****
 if len(pair) == 1:
 pair = (None, name)
 else:
 pair = tuple(pair)
 
! self._cont_handler.endElementNS(pair, None)
 
 # this is not used (call directly to ContentHandler)
--- 257,270 ----
 if len(pair) == 1:
 pair = (None, name)
+ qname = name
 else:
 pair = tuple(pair)
+ qname = pair[1]
+ if self._ns_stack:
+ prefix = self._ns_stack[-1][pair[0]][-1]
+ if prefix:
+ qname = "%s:%s" % (prefix, pair[1])
 
! self._cont_handler.endElementNS(pair, qname)
 
 # this is not used (call directly to ContentHandler)
***************
*** 266,274 ****
 def start_namespace_decl(self, prefix, uri):
 if self._ns_stack:
! d = self._ns_stack.copy()
 if d.has_key(uri):
 L = d[uri][:]
 d[uri] = L
 L.append(prefix)
 else:
 d = {uri: [prefix]}
--- 278,288 ----
 def start_namespace_decl(self, prefix, uri):
 if self._ns_stack:
! d = self._ns_stack[-1].copy()
 if d.has_key(uri):
 L = d[uri][:]
 d[uri] = L
 L.append(prefix)
+ else:
+ d[uri] = [prefix]
 else:
 d = {uri: [prefix]}

AltStyle によって変換されたページ (->オリジナル) /