Commit a02fed41 authored by Nicolas Delaby's avatar Nicolas Delaby

Fix bug where append sub-elements where misordered


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk/utils/xupdate_processor@42471 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent a421d310
......@@ -213,6 +213,7 @@ class XUpdateHandler(ContentHandler):
elif localname == 'element':
node_stack_position = self._current_position_to_append_stack.pop()
node_to_append_list = [self._node_stack.pop() for node in self._node_stack[node_stack_position:]]
node_to_append_list.reverse()
node = self._node_stack[-1]
node.extend(node_to_append_list)
if len(node):
......
......@@ -449,6 +449,67 @@ class TestXUpdateProcessor(unittest.TestCase):
<title xmlns:prefix="http://any_uri" prefix:attr="B">A</title>
</object>
</aaa:erp5>
"""
self._assertXUprocWorks(xml_xu_string, xml_doc_string,
expected_result_string)
def test_NodeCreationWithMultipleSubElements(self):
"""check that creation of new node with multiple sub elements,
will not append them in reverse order
"""
xml_doc_string = """
<erp5>
<object portal_type="Test"/>
<object1/>
<object2/>
<object3/>
</erp5>
"""
xml_xu_string = """
<xupdate:modifications xmlns:xupdate="http://www.xmldb.org/xupdate" version="1.0">
<xupdate:insert-after select="/erp5/object[1]">
<xupdate:element name="workflow_action">
<xupdate:attribute name="id">edit_workflow</xupdate:attribute>
<action type="string">edit</action>
<comment type="None"/>
<error_message type="string"/>
<state type="string">current</state>
</xupdate:element>
</xupdate:insert-after>
<xupdate:insert-after select="/erp5/object1">
<action type="string">edit</action>
<comment type="None"/>
<error_message type="string"/>
<state type="string">current</state>
</xupdate:insert-after>
<xupdate:insert-before select="/erp5/object3">
<action type="string">edit</action>
<comment type="None"/>
<error_message type="string"/>
<state type="string">current</state>
</xupdate:insert-before>
</xupdate:modifications>
"""
expected_result_string = """<erp5>
<object portal_type="Test"/>
<workflow_action id="edit_workflow">
<action type="string">edit</action>
<comment type="None"/>
<error_message type="string"/>
<state type="string">current</state>
</workflow_action>
<object1/>
<action type="string">edit</action>
<comment type="None"/>
<error_message type="string"/>
<state type="string">current</state>
<object2/>
<action type="string">edit</action>
<comment type="None"/>
<error_message type="string"/>
<state type="string">current</state>
<object3/>
</erp5>
"""
self._assertXUprocWorks(xml_xu_string, xml_doc_string,
expected_result_string)
......
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