import_node patch

[email protected] (Eric Bourque)
Newsgroups php.xml.dev
Message-ID <[email protected]>
Hi,

Here is a patch to import_node in domxml. I don't know where else to
send it since mail to the original author didn't get a response. Perhaps
someone can inform me of the correct place to send it.

This patch does two things:

(1) renames imported_node to import_node to follow the DOM function
naming.

(2) makes sure that the (new) owner document is set properly for all
descendants in the imported subtree, instead of just the node itself.

This patch is against 4.3.1.

Cheers,

Eric
php-4.3.1-domxml.patch (text/x-patch, 1.8 KB)
diff -ur php-4.3.1.orig/ext/domxml/php_domxml.c php-4.3.1/ext/domxml/php_domxml.c
--- php-4.3.1.orig/ext/domxml/php_domxml.c	2002-12-05 17:15:37.000000000 -0500
+++ php-4.3.1/ext/domxml/php_domxml.c	2003-03-10 15:39:44.000000000 -0500
@@ -323,7 +323,7 @@
 	PHP_FALIAS(set_root,				domxml_doc_set_root,			NULL)
 	PHP_FALIAS(get_root,				domxml_doc_document_element,	NULL)
 	PHP_FALIAS(root,					domxml_doc_document_element,	NULL)
-	PHP_FALIAS(imported_node,			domxml_doc_imported_node,		NULL)
+	PHP_FALIAS(import_node,			    domxml_doc_import_node, 		NULL)
 	PHP_FALIAS(dtd,						domxml_intdtd,					NULL)
 	PHP_FALIAS(ids,						domxml_doc_ids,					NULL)
 	PHP_FALIAS(dumpmem,					domxml_dump_mem,				NULL)
@@ -3514,9 +3514,9 @@
 }
 /* }}} */
 
-/* {{{ proto object domxml_doc_imported_node(object node, bool recursive)
+/* {{{ proto object domxml_doc_import_node(object node, bool recursive)
    Creates new element node */
-PHP_FUNCTION(domxml_doc_imported_node)
+PHP_FUNCTION(domxml_doc_import_node)
 {
 	zval *arg1, *id, *rv = NULL;
 	xmlNodePtr node, srcnode;
@@ -3536,7 +3536,7 @@
 	if (!node) {
 		RETURN_FALSE;
 	}
-	node->doc = docp;			/* Not enough because other nodes in the tree are not set */
+	xmlSetTreeDoc(node,docp);
 
 	DOMXML_RET_OBJ(rv, node, &ret);
 }
diff -ur php-4.3.1.orig/ext/domxml/php_domxml.h php-4.3.1/ext/domxml/php_domxml.h
--- php-4.3.1.orig/ext/domxml/php_domxml.h	2002-08-23 11:26:19.000000000 -0400
+++ php-4.3.1/ext/domxml/php_domxml.h	2003-03-10 15:38:45.000000000 -0500
@@ -97,7 +97,7 @@
 PHP_FUNCTION(domxml_doc_create_attribute);
 PHP_FUNCTION(domxml_doc_create_cdata_section);
 PHP_FUNCTION(domxml_doc_create_entity_reference);
-PHP_FUNCTION(domxml_doc_imported_node);
+PHP_FUNCTION(domxml_doc_import_node);
 PHP_FUNCTION(domxml_doc_add_root);
 PHP_FUNCTION(domxml_doc_document_element);
 PHP_FUNCTION(domxml_doc_set_root);
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.