rrichards Sun Feb 22 08:05:50 2004 EDT
Modified files:
/php-src/ext/dom element.c
Log:
add optional third parameter to support namespace in constructor
http://cvs.php.net/diff.php/php-src/ext/dom/element.c?r1=1.25&r2=1.26&ty=u
Index: php-src/ext/dom/element.c
diff -u php-src/ext/dom/element.c:1.25 php-src/ext/dom/element.c:1.26
--- php-src/ext/dom/element.c:1.25 Mon Feb 16 08:06:33 2004
+++ php-src/ext/dom/element.c Sun Feb 22 08:05:49 2004
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: element.c,v 1.25 2004/02/16 13:06:33 rrichards Exp $ */
+/* $Id: element.c,v 1.26 2004/02/22 13:05:49 rrichards Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -65,10 +65,13 @@
zval *id;
xmlNodePtr nodep = NULL, oldnode = NULL;
dom_object *intern;
- char *name, *value = NULL;
+ char *name, *value = NULL, *uri = NULL;
+ char *localname = NULL, *prefix = NULL;
+ int errorcode = 0, uri_len = 0;
int name_len, value_len = 0;
+ xmlNsPtr nsptr = NULL;
- if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os|s",
&id, dom_element_class_entry, &name, &name_len, &value, &value_len) == FAILURE) {
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(),
"Os|s!s", &id, dom_element_class_entry, &name, &name_len, &value, &value_len, &uri,
&uri_len) == FAILURE) {
return;
}
@@ -77,7 +80,30 @@
RETURN_FALSE;
}
- nodep = xmlNewNode(NULL, (xmlChar *) name);
+ /* Namespace logic is seperate and only when uri passed in to insure no BC
breakage */
+ if (uri_len > 0) {
+ errorcode = dom_check_qname(name, &localname, &prefix, uri_len,
name_len);
+ if (errorcode == 0) {
+ nodep = xmlNewNode (NULL, localname);
+ if (nodep != NULL && uri != NULL) {
+ nsptr = dom_get_ns(nodep, uri, &errorcode, prefix);
+ xmlSetNs(nodep, nsptr);
+ }
+ }
+ xmlFree(localname);
+ if (prefix != NULL) {
+ xmlFree(prefix);
+ }
+ if (errorcode != 0) {
+ if (nodep != NULL) {
+ xmlFree(nodep);
+ }
+ php_dom_throw_error(errorcode, 0 TSRMLS_CC);
+ RETURN_FALSE;
+ }
+ } else {
+ nodep = xmlNewNode(NULL, (xmlChar *) name);
+ }
if (!nodep)
RETURN_FALSE;
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php