Commit 1ba251e9 authored by Nicolas Delaby's avatar Nicolas Delaby

Use empty namespace for Attribute nodes

parent bba61e96
......@@ -25,12 +25,14 @@ try:
from Ft.Xml.Domlette import NonvalidatingReader, PrettyPrint
parseString = NonvalidatingReader.parseString
from Ft.Xml.Domlette import implementation
from Ft.Xml import EMPTY_NAMESPACE
def getDOMImplementation():
return implementation
except ImportError:
from xml.dom.minidom import parse, parseString
from xml.dom.minidom import getDOMImplementation
from xml.dom.ext import PrettyPrint
EMPTY_NAMESPACE = None
import sys
import getopt
......@@ -110,10 +112,10 @@ class ERP5Diff:
createElement = self._result.createElementNS
createTextNode = self._result.createTextNode
append_element = createElement(self._ns, 'xupdate:append')
append_element.setAttributeNS(self._ns, 'select', path)
append_element.setAttributeNS(EMPTY_NAMESPACE, 'select', path)
for name, val in dict.iteritems():
attr_element = createElement(self._ns, 'xupdate:attribute')
attr_element.setAttributeNS(self._ns, 'name', name)
attr_element.setAttributeNS(EMPTY_NAMESPACE, 'name', name)
text_node = createTextNode(val)
attr_element.appendChild(text_node)
append_element.appendChild(attr_element)
......@@ -126,7 +128,7 @@ class ERP5Diff:
root = self._getResultRoot()
createElement = self._result.createElementNS
remove_element = createElement(self._ns, 'xupdate:remove')
remove_element.setAttributeNS(self._ns, 'select', self._concatPath(path, 'attribute::' + name))
remove_element.setAttributeNS(EMPTY_NAMESPACE, 'select', self._concatPath(path, 'attribute::' + name))
root.appendChild(remove_element)
def _xupdateUpdateAttribute(self, name, val, path):
......@@ -137,7 +139,7 @@ class ERP5Diff:
createElement = self._result.createElementNS
createTextNode = self._result.createTextNode
update_element = createElement(self._ns, 'xupdate:update')
update_element.setAttributeNS(self._ns, 'select', self._concatPath(path, 'attribute::' + name))
update_element.setAttributeNS(EMPTY_NAMESPACE, 'select', self._concatPath(path, 'attribute::' + name))
text_node = createTextNode(val)
update_element.appendChild(text_node)
root.appendChild(update_element)
......@@ -150,7 +152,7 @@ class ERP5Diff:
createElement = self._result.createElementNS
createTextNode = self._result.createTextNode
rename_element = createElement(self._ns, 'xupdate:rename')
rename_element.setAttributeNS(self._ns, 'select', path)
rename_element.setAttributeNS(EMPTY_NAMESPACE, 'select', path)
text_node = createTextNode(name)
rename_element.appendChild(text_node)
root.appendChild(rename_element)
......@@ -162,7 +164,7 @@ class ERP5Diff:
root = self._getResultRoot()
createElement = self._result.createElementNS
update_element = createElement(self._ns, 'xupdate:update')
update_element.setAttributeNS(self._ns ,'select', path)
update_element.setAttributeNS(EMPTY_NAMESPACE, 'select', path)
for node in element.childNodes:
#self._p("node is %s" % repr(node))
clone_node = node.cloneNode(1)
......@@ -176,7 +178,7 @@ class ERP5Diff:
root = self._getResultRoot()
createElement = self._result.createElementNS
remove_element = createElement(self._ns, 'xupdate:remove')
remove_element.setAttributeNS(self._ns, 'select', path)
remove_element.setAttributeNS(EMPTY_NAMESPACE, 'select', path)
root.appendChild(remove_element)
def _xupdateInsertBefore(self, element_list, path):
......@@ -187,14 +189,14 @@ class ERP5Diff:
createElement = self._result.createElementNS
createTextNode = self._result.createTextNode
insert_element = createElement(self._ns, 'xupdate:insert-before')
insert_element.setAttributeNS(self._ns, 'select', path)
insert_element.setAttributeNS(EMPTY_NAMESPACE, 'select', path)
for element in element_list:
child_element = createElement(self._ns, 'xupdate:element')
child_element.setAttributeNS(self._ns, 'name', element.tagName)
child_element.setAttributeNS(EMPTY_NAMESPACE, 'name', element.tagName)
attr_map = element.attributes
for attr in attr_map.values():
attr_element = createElement(self._ns, 'xupdate:attribute')
attr_element.setAttributeNS(self._ns, 'name', attr.name)
attr_element.setAttributeNS(EMPTY_NAMESPACE, 'name', attr.name)
text_node = createTextNode(attr.nodeValue)
attr_element.appendChild(text_node)
child_element.appendChild(attr_element)
......@@ -212,14 +214,14 @@ class ERP5Diff:
createElement = self._result.createElementNS
createTextNode = self._result.createTextNode
append_element = createElement(self._ns, 'xupdate:append')
append_element.setAttributeNS(self._ns, 'select', path)
append_element.setAttributeNS(EMPTY_NAMESPACE, 'select', path)
for element in element_list:
child_element = createElement(self._ns, 'xupdate:element')
child_element.setAttributeNS(self._ns, 'name', element.tagName)
child_element.setAttributeNS(EMPTY_NAMESPACE, 'name', element.tagName)
attr_map = element.attributes
for attr in attr_map.values():
attr_element = createElement(self._ns, 'xupdate:attribute')
attr_element.setAttributeNS(self._ns, 'name', attr.name)
attr_element.setAttributeNS(EMPTY_NAMESPACE, 'name', attr.name)
text_node = createTextNode(attr.nodeValue)
attr_element.appendChild(text_node)
child_element.appendChild(attr_element)
......@@ -440,7 +442,7 @@ class ERP5Diff:
if self._result is not None:
self._result.close()
self._result = impl.createDocument(self._ns, 'xupdate:modifications', None)
attr_version = self._result.createAttributeNS(self._ns, 'version')
attr_version = self._result.createAttributeNS(EMPTY_NAMESPACE, 'version')
attr_version.value = '1.0'
self._result.documentElement.setAttributeNodeNS(attr_version)
if self._testElements(old_root_element, new_root_element):
......
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