[Python-checkins] CVS: python/dist/src/Lib/xml/dom pulldom.py,1.21,1.22

Martin v. L?wis loewis@users.sourceforge.net
2001年7月18日 08:30:27 -0700


Update of /cvsroot/python/python/dist/src/Lib/xml/dom
In directory usw-pr-cvs1:/tmp/cvs-serv528
Modified Files:
	pulldom.py 
Log Message:
Patch #432117: Record namespaces in the DOM tree using the DOM xmlns prefix.
Index: pulldom.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/xml/dom/pulldom.py,v
retrieving revision 1.21
retrieving revision 1.22
diff -C2 -r1.21 -r1.22
*** pulldom.py	2001年03月23日 04:39:24	1.21
--- pulldom.py	2001年07月18日 15:30:25	1.22
***************
*** 45,48 ****
--- 45,51 ----
 
 def startPrefixMapping(self, prefix, uri):
+ if not hasattr(self, '_xmlns_attrs'):
+ self._xmlns_attrs = []
+ self._xmlns_attrs.append((prefix or 'xmlns', uri))
 self._ns_contexts.append(self._current_context.copy())
 self._current_context[uri] = prefix or ''
***************
*** 52,55 ****
--- 55,65 ----
 
 def startElementNS(self, name, tagName , attrs):
+ # Retrieve xml namespace declaration attributes.
+ xmlns_uri = 'http://www.w3.org/2000/xmlns/'
+ xmlns_attrs = getattr(self, '_xmlns_attrs', None)
+ if xmlns_attrs is not None:
+ for aname, value in xmlns_attrs:
+ attrs._attrs[(xmlns_uri, aname)] = value
+ self._xmlns_attrs = []
 uri, localname = name
 if uri:
***************
*** 77,81 ****
 for aname,value in attrs.items():
 a_uri, a_localname = aname
! if a_uri:
 prefix = self._current_context[a_uri]
 if prefix:
--- 87,98 ----
 for aname,value in attrs.items():
 a_uri, a_localname = aname
! if a_uri == xmlns_uri:
! if a_localname == 'xmlns':
! qname = a_localname
! else:
! qname = 'xmlns:' + a_localname
! attr = self.document.createAttributeNS(a_uri, qname)
! node.setAttributeNodeNS(attr)
! elif a_uri:
 prefix = self._current_context[a_uri]
 if prefix:

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