diff options
Diffstat (limited to 'ext/dom/element.c')
-rw-r--r-- | ext/dom/element.c | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/ext/dom/element.c b/ext/dom/element.c index afd8a11ab..3a43a32a7 100644 --- a/ext/dom/element.c +++ b/ext/dom/element.c @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: element.c,v 1.30.2.2 2004/11/18 19:55:00 rrichards Exp $ */ +/* $Id: element.c,v 1.30.2.4 2005/05/20 15:02:48 rrichards Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -250,7 +250,7 @@ PHP_FUNCTION(dom_element_set_attribute) } attr = xmlHasProp(nodep,name); - if (attr != NULL) { + if (attr != NULL && attr->type != XML_ATTRIBUTE_DECL) { node_list_unlink(attr->children TSRMLS_CC); } attr = xmlSetProp(nodep, name, value); @@ -294,13 +294,14 @@ PHP_FUNCTION(dom_element_remove_attribute) RETURN_FALSE; } - /* TODO: DTD defined attributes are handled special */ - if (php_dom_object_get_data((xmlNodePtr) attrp) == NULL) { - node_list_unlink(attrp->children TSRMLS_CC); - xmlUnlinkNode((xmlNodePtr) attrp); - xmlFreeProp(attrp); - } else { - xmlUnlinkNode((xmlNodePtr) attrp); + if (attrp->type != XML_ATTRIBUTE_DECL) { + if (php_dom_object_get_data((xmlNodePtr) attrp) == NULL) { + node_list_unlink(attrp->children TSRMLS_CC); + xmlUnlinkNode((xmlNodePtr) attrp); + xmlFreeProp(attrp); + } else { + xmlUnlinkNode((xmlNodePtr) attrp); + } } RETURN_TRUE; @@ -368,7 +369,7 @@ PHP_FUNCTION(dom_element_set_attribute_node) } existattrp = xmlHasProp(nodep, attrp->name); - if (existattrp != NULL) { + if (existattrp != NULL && existattrp->type != XML_ATTRIBUTE_DECL) { if ((oldobj = php_dom_object_get_data((xmlNodePtr) existattrp)) != NULL && ((php_libxml_node_ptr *)oldobj->ptr)->node == (xmlNodePtr) attrp) { @@ -540,7 +541,7 @@ PHP_FUNCTION(dom_element_set_attribute_ns) if (errorcode == 0) { if (uri_len > 0) { nodep = (xmlNodePtr) xmlHasNsProp(elemp, localname, uri); - if (nodep != NULL) { + if (nodep != NULL && nodep->type != XML_ATTRIBUTE_DECL) { node_list_unlink(nodep->children TSRMLS_CC); } @@ -578,7 +579,7 @@ PHP_FUNCTION(dom_element_set_attribute_ns) } } else { attr = xmlHasProp(elemp, localname); - if (attr != NULL) { + if (attr != NULL && attr->type != XML_ATTRIBUTE_DECL) { node_list_unlink(attr->children TSRMLS_CC); } attr = xmlSetProp(elemp, localname, value); @@ -642,7 +643,7 @@ PHP_FUNCTION(dom_element_remove_attribute_ns) } } - if (attrp) { + if (attrp && attrp->type != XML_ATTRIBUTE_DECL) { if (php_dom_object_get_data((xmlNodePtr) attrp) == NULL) { node_list_unlink(attrp->children TSRMLS_CC); xmlUnlinkNode((xmlNodePtr) attrp); @@ -726,7 +727,7 @@ PHP_FUNCTION(dom_element_set_attribute_node_ns) existattrp = xmlHasProp(nodep, attrp->name); } - if (existattrp != NULL) { + if (existattrp != NULL && existattrp->type != XML_ATTRIBUTE_DECL) { if ((oldobj = php_dom_object_get_data((xmlNodePtr) existattrp)) != NULL && ((php_libxml_node_ptr *)oldobj->ptr)->node == (xmlNodePtr) attrp) { |