Commit 87e4471c authored by Nicolas Delaby's avatar Nicolas Delaby

* Add namespace declaration on xupdate nodes which are using

prefix in builded xpath expression.
* Update test according to this modification
parent 0c1a536a
......@@ -214,7 +214,7 @@ class ERP5Diff:
remove_element.attrib['select'] = path
root.append(remove_element)
def _xupdateAppendElements(self, element_list, path, nsmap=None):
def _xupdateAppendElements(self, element_list, path):
"""
Append elements to the element at 'path'.
xupdate:append
......@@ -234,18 +234,18 @@ class ERP5Diff:
#reuse same container as preceding
append_element = last_append_element
elif relative_next is not None and relative_next not in element_list:
append_element = etree.SubElement(root, '{%s}insert-before' % self._ns, nsmap=nsmap)
append_element = etree.SubElement(root, '{%s}insert-before' % self._ns, nsmap=element.nsmap)
path_list = self._makeRelativePathList([relative_next])
next_sibling_path = self._concatPath(path, path_list[0])
append_element.attrib['select'] = next_sibling_path
elif relative_previous is not None and relative_previous not in element_list:
append_element = etree.SubElement(root, '{%s}insert-after' % self._ns, nsmap=nsmap)
append_element = etree.SubElement(root, '{%s}insert-after' % self._ns, nsmap=element.nsmap)
path_list = self._makeRelativePathList([relative_previous])
preceding_sibling_path = self._concatPath(path, path_list[0])
append_element.attrib['select'] = preceding_sibling_path
else:
#xupdate:append by default
append_element = etree.SubElement(root, '{%s}append' % self._ns, nsmap=nsmap)
append_element = etree.SubElement(root, '{%s}append' % self._ns, nsmap=element.nsmap)
if parent_element.index(element) == 0:
child = 'first()'
elif parent_element.index(element) == (len_total_child_list -1):
......
......@@ -724,14 +724,14 @@ does not work as bellow example. This is a known bug.
>>> erp5diff.output()
<xupdate:modifications xmlns:xupdate="http://www.xmldb.org/xupdate" version="1.0">
<xupdate:remove xmlns:prefixbis="http://any_uri_bis" select="/erp5/object[2]/prefixbis:title"/>
<xupdate:append select="/erp5/object[2]" child="first()">
<xupdate:append xmlns:prefix="http://any_uri" select="/erp5/object[2]" child="first()">
<xupdate:element name="prefix:title" namespace="http://any_uri"><xupdate:attribute name="prefix:myattr" namespace="http://any_uri">anyvalue</xupdate:attribute>B</xupdate:element>
</xupdate:append>
<xupdate:remove xmlns:againanotherprefix="http://any_uri" select="/erp5/object[3]/againanotherprefix:title"/>
<xupdate:append select="/erp5/object[3]" child="first()">
<xupdate:element name="title">A</xupdate:element>
</xupdate:append>
<xupdate:insert-after select="/erp5/object[3]">
<xupdate:insert-after xmlns:erp5="http://www.erp5.org/namespaces/erp5_object" select="/erp5/object[3]">
<xupdate:element name="erp5:object" namespace="http://www.erp5.org/namespaces/erp5_object">
<xupdate:attribute name="portal_type">Test</xupdate:attribute>
<title>B</title>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment