]> granicus.if.org Git - python/commitdiff
Merged revisions 83864 via svnmerge from
authorFlorent Xicluna <florent.xicluna@gmail.com>
Mon, 9 Aug 2010 20:46:49 +0000 (20:46 +0000)
committerFlorent Xicluna <florent.xicluna@gmail.com>
Mon, 9 Aug 2010 20:46:49 +0000 (20:46 +0000)
svn+ssh://pythondev@svn.python.org/python/branches/py3k

........
  r83864 | florent.xicluna | 2010-08-09 01:08:41 +0200 (lun., 09 août 2010) | 2 lines

  Fix xml.etree.ElementInclude to include the tail of the current node.  Issue #6231
........

Lib/test/test_xml_etree.py
Lib/xml/etree/ElementInclude.py
Misc/NEWS

index ad3f112f8a8fe4585396f3e0b8afd7b2d1e3269b..98ca4d28809ebd237b9f47fb1d39bb0ffe0fe410 100644 (file)
@@ -1259,6 +1259,14 @@ XINCLUDE["C2.xml"] = """\
 
 XINCLUDE["count.txt"] = "324387"
 
+XINCLUDE["C2b.xml"] = """\
+<?xml version='1.0'?>
+<document xmlns:xi="http://www.w3.org/2001/XInclude">
+  <p>This document has been <em>accessed</em>
+  <xi:include href="count.txt" parse="text"/> times.</p>
+</document>
+"""
+
 XINCLUDE["C3.xml"] = """\
 <?xml version='1.0'?>
 <document xmlns:xi="http://www.w3.org/2001/XInclude">
@@ -1334,6 +1342,16 @@ def xinclude():
       324387 times.</p>
     </document>
 
+    Textual inclusion after sibling element (based on modified XInclude C.2)
+
+    >>> document = xinclude_loader("C2b.xml")
+    >>> ElementInclude.include(document, xinclude_loader)
+    >>> print(serialize(document)) # C2b
+    <document>
+      <p>This document has been <em>accessed</em>
+      324387 times.</p>
+    </document>
+
     Textual inclusion of XML example (XInclude C.3)
 
     >>> document = xinclude_loader("C3.xml")
index dde0a41531c0030a87ae66051440e65ebb8df016..84fd7548b28a0c5f51193caf28bdf045cc1ea3a7 100644 (file)
@@ -125,7 +125,7 @@ def include(elem, loader=None):
                         )
                 if i:
                     node = elem[i-1]
-                    node.tail = (node.tail or "") + text
+                    node.tail = (node.tail or "") + text + (e.tail or "")
                 else:
                     elem.text = (elem.text or "") + text + (e.tail or "")
                 del elem[i]
index bf86216def7f88580fa844c8b948f3d482e34c87..0f54b9317a84638e4c36651db8a47b25805a7504 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -29,6 +29,9 @@ Core and Builtins
 Library
 -------
 
+- Issue #6231: Fix xml.etree.ElementInclude to include the tail of the
+  current node.
+
 - Issue #6869: Fix a refcount problem in the _ctypes extension.
 
 - Issue5504 - ctypes should now work with systems where mmap can't be