summaryrefslogtreecommitdiff
path: root/ext/dom/element.c
diff options
context:
space:
mode:
authorRob Richards <rrichards@php.net>2004-05-16 10:30:16 +0000
committerRob Richards <rrichards@php.net>2004-05-16 10:30:16 +0000
commit9e3956b313ef74f0e7c4881ca39c9395036d45bb (patch)
treef14ce42a575f226ac068b10f216df59c04c32896 /ext/dom/element.c
parent92c72cb8d85d9115c08f857f2237bd532848a786 (diff)
downloadphp-git-9e3956b313ef74f0e7c4881ca39c9395036d45bb.tar.gz
constructors throw DOMException
add DOM_PHP_ERR DomException code validate tagnames in constructors use C style comments update TODO
Diffstat (limited to 'ext/dom/element.c')
-rw-r--r--ext/dom/element.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/ext/dom/element.c b/ext/dom/element.c
index 944c9c946e..c817a3c01e 100644
--- a/ext/dom/element.c
+++ b/ext/dom/element.c
@@ -68,15 +68,19 @@ PHP_METHOD(domelement, __construct)
char *name, *value = NULL, *uri = NULL;
char *localname = NULL, *prefix = NULL;
int errorcode = 0, uri_len = 0;
- int name_len, value_len = 0;
+ int name_len, value_len = 0, name_valid;
xmlNsPtr nsptr = NULL;
+ php_set_error_handling(EH_THROW, dom_domexception_class_entry TSRMLS_CC);
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) {
+ php_std_error_handling();
return;
}
- if (name_len == 0) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Element name is required");
+ php_std_error_handling();
+ name_valid = xmlValidateName((xmlChar *) name, 0);
+ if (name_valid != 0) {
+ php_dom_throw_error(INVALID_CHARACTER_ERR, 1 TSRMLS_CC);
RETURN_FALSE;
}
@@ -98,15 +102,17 @@ PHP_METHOD(domelement, __construct)
if (nodep != NULL) {
xmlFree(nodep);
}
- php_dom_throw_error(errorcode, 0 TSRMLS_CC);
+ php_dom_throw_error(errorcode, 1 TSRMLS_CC);
RETURN_FALSE;
}
} else {
nodep = xmlNewNode(NULL, (xmlChar *) name);
}
- if (!nodep)
+ if (!nodep) {
+ php_dom_throw_error(INVALID_STATE_ERR, 1 TSRMLS_CC);
RETURN_FALSE;
+ }
if (value_len > 0) {
xmlNodeSetContentLen(nodep, value, value_len);