Commit 3c5d0125 authored by Nicolas Delaby's avatar Nicolas Delaby

Add test for namespace support

parent 7b75fa37
......@@ -693,6 +693,81 @@ does not work as bellow example. This is a known bug.
<xupdate:update select="/object[3]/title">C</xupdate:update>
</xupdate:modifications>
23. Modify nodes with Qualified Names
ERP5Diff should create xpath valid expression with correct prefix
>>> old_xml = """
... <erp5>
... <object portal_type="Test">
... <prefix:title xmlns:prefix="http://any_uri">A</prefix:title>
... </object>
... <object portal_type="Test">
... <prefixbis:title xmlns:prefixbis="http://any_uri_bis">A</prefixbis:title>
... </object>
... <object portal_type="Test">
... <againanotherprefix:title xmlns:againanotherprefix="http://any_uri">A</againanotherprefix:title>
... </object>
... </erp5>
... """
>>> new_xml = """
... <erp5>
... <object portal_type="Test">
... <anotherprefix:title xmlns:anotherprefix="http://any_uri">A</anotherprefix:title>
... </object>
... <object portal_type="Test">
... <prefix:title xmlns:prefix="http://any_uri" prefix:myattr="anyvalue">B</prefix:title>
... </object>
... <object portal_type="Test">
... <title>A</title>
... </object>
... <erp5:object portal_type="Test" xmlns:erp5="http://www.erp5.org/namespaces/erp5_object">
... <title>B</title>
... </erp5:object>
... <object portal_type="Test">
... <prefix:title xmlns:prefix="http://any_uri">C</prefix:title>
... </object>
... </erp5>
... """
>>> erp5diff.compare(old_xml, new_xml)
>>> erp5diff.output()
<xupdate:modifications xmlns:xupdate="http://www.xmldb.org/xupdate" version="1.0">
<xupdate:remove select="/object[2]/prefixbis:title"/>
<xupdate:append select="/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 select="/object[3]/againanotherprefix:title"/>
<xupdate:append select="/object[3]" child="first()">
<xupdate:element name="title">A</xupdate:element>
</xupdate:append>
<xupdate:insert-after select="/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>
</xupdate:element>
<xupdate:element name="object"><xupdate:attribute name="portal_type">Test</xupdate:attribute><prefix:title xmlns:prefix="http://any_uri">C</prefix:title>
</xupdate:element>
</xupdate:insert-after>
</xupdate:modifications>
24. Modify nodes with Qualified Names
Work on Attributes specially
>>> old_xml = """
... <erp5>
... <object portal_type="Test">
... <title xmlns:prefix="http://any_uri" prefix:attr="A">A</title>
... </object>
... </erp5>
... """
>>> new_xml = """
... <erp5>
... <object portal_type="Test">
... <title xmlns:prefix="http://any_uri" prefix:attr="B">A</title>
... </object>
... </erp5>
... """
>>> erp5diff.compare(old_xml, new_xml)
>>> erp5diff.output()
<xupdate:modifications xmlns:xupdate="http://www.xmldb.org/xupdate" version="1.0">
<xupdate:update select="/object/title/attribute::prefix:attr">B</xupdate:update>
</xupdate:modifications>
- 2003-12-04, Yoshinori OKUJI <yo@nexedi.com>
- 2009-09-15, Tatuya Kamada <tatuya@nexedi.com>
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