# HG changeset patch # User paulb # Date 1176072725 0 # Node ID b418829e3e4517388576b5f0f80e6afec8c03d75 # Parent e062bab9737f16fa009ddc6a9ec9f220b8c8edf6 [project @ 2007-04-08 22:52:05 by paulb] Moved document checking into the Node class. Introduced a Node_equals function for comparisons. diff -r e062bab9737f -r b418829e3e45 libxml2dom/macrolib/macrolib.py --- a/libxml2dom/macrolib/macrolib.py Sun Apr 08 22:51:59 2007 +0000 +++ b/libxml2dom/macrolib/macrolib.py Sun Apr 08 22:52:05 2007 +0000 @@ -49,10 +49,6 @@ else: return s -def check_document(node, tmp): - if Node_ownerDocument(tmp) is not None and Node_ownerDocument(node) is not Node_ownerDocument(tmp): - raise xml.dom.DOMException(xml.dom.WRONG_DOCUMENT_ERR) - def get_ns(ns): out_ns = to_unicode(libxml2mod.xmlNodeGetContent(ns)) # Detect "" and produce None as the empty namespace. @@ -162,6 +158,9 @@ for label, value in _nodeTypes.items(): _reverseNodeTypes[value] = label +def Node_equals(node, other): + return libxml2mod.xmlXPathCmpNodes(node, other) == 0 + def Node_ownerDocument(node): return libxml2mod.doc(node) @@ -417,15 +416,12 @@ return libxml2mod.xmlNewCDataBlock(Node_ownerDocument(node), value, len(value)) def Node_insertBefore(node, tmp, oldNode): - check_document(node, tmp) return libxml2mod.xmlAddPrevSibling(oldNode, tmp) def Node_replaceChild(node, tmp, oldNode): - check_document(node, tmp) return libxml2mod.xmlReplaceNode(oldNode, tmp) def Node_appendChild(node, tmp): - check_document(node, tmp) return libxml2mod.xmlAddChild(node, tmp) def Node_removeChild(node, child):