-1) Change _node_list_pointer to something faster than just a linked list.
- Currently there to test that unlinked node tracking works
-2) Possible create new object type for documents as these are the only types which need to track nodes
- - Would also require its own dtor functionality
-3) Define correct behavior. When certain types of nodes are destroyed,
- do we unlink children (if referenced) or just destroy them. (Element/Attribute nodes)
-4) Find out where XPath goes (this extension or its own)
-5) What DOM object types are really needed (i.e. not currently using DOMString)
-6) Determine how to handle non speced functionality.
- i.e validation (add method or implement as property for processing)
-
-
+For 5.1
+1) enhance XPath functionality
+2) look at auto encoding support for in/output
+3) What DOM object types are really needed (i.e. not currently using DOMString)
xmlNodePtr oldnode = NULL;
dom_object *intern;
char *name, *value = NULL;
- int name_len, value_len;
+ int name_len, value_len, name_valid;
+ 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", &id, dom_attr_class_entry, &name, &name_len, &value, &value_len) == FAILURE) {
+ php_std_error_handling();
return;
}
+ php_std_error_handling();
intern = (dom_object *)zend_object_store_get_object(id TSRMLS_CC);
- if (name_len == 0) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Attribute name is required");
+ name_valid = xmlValidateName((xmlChar *) name, 0);
+ if (name_valid != 0) {
+ php_dom_throw_error(INVALID_CHARACTER_ERR, 1 TSRMLS_CC);
RETURN_FALSE;
}
nodep = xmlNewProp(NULL, (xmlChar *) name, value);
- if (!nodep)
+ if (!nodep) {
+ php_dom_throw_error(INVALID_STATE_ERR, 1 TSRMLS_CC);
RETURN_FALSE;
+ }
if (intern != NULL) {
oldnode = (xmlNodePtr)intern->ptr;
char *value = NULL;
int value_len;
+ php_set_error_handling(EH_THROW, dom_domexception_class_entry TSRMLS_CC);
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os", &id, dom_cdatasection_class_entry, &value, &value_len) == FAILURE) {
+ php_std_error_handling();
return;
}
+ php_std_error_handling();
nodep = xmlNewCDataBlock(NULL, (xmlChar *) value, value_len);
- if (!nodep)
+ if (!nodep) {
+ php_dom_throw_error(INVALID_STATE_ERR, 1 TSRMLS_CC);
RETURN_FALSE;
+ }
intern = (dom_object *)zend_object_store_get_object(id TSRMLS_CC);
if (intern != NULL) {
char *value = NULL;
int value_len;
+ php_set_error_handling(EH_THROW, dom_domexception_class_entry TSRMLS_CC);
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O|s", &id, dom_comment_class_entry, &value, &value_len) == FAILURE) {
+ php_std_error_handling();
return;
}
+ php_std_error_handling();
nodep = xmlNewComment((xmlChar *) value);
- if (!nodep)
+ if (!nodep) {
+ php_dom_throw_error(INVALID_STATE_ERR, 1 TSRMLS_CC);
RETURN_FALSE;
+ }
intern = (dom_object *)zend_object_store_get_object(id TSRMLS_CC);
if (intern != NULL) {
-/* {{{ proto domelement dom_document_create_element(string tagName);
+/* {{{ proto domelement dom_document_create_element(string tagName [, string value]);
URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-2141741547
Since:
*/
char *encoding, *version = NULL;
int encoding_len = 0, version_len = 0, refcount;
+ php_set_error_handling(EH_THROW, dom_domexception_class_entry TSRMLS_CC);
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O|ss", &id, dom_document_class_entry, &version, &version_len, &encoding, &encoding_len) == FAILURE) {
+ php_std_error_handling();
return;
}
+ php_std_error_handling();
docp = xmlNewDoc(version);
- if (!docp)
+
+ if (!docp) {
+ php_dom_throw_error(INVALID_STATE_ERR, 1 TSRMLS_CC);
RETURN_FALSE;
+ }
if (encoding_len > 0) {
docp->encoding = (const xmlChar*)xmlStrdup(encoding);
xmlNodePtr nodep = NULL, oldnode = NULL;
dom_object *intern;
+ php_set_error_handling(EH_THROW, dom_domexception_class_entry TSRMLS_CC);
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &id, dom_documentfragment_class_entry) == FAILURE) {
+ php_std_error_handling();
return;
}
+ php_std_error_handling();
nodep = xmlNewDocFragment(NULL);
- if (!nodep)
+ if (!nodep) {
+ php_dom_throw_error(INVALID_STATE_ERR, 1 TSRMLS_CC);
RETURN_FALSE;
+ }
intern = (dom_object *)zend_object_store_get_object(id TSRMLS_CC);
if (intern != NULL) {
/* domexception errors */
typedef enum {
+/* PHP_ERR is non-spec code for PHP errors: */
+ PHP_ERR = 0,
INDEX_SIZE_ERR = 1,
DOMSTRING_SIZE_ERR = 2,
HIERARCHY_REQUEST_ERR = 3,
NOT_FOUND_ERR = 8,
NOT_SUPPORTED_ERR = 9,
INUSE_ATTRIBUTE_ERR = 10,
-// Introduced in DOM Level 2:
+/* Introduced in DOM Level 2: */
INVALID_STATE_ERR = 11,
-// Introduced in DOM Level 2:
+/* Introduced in DOM Level 2: */
SYNTAX_ERR = 12,
-// Introduced in DOM Level 2:
+/* Introduced in DOM Level 2: */
INVALID_MODIFICATION_ERR = 13,
-// Introduced in DOM Level 2:
+/* Introduced in DOM Level 2: */
NAMESPACE_ERR = 14,
-// Introduced in DOM Level 2:
+/* Introduced in DOM Level 2: */
INVALID_ACCESS_ERR = 15,
-// Introduced in DOM Level 3:
+/* Introduced in DOM Level 3: */
VALIDATION_ERR = 16
} dom_exception_code;
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;
}
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);
char *name;
int name_len;
+ php_set_error_handling(EH_THROW, dom_domexception_class_entry TSRMLS_CC);
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os", &id, dom_entityreference_class_entry, &name, &name_len) == FAILURE) {
+ php_std_error_handling();
return;
}
+ php_std_error_handling();
if (name_len == 0) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Entity Reference name is required");
+ php_dom_throw_error(INVALID_CHARACTER_ERR, 1 TSRMLS_CC);
RETURN_FALSE;
}
node = xmlNewReference(NULL, name);
- if (!node)
+ if (!node) {
+ php_dom_throw_error(INVALID_STATE_ERR, 1 TSRMLS_CC);
RETURN_FALSE;
+ }
intern = (dom_object *)zend_object_store_get_object(id TSRMLS_CC);
if (intern != NULL) {
REGISTER_LONG_CONSTANT("XML_ATTRIBUTE_ENUMERATION", XML_ATTRIBUTE_ENUMERATION, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("XML_ATTRIBUTE_NOTATION", XML_ATTRIBUTE_NOTATION, CONST_CS | CONST_PERSISTENT);
- /* domException Codes */
+ /* DOMException Codes */
+ REGISTER_LONG_CONSTANT("DOM_PHP_ERR", PHP_ERR, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("DOM_INDEX_SIZE_ERR", INDEX_SIZE_ERR, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("DOMSTRING_SIZE_ERR", DOMSTRING_SIZE_ERR, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("DOM_HIERARCHY_REQUEST_ERR", HIERARCHY_REQUEST_ERR, CONST_CS | CONST_PERSISTENT);
char *name, *value = NULL;
int name_len, value_len;
+ 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", &id, dom_processinginstruction_class_entry, &name, &name_len, &value, &value_len) == FAILURE) {
+ php_std_error_handling();
return;
}
+ php_std_error_handling();
if (name_len == 0) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "PI name is required");
+ php_dom_throw_error(INVALID_CHARACTER_ERR, 1 TSRMLS_CC);
RETURN_FALSE;
}
nodep = xmlNewPI((xmlChar *) name, (xmlChar *) value);
- if (!nodep)
+ if (!nodep) {
+ php_dom_throw_error(INVALID_STATE_ERR, 1 TSRMLS_CC);
RETURN_FALSE;
+ }
intern = (dom_object *)zend_object_store_get_object(id TSRMLS_CC);
if (intern != NULL) {
char *value = NULL;
int value_len;
+ php_set_error_handling(EH_THROW, dom_domexception_class_entry TSRMLS_CC);
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O|s", &id, dom_text_class_entry, &value, &value_len) == FAILURE) {
+ php_std_error_handling();
return;
}
+ php_std_error_handling();
nodep = xmlNewText((xmlChar *) value);
- if (!nodep)
+ if (!nodep) {
+ php_dom_throw_error(INVALID_STATE_ERR, 1 TSRMLS_CC);
RETURN_FALSE;
+ }
intern = (dom_object *)zend_object_store_get_object(id TSRMLS_CC);
if (intern != NULL) {
dom_object *docobj, *intern;
xmlXPathContextPtr ctx, oldctx;
+ php_set_error_handling(EH_THROW, dom_domexception_class_entry TSRMLS_CC);
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "OO", &id, dom_xpath_class_entry, &doc, dom_document_class_entry) == FAILURE) {
+ php_std_error_handling();
return;
}
+ php_std_error_handling();
DOM_GET_OBJ(docp, doc, xmlDocPtr, docobj);
ctx = xmlXPathNewContext(docp);
if (ctx == NULL) {
+ php_dom_throw_error(INVALID_STATE_ERR, 1 TSRMLS_CC);
RETURN_FALSE;
}