diff options
author | SVN Migration <svn@php.net> | 2004-01-25 12:03:25 +0000 |
---|---|---|
committer | SVN Migration <svn@php.net> | 2004-01-25 12:03:25 +0000 |
commit | 22476b36ce621bdd115493bab84cbe706e422a7c (patch) | |
tree | 1124d1c5af68860a78c2252bb0dac63c9f18156e /ext/dom | |
parent | eb7aca4ea896b09cb9afc2466a46f4720acc4a4e (diff) | |
download | php-git-php_ibase_before_split.tar.gz |
This commit was manufactured by cvs2svn to create tagphp_ibase_before_split
'php_ibase_before_split'.
Diffstat (limited to 'ext/dom')
71 files changed, 0 insertions, 11311 deletions
diff --git a/ext/dom/CREDITS b/ext/dom/CREDITS deleted file mode 100644 index b78e376d6e..0000000000 --- a/ext/dom/CREDITS +++ /dev/null @@ -1,2 +0,0 @@ -DOM -Christian Stocker, Rob Richards, Marcus Boerger diff --git a/ext/dom/EXPERIMENTAL b/ext/dom/EXPERIMENTAL deleted file mode 100644 index 293159a693..0000000000 --- a/ext/dom/EXPERIMENTAL +++ /dev/null @@ -1,5 +0,0 @@ -this module is experimental, -its functions may change their names -or move to extension all together -so do not rely to much on them -you have been warned! diff --git a/ext/dom/TODO b/ext/dom/TODO deleted file mode 100644 index f6b7fe2e61..0000000000 --- a/ext/dom/TODO +++ /dev/null @@ -1,12 +0,0 @@ -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) - - diff --git a/ext/dom/attr.c b/ext/dom/attr.c deleted file mode 100644 index c5bf81897a..0000000000 --- a/ext/dom/attr.c +++ /dev/null @@ -1,238 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP Version 5 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2004 The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 3.0 of the PHP license, | - | that is bundled with this package in the file LICENSE, and is | - | available through the world-wide-web at the following url: | - | http://www.php.net/license/3_0.txt. | - | If you did not receive a copy of the PHP license and are unable to | - | obtain it through the world-wide-web, please send a note to | - | license@php.net so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - | Authors: Christian Stocker <chregu@php.net> | - | Rob Richards <rrichards@php.net> | - +----------------------------------------------------------------------+ -*/ - -/* $Id$ */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "php.h" - -#if HAVE_LIBXML && HAVE_DOM - -#include "php_dom.h" - - -/* -* class domattr extends domnode -* -* URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#ID-637646024 -* Since: -*/ - -zend_function_entry php_dom_attr_class_functions[] = { - PHP_FALIAS(isId, dom_attr_is_id, NULL) - PHP_FALIAS(domattr, dom_attr_attr, NULL) - {NULL, NULL, NULL} -}; - -/* {{{ proto domnode dom_attr_attr(string name, [string value]); */ -PHP_FUNCTION(dom_attr_attr) -{ - - zval *id; - xmlAttrPtr nodep = NULL; - xmlNodePtr oldnode = NULL; - dom_object *intern; - char *name, *value = NULL; - int name_len, value_len; - - 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) { - return; - } - - 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"); - RETURN_FALSE; - } - - nodep = xmlNewProp(NULL, (xmlChar *) name, value); - - if (!nodep) - RETURN_FALSE; - - if (intern != NULL) { - oldnode = (xmlNodePtr)intern->ptr; - if (oldnode != NULL) { - php_libxml_node_free_resource(oldnode TSRMLS_CC); - } - php_libxml_increment_node_ptr((php_libxml_node_object *)intern, (xmlNodePtr)nodep, (void *)intern TSRMLS_CC); - } -} - -/* }}} end dom_attr_attr */ - - -/* {{{ proto name string -readonly=yes -URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#ID-1112119403 -Since: -*/ -int dom_attr_name_read(dom_object *obj, zval **retval TSRMLS_DC) -{ - xmlAttrPtr attrp; - - attrp = (xmlAttrPtr) dom_object_get_node(obj); - ALLOC_ZVAL(*retval); - ZVAL_STRING(*retval, (char *) (attrp->name), 1); - - return SUCCESS; -} - -/* }}} */ - - - -/* {{{ proto specified boolean -readonly=yes -URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#ID-862529273 -Since: -*/ -int dom_attr_specified_read(dom_object *obj, zval **retval TSRMLS_DC) -{ - /* TODO */ - ALLOC_ZVAL(*retval); - ZVAL_TRUE(*retval); - return SUCCESS; -} - -/* }}} */ - - - -/* {{{ proto value string -readonly=no -URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#ID-221662474 -Since: -*/ -int dom_attr_value_read(dom_object *obj, zval **retval TSRMLS_DC) -{ - xmlAttrPtr attrp; - xmlChar *content; - - attrp = (xmlAttrPtr) dom_object_get_node(obj); - - ALLOC_ZVAL(*retval); - - - if ((content = xmlNodeGetContent((xmlNodePtr) attrp)) != NULL) { - ZVAL_STRING(*retval, content, 1); - } else { - ZVAL_EMPTY_STRING(*retval); - } - - xmlFree(content); - - return SUCCESS; - -} - -int dom_attr_value_write(dom_object *obj, zval *newval TSRMLS_DC) -{ - xmlAttrPtr attrp; - - attrp = (xmlAttrPtr) dom_object_get_node(obj); - - if (attrp->children) { - node_list_unlink(attrp->children TSRMLS_CC); - } - xmlNodeSetContentLen((xmlNodePtr) attrp, Z_STRVAL_P(newval), Z_STRLEN_P(newval) + 1); - - return SUCCESS; -} - -/* }}} */ - - - -/* {{{ proto ownerElement element -readonly=yes -URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#Attr-ownerElement -Since: DOM Level 2 -*/ -int dom_attr_owner_element_read(dom_object *obj, zval **retval TSRMLS_DC) -{ - xmlNodePtr nodep, nodeparent; - int ret; - - nodep = dom_object_get_node(obj); - - nodeparent = nodep->parent; - if (!nodeparent) { - return FAILURE; - } - - ALLOC_ZVAL(*retval); - - if (NULL == (*retval = php_dom_create_object(nodeparent, &ret, NULL, *retval, obj TSRMLS_CC))) { - php_error(E_WARNING, "Cannot create required DOM object"); - return FAILURE; - } - return SUCCESS; - -} - -/* }}} */ - - - -/* {{{ proto schemaTypeInfo typeinfo -readonly=yes -URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#Attr-schemaTypeInfo -Since: DOM Level 3 -*/ -int dom_attr_schema_type_info_read(dom_object *obj, zval **retval TSRMLS_DC) -{ - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Not yet implemented"); - ALLOC_ZVAL(*retval); - ZVAL_NULL(*retval); - return SUCCESS; -} - -/* }}} */ - - - -/* {{{ proto boolean dom_attr_is_id(); -URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#Attr-isId -Since: DOM Level 3 -*/ -PHP_FUNCTION(dom_attr_is_id) -{ - zval *id; - dom_object *intern; - xmlAttrPtr attrp; - xmlNodePtr nodep; - - DOM_GET_THIS_OBJ(attrp, id, xmlAttrPtr, intern); - - nodep = attrp->parent; - - if (xmlIsID(attrp->doc, nodep, attrp)) { - RETURN_TRUE; - } else { - RETURN_FALSE; - } -} -/* }}} end dom_attr_is_id */ - -#endif diff --git a/ext/dom/cdatasection.c b/ext/dom/cdatasection.c deleted file mode 100644 index 0daab0bfcc..0000000000 --- a/ext/dom/cdatasection.c +++ /dev/null @@ -1,73 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP Version 5 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2004 The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 3.0 of the PHP license, | - | that is bundled with this package in the file LICENSE, and is | - | available through the world-wide-web at the following url: | - | http://www.php.net/license/3_0.txt. | - | If you did not receive a copy of the PHP license and are unable to | - | obtain it through the world-wide-web, please send a note to | - | license@php.net so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - | Authors: Christian Stocker <chregu@php.net> | - | Rob Richards <rrichards@php.net> | - +----------------------------------------------------------------------+ -*/ - -/* $Id$ */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "php.h" -#if HAVE_LIBXML && HAVE_DOM -#include "php_dom.h" - - -/* -* class domcdatasection extends domtext -* -* URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#ID-667469212 -* Since: -*/ - -zend_function_entry php_dom_cdatasection_class_functions[] = { - PHP_FALIAS("domcdatasection", dom_cdatasection_cdatasection, NULL) - {NULL, NULL, NULL} -}; - -/* {{{ proto domnode dom_cdatasection_cdatasection(string value); */ -PHP_FUNCTION(dom_cdatasection_cdatasection) -{ - - zval *id; - xmlNodePtr nodep = NULL, oldnode = NULL; - dom_object *intern; - char *value = NULL; - int value_len; - - if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os", &id, dom_cdatasection_class_entry, &value, &value_len) == FAILURE) { - return; - } - - nodep = xmlNewCDataBlock(NULL, (xmlChar *) value, value_len); - - if (!nodep) - RETURN_FALSE; - - intern = (dom_object *)zend_object_store_get_object(id TSRMLS_CC); - if (intern != NULL) { - oldnode = (xmlNodePtr)intern->ptr; - if (oldnode != NULL) { - php_libxml_node_free_resource(oldnode TSRMLS_CC); - } - php_libxml_increment_node_ptr((php_libxml_node_object *)intern, nodep, (void *)intern TSRMLS_CC); - } -} -/* }}} end dom_cdatasection_cdatasection */ - -#endif diff --git a/ext/dom/characterdata.c b/ext/dom/characterdata.c deleted file mode 100644 index 4e4fe86747..0000000000 --- a/ext/dom/characterdata.c +++ /dev/null @@ -1,350 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP Version 5 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2004 The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 3.0 of the PHP license, | - | that is bundled with this package in the file LICENSE, and is | - | available through the world-wide-web at the following url: | - | http://www.php.net/license/3_0.txt. | - | If you did not receive a copy of the PHP license and are unable to | - | obtain it through the world-wide-web, please send a note to | - | license@php.net so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - | Authors: Christian Stocker <chregu@php.net> | - | Rob Richards <rrichards@php.net> | - +----------------------------------------------------------------------+ -*/ - -/* $Id$ */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "php.h" -#if HAVE_LIBXML && HAVE_DOM -#include "php_dom.h" - - -/* -* class domcharacterdata extends domnode -* -* URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-FF21A306 -* Since: -*/ - -zend_function_entry php_dom_characterdata_class_functions[] = { - PHP_FALIAS(substringData, dom_characterdata_substring_data, NULL) - PHP_FALIAS(appendData, dom_characterdata_append_data, NULL) - PHP_FALIAS(insertData, dom_characterdata_insert_data, NULL) - PHP_FALIAS(deleteData, dom_characterdata_delete_data, NULL) - PHP_FALIAS(replaceData, dom_characterdata_replace_data, NULL) - {NULL, NULL, NULL} -}; - -/* {{{ proto data string -readonly=no -URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-72AB8359 -Since: -*/ -int dom_characterdata_data_read(dom_object *obj, zval **retval TSRMLS_DC) -{ - xmlNodePtr nodep; - xmlChar *content; - - nodep = dom_object_get_node(obj); - - ALLOC_ZVAL(*retval); - - if ((content = xmlNodeGetContent(nodep)) != NULL) { - ZVAL_STRING(*retval, content, 1); - } else { - ZVAL_EMPTY_STRING(*retval); - } - - xmlFree(content); - - return SUCCESS; -} - -int dom_characterdata_data_write(dom_object *obj, zval *newval TSRMLS_DC) -{ - xmlNode *nodep; - - nodep = dom_object_get_node(obj); - xmlNodeSetContentLen(nodep, Z_STRVAL_P(newval), Z_STRLEN_P(newval) + 1); - return SUCCESS; -} - -/* }}} */ - -/* {{{ proto length unsigned long -readonly=yes -URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-7D61178C -Since: -*/ -int dom_characterdata_length_read(dom_object *obj, zval **retval TSRMLS_DC) -{ - xmlNodePtr nodep; - xmlChar *content; - long length; - - nodep = dom_object_get_node(obj); - - ALLOC_ZVAL(*retval); - - content = xmlNodeGetContent(nodep); - length = xmlUTF8Strlen(content); - - xmlFree(content); - ZVAL_LONG(*retval, length); - - return SUCCESS; -} - -/* }}} */ - - - - -/* {{{ proto domstring dom_characterdata_substring_data(unsigned long offset, unsigned long count); -URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-6531BCCF -Since: -*/ -PHP_FUNCTION(dom_characterdata_substring_data) -{ - xmlChar *cur; - xmlChar *substring; - xmlNodePtr node; - long offset, count; - int length; - dom_object *intern; - - DOM_GET_THIS_OBJ(node, getThis(), xmlNodePtr, intern); - - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ll", &offset, &count) == FAILURE) { - return; - } - - cur = xmlNodeGetContent(node); - if (cur == NULL) { - RETURN_FALSE; - } - - length = xmlUTF8Strlen(cur); - - if (offset < 0 || count < 0 || offset > length) { - xmlFree(cur); - php_dom_throw_error(INDEX_SIZE_ERR, dom_get_strict_error(intern->document) TSRMLS_CC); - RETURN_FALSE; - } - - if ((offset + count) > length) { - count = length - offset; - } - - substring = xmlUTF8Strsub(cur, offset, count); - xmlFree(cur); - - if (substring) { - RETVAL_STRING(substring, 1); - xmlFree(substring); - } else { - RETVAL_EMPTY_STRING(); - } -} -/* }}} end dom_characterdata_substring_data */ - - -/* {{{ proto dom_void dom_characterdata_append_data(string arg); -URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-32791A2F -Since: -*/ -PHP_FUNCTION(dom_characterdata_append_data) -{ - zval *id; - xmlNode *nodep; - dom_object *intern; - char *arg; - int arg_len; - - - DOM_GET_THIS_OBJ(nodep, id, xmlNodePtr, intern); - - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &arg, &arg_len) == FAILURE) { - return; - } - - xmlTextConcat(nodep, arg, arg_len); - - RETURN_TRUE; -} -/* }}} end dom_characterdata_append_data */ - - -/* {{{ proto dom_void dom_characterdata_insert_data(unsigned long offset, string arg); -URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-3EDB695F -Since: -*/ -PHP_FUNCTION(dom_characterdata_insert_data) -{ - xmlChar *cur, *first, *second; - xmlNodePtr node; - char *arg; - long offset; - int length, arg_len; - dom_object *intern; - - DOM_GET_THIS_OBJ(node, getThis(), xmlNodePtr, intern); - - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ls", &offset, &arg, &arg_len) == FAILURE) { - return; - } - - cur = xmlNodeGetContent(node); - if (cur == NULL) { - RETURN_FALSE; - } - - length = xmlUTF8Strlen(cur); - - if (offset < 0 || offset > length) { - xmlFree(cur); - php_dom_throw_error(INDEX_SIZE_ERR, dom_get_strict_error(intern->document) TSRMLS_CC); - RETURN_FALSE; - } - - first = xmlUTF8Strndup(cur, offset); - second = xmlUTF8Strsub(cur, offset, length - offset); - xmlFree(cur); - - xmlNodeSetContent(node, first); - xmlNodeAddContent(node, arg); - xmlNodeAddContent(node, second); - - xmlFree(first); - xmlFree(second); - - RETURN_TRUE; -} -/* }}} end dom_characterdata_insert_data */ - - -/* {{{ proto dom_void dom_characterdata_delete_data(unsigned long offset, unsigned long count); -URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-7C603781 -Since: -*/ -PHP_FUNCTION(dom_characterdata_delete_data) -{ - xmlChar *cur, *substring, *second; - xmlNodePtr node; - long offset, count; - int length; - dom_object *intern; - - DOM_GET_THIS_OBJ(node, getThis(), xmlNodePtr, intern); - - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ll", &offset, &count) == FAILURE) { - return; - } - - cur = xmlNodeGetContent(node); - if (cur == NULL) { - RETURN_FALSE; - } - - length = xmlUTF8Strlen(cur); - - if (offset < 0 || count < 0 || offset > length) { - xmlFree(cur); - php_dom_throw_error(INDEX_SIZE_ERR, dom_get_strict_error(intern->document) TSRMLS_CC); - RETURN_FALSE; - } - - if (offset > 0) { - substring = xmlUTF8Strsub(cur, 0, offset); - } else { - substring = NULL; - } - - if ((offset + count) > length) { - count = length - offset; - } - - second = xmlUTF8Strsub(cur, offset + count, length - offset); - substring = xmlStrcat(substring, second); - - xmlNodeSetContent(node, substring); - - xmlFree(cur); - xmlFree(second); - xmlFree(substring); - - RETURN_TRUE; -} -/* }}} end dom_characterdata_delete_data */ - - -/* {{{ proto dom_void dom_characterdata_replace_data(unsigned long offset, unsigned long count, string arg); -URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-E5CBA7FB -Since: -*/ -PHP_FUNCTION(dom_characterdata_replace_data) -{ - xmlChar *cur, *substring, *second = NULL; - xmlNodePtr node; - char *arg; - long offset, count; - int length, arg_len; - dom_object *intern; - - DOM_GET_THIS_OBJ(node, getThis(), xmlNodePtr, intern); - - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lls", &offset, &count, &arg, &arg_len) == FAILURE) { - return; - } - - cur = xmlNodeGetContent(node); - if (cur == NULL) { - RETURN_FALSE; - } - - length = xmlUTF8Strlen(cur); - - if (offset < 0 || count < 0 || offset > length) { - xmlFree(cur); - php_dom_throw_error(INDEX_SIZE_ERR, dom_get_strict_error(intern->document) TSRMLS_CC); - RETURN_FALSE; - } - - if (offset > 0) { - substring = xmlUTF8Strsub(cur, 0, offset); - } else { - substring = NULL; - } - - if ((offset + count) > length) { - count = length - offset; - } - - if (offset < length) { - second = xmlUTF8Strsub(cur, offset + count, length - offset); - } - - substring = xmlStrcat(substring, arg); - substring = xmlStrcat(substring, second); - - xmlNodeSetContent(node, substring); - - xmlFree(cur); - if (second) { - xmlFree(second); - } - xmlFree(substring); - - RETURN_TRUE; -} -/* }}} end dom_characterdata_replace_data */ -#endif diff --git a/ext/dom/comment.c b/ext/dom/comment.c deleted file mode 100644 index 5963ff9e73..0000000000 --- a/ext/dom/comment.c +++ /dev/null @@ -1,72 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP Version 5 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2004 The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 3.0 of the PHP license, | - | that is bundled with this package in the file LICENSE, and is | - | available through the world-wide-web at the following url: | - | http://www.php.net/license/3_0.txt. | - | If you did not receive a copy of the PHP license and are unable to | - | obtain it through the world-wide-web, please send a note to | - | license@php.net so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - | Authors: Christian Stocker <chregu@php.net> | - | Rob Richards <rrichards@php.net> | - +----------------------------------------------------------------------+ -*/ - -/* $Id$ */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "php.h" -#if HAVE_LIBXML && HAVE_DOM -#include "php_dom.h" - - -/* -* class domcomment extends domcharacterdata -* -* URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#ID-1728279322 -* Since: -*/ - -zend_function_entry php_dom_comment_class_functions[] = { - PHP_FALIAS(domcomment, dom_comment_comment, NULL) - {NULL, NULL, NULL} -}; - -/* {{{ proto dom_comment_comment([string value]); */ -PHP_FUNCTION(dom_comment_comment) -{ - - zval *id; - xmlNodePtr nodep = NULL, oldnode = NULL; - dom_object *intern; - char *value = NULL; - int value_len; - - if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O|s", &id, dom_comment_class_entry, &value, &value_len) == FAILURE) { - return; - } - - nodep = xmlNewComment((xmlChar *) value); - - if (!nodep) - RETURN_FALSE; - - intern = (dom_object *)zend_object_store_get_object(id TSRMLS_CC); - if (intern != NULL) { - oldnode = (xmlNodePtr)intern->ptr; - if (oldnode != NULL) { - php_libxml_node_free_resource(oldnode TSRMLS_CC); - } - php_libxml_increment_node_ptr((php_libxml_node_object *)intern, (xmlNodePtr)nodep, (void *)intern TSRMLS_CC); - } -} -/* }}} end dom_comment_comment */ -#endif diff --git a/ext/dom/config.m4 b/ext/dom/config.m4 deleted file mode 100644 index 82c97e6bd3..0000000000 --- a/ext/dom/config.m4 +++ /dev/null @@ -1,32 +0,0 @@ -dnl -dnl $Id$ -dnl - -PHP_ARG_ENABLE(dom, whether to enable DOM support, -[ --disable-dom Disable new DOM support.], yes) - -if test -z "$PHP_LIBXML_DIR"; then - PHP_ARG_WITH(libxml-dir, libxml2 install dir, - [ --with-libxml-dir[=DIR] DOM: libxml2 install prefix.], no, no) -fi - -if test "$PHP_DOM" != "no" && test "$PHP_LIBXML" != "no"; then - - PHP_SETUP_LIBXML(DOM_SHARED_LIBADD, [ - AC_DEFINE(HAVE_DOM,1,[ ]) - PHP_NEW_EXTENSION(dom, [php_dom.c attr.c document.c domerrorhandler.c \ - domstringlist.c domexception.c namelist.c \ - processinginstruction.c cdatasection.c \ - documentfragment.c domimplementation.c \ - element.c node.c string_extend.c characterdata.c \ - documenttype.c domimplementationlist.c entity.c \ - nodelist.c text.c comment.c domconfiguration.c \ - domimplementationsource.c entityreference.c \ - notation.c xpath.c dom_iterators.c \ - typeinfo.c domerror.c domlocator.c namednodemap.c userdatahandler.c], - $ext_shared) - PHP_SUBST(DOM_SHARED_LIBADD) - ], [ - AC_MSG_ERROR([xml2-config not found. Please check your libxml2 installation.]) - ]) -fi diff --git a/ext/dom/config.w32 b/ext/dom/config.w32 deleted file mode 100644 index 382587ff6e..0000000000 --- a/ext/dom/config.w32 +++ /dev/null @@ -1,22 +0,0 @@ -// $Id$ -// vim:ft=javascript - -ARG_WITH("dom", "DOM support", "yes"); - -if (PHP_DOM == "yes" && PHP_LIBXML == "yes") { - EXTENSION("dom", "php_dom.c attr.c document.c domerrorhandler.c \ - domstringlist.c domexception.c namelist.c processinginstruction.c \ - cdatasection.c documentfragment.c domimplementation.c element.c \ - node.c string_extend.c characterdata.c documenttype.c \ - domimplementationlist.c entity.c nodelist.c text.c comment.c \ - domconfiguration.c domimplementationsource.c entityreference.c \ - notation.c xpath.c dom_iterators.c typeinfo.c domerror.c \ - domlocator.c namednodemap.c userdatahandler.c"); - AC_DEFINE("HAVE_DOM", 1, "DOM support"); - if (!PHP_DOM_SHARED) { - ADD_FLAG("CFLAGS_DOM", "/D LIBXML_STATIC "); - } - ADD_EXTENSION_DEP('dom', 'libxml'); -} - - diff --git a/ext/dom/document.c b/ext/dom/document.c deleted file mode 100644 index a5f67e6c2a..0000000000 --- a/ext/dom/document.c +++ /dev/null @@ -1,1857 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP Version 5 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2004 The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 3.0 of the PHP license, | - | that is bundled with this package in the file LICENSE, and is | - | available through the world-wide-web at the following url: | - | http://www.php.net/license/3_0.txt. | - | If you did not receive a copy of the PHP license and are unable to | - | obtain it through the world-wide-web, please send a note to | - | license@php.net so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - | Authors: Christian Stocker <chregu@php.net> | - | Rob Richards <rrichards@php.net> | - +----------------------------------------------------------------------+ -*/ - -/* $Id$ */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "php.h" -#if HAVE_LIBXML && HAVE_DOM -#include "php_dom.h" -#include <libxml/SAX.h> -#ifdef LIBXML_SCHEMAS_ENABLED -#include <libxml/relaxng.h> -#include <libxml/xmlschemas.h> -#endif - -typedef struct _idsIterator idsIterator; -struct _idsIterator { - xmlChar *elementId; - xmlNode *element; -}; - -#define DOM_LOAD_STRING 0 -#define DOM_LOAD_FILE 1 - -/* -* class domdocument extends domnode -* -* URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-i-Document -* Since: -*/ - -zend_function_entry php_dom_document_class_functions[] = { - PHP_FALIAS(createElement, dom_document_create_element, NULL) - PHP_FALIAS(createDocumentFragment, dom_document_create_document_fragment, NULL) - PHP_FALIAS(createTextNode, dom_document_create_text_node, NULL) - PHP_FALIAS(createComment, dom_document_create_comment, NULL) - PHP_FALIAS(createCDATASection, dom_document_create_cdatasection, NULL) - PHP_FALIAS(createProcessingInstruction, dom_document_create_processing_instruction, NULL) - PHP_FALIAS(createAttribute, dom_document_create_attribute, NULL) - PHP_FALIAS(createEntityReference, dom_document_create_entity_reference, NULL) - PHP_FALIAS(getElementsByTagName, dom_document_get_elements_by_tag_name, NULL) - PHP_FALIAS(importNode, dom_document_import_node, NULL) - PHP_FALIAS(createElementNS, dom_document_create_element_ns, NULL) - PHP_FALIAS(createAttributeNS, dom_document_create_attribute_ns, NULL) - PHP_FALIAS(getElementsByTagNameNS, dom_document_get_elements_by_tag_name_ns, NULL) - PHP_FALIAS(getElementById, dom_document_get_element_by_id, NULL) - PHP_FALIAS(adoptNode, dom_document_adopt_node, NULL) - PHP_FALIAS(normalizeDocument, dom_document_normalize_document, NULL) - PHP_FALIAS(renameNode, dom_document_rename_node, NULL) - PHP_FALIAS(load, dom_document_load, NULL) - PHP_FALIAS(save, dom_document_save, NULL) - PHP_FALIAS(loadXML, dom_document_loadxml, NULL) - PHP_FALIAS(saveXML, dom_document_savexml, NULL) - PHP_FALIAS(domdocument, dom_document_document, NULL) - PHP_FALIAS(validate, dom_document_validate, NULL) - PHP_FALIAS(xinclude, dom_document_xinclude, NULL) -#if defined(LIBXML_HTML_ENABLED) - PHP_FALIAS(loadHTML, dom_document_load_html, NULL) - PHP_FALIAS(loadHTMLFile, dom_document_load_html_file, NULL) - PHP_FALIAS(saveHTML, dom_document_save_html, NULL) - PHP_FALIAS(saveHTMLFile, dom_document_save_html_file, NULL) -#endif /* defined(LIBXML_HTML_ENABLED) */ -#if defined(LIBXML_SCHEMAS_ENABLED) - PHP_FALIAS(schemaValidate, dom_document_schema_validate_file, NULL) - PHP_FALIAS(schemaValidateSource, dom_document_schema_validate_xml, NULL) - PHP_FALIAS(relaxNGValidate, dom_document_relaxNG_validate_file, NULL) - PHP_FALIAS(relaxNGValidateSource, dom_document_relaxNG_validate_xml, NULL) -#endif - {NULL, NULL, NULL} -}; - -/* {{{ proto doctype documenttype -readonly=yes -URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-B63ED1A31 -Since: -*/ -int dom_document_doctype_read(dom_object *obj, zval **retval TSRMLS_DC) -{ - xmlDoc *docp; - xmlDtdPtr dtdptr; - int ret; - - docp = (xmlDocPtr) dom_object_get_node(obj); - - dtdptr = xmlGetIntSubset(docp); - if (!dtdptr) { - return FAILURE; - } - - ALLOC_ZVAL(*retval); - if (NULL == (*retval = php_dom_create_object((xmlNodePtr) dtdptr, &ret, NULL, *retval, obj TSRMLS_CC))) { - php_error(E_WARNING, "Cannot create required DOM object"); - return FAILURE; - } - return SUCCESS; - -} - -/* }}} */ - - - -/* {{{ proto implementation domimplementation -readonly=yes -URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-1B793EBA -Since: -*/ -int dom_document_implementation_read(dom_object *obj, zval **retval TSRMLS_DC) -{ - ALLOC_ZVAL(*retval); - php_dom_create_implementation(retval TSRMLS_CC); - return SUCCESS; -} - -/* }}} */ - - - -/* {{{ proto domelement document_element documentElement -readonly=yes -URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-87CD092 -Since: -*/ -int dom_document_document_element_read(dom_object *obj, zval **retval TSRMLS_DC) -{ - xmlDoc *docp; - xmlNode *root; - int ret; - - docp = (xmlDocPtr) dom_object_get_node(obj); - - root = xmlDocGetRootElement(docp); - if (!root) { - return FAILURE; - } - - ALLOC_ZVAL(*retval); - if (NULL == (*retval = php_dom_create_object(root, &ret, NULL, *retval, obj TSRMLS_CC))) { - php_error(E_WARNING, "Cannot create required DOM object"); - return FAILURE; - } - return SUCCESS; -} - -/* }}} */ - - -/* {{{ proto actual_encoding string -readonly=no -URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-Document3-actualEncoding -Since: DOM Level 3 -*/ -/* READ ONLY FOR NOW USING ENCODING PROPERTY -int dom_document_actual_encoding_read(dom_object *obj, zval **retval TSRMLS_DC) -{ - ALLOC_ZVAL(*retval); - ZVAL_NULL(*retval); - return SUCCESS; -} - -int dom_document_actual_encoding_write(dom_object *obj, zval *newval TSRMLS_DC) -{ - return SUCCESS; -} -*/ - -/* }}} */ - -/* {{{ proto encoding string -URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-Document3-encoding -Since: DOM Level 3 -*/ -int dom_document_encoding_read(dom_object *obj, zval **retval TSRMLS_DC) -{ - xmlDoc *docp; - char *encoding; - - docp = (xmlDocPtr) dom_object_get_node(obj); - encoding = (char *) docp->encoding; - ALLOC_ZVAL(*retval); - - if (encoding != NULL) { - ZVAL_STRING(*retval, encoding, 1); - } else { - ZVAL_NULL(*retval); - } - - return SUCCESS; -} - -int dom_document_encoding_write(dom_object *obj, zval *newval TSRMLS_DC) -{ - xmlDoc *docp; - xmlCharEncodingHandlerPtr handler; - - docp = (xmlDocPtr) dom_object_get_node(obj); - - handler = xmlFindCharEncodingHandler(Z_STRVAL_P(newval)); - - if (handler != NULL) { - xmlCharEncCloseFunc(handler); - if (docp->encoding != NULL) { - xmlFree((xmlChar *)docp->encoding); - } - docp->encoding = xmlStrdup((const xmlChar *) Z_STRVAL_P(newval)); - return SUCCESS; - } else { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid Document Encoding"); - } - - return SUCCESS; -} - -/* }}} */ - - - -/* {{{ proto standalone boolean -readonly=no -URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-Document3-standalone -Since: DOM Level 3 -*/ -int dom_document_standalone_read(dom_object *obj, zval **retval TSRMLS_DC) -{ - xmlDoc *docp; - int standalone; - - docp = (xmlDocPtr) dom_object_get_node(obj); - ALLOC_ZVAL(*retval); - standalone = docp->standalone; - ZVAL_BOOL(*retval, standalone); - - return SUCCESS; -} - -int dom_document_standalone_write(dom_object *obj, zval *newval TSRMLS_DC) -{ - xmlDoc *docp; - int standalone; - - docp = (xmlDocPtr) dom_object_get_node(obj); - standalone = Z_LVAL_P(newval); - if (standalone > 0) { - docp->standalone = 1; - } - else if (standalone < 0) { - docp->standalone = -1; - } - else { - docp->standalone = 0; - } - - return SUCCESS; -} - -/* }}} */ - - - -/* {{{ proto version string -readonly=no -URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-Document3-version -Since: DOM Level 3 -*/ -int dom_document_version_read(dom_object *obj, zval **retval TSRMLS_DC) -{ - xmlDoc *docp; - char *version; - - docp = (xmlDocPtr) dom_object_get_node(obj); - version = (char *) docp->version; - ALLOC_ZVAL(*retval); - - if (version != NULL) { - ZVAL_STRING(*retval, version, 1); - } else { - ZVAL_NULL(*retval); - } - - return SUCCESS; -} - -int dom_document_version_write(dom_object *obj, zval *newval TSRMLS_DC) -{ - xmlDoc *docp; - - docp = (xmlDocPtr) dom_object_get_node(obj); - if (docp->version != NULL) { - xmlFree((xmlChar *) docp->version ); - } - - docp->version = xmlStrdup((const xmlChar *) Z_STRVAL_P(newval)); - - return SUCCESS; -} - -/* }}} */ - -/* {{{ proto strict_error_checking boolean -readonly=no -URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-Document3-strictErrorChecking -Since: DOM Level 3 -*/ -int dom_document_strict_error_checking_read(dom_object *obj, zval **retval TSRMLS_DC) -{ - dom_doc_props *doc_prop; - - ALLOC_ZVAL(*retval); - if (obj->document) { - doc_prop = dom_get_doc_props(obj->document); - ZVAL_BOOL(*retval, doc_prop->stricterror); - } else { - ZVAL_FALSE(*retval); - } - return SUCCESS; -} - -int dom_document_strict_error_checking_write(dom_object *obj, zval *newval TSRMLS_DC) -{ - dom_doc_props *doc_prop; - - if (obj->document && newval->type == IS_BOOL) { - doc_prop = dom_get_doc_props(obj->document); - doc_prop->stricterror = Z_LVAL_P(newval); - } - - return SUCCESS; -} - -/* }}} */ - -/* {{{ proto formatOutput boolean -readonly=no -*/ -int dom_document_format_output_read(dom_object *obj, zval **retval TSRMLS_DC) -{ - dom_doc_props *doc_prop; - - ALLOC_ZVAL(*retval); - if (obj->document) { - doc_prop = dom_get_doc_props(obj->document); - ZVAL_BOOL(*retval, doc_prop->formatoutput); - } else { - ZVAL_FALSE(*retval); - } - return SUCCESS; -} - -int dom_document_format_output_write(dom_object *obj, zval *newval TSRMLS_DC) -{ - dom_doc_props *doc_prop; - - if (obj->document && newval->type == IS_BOOL) { - doc_prop = dom_get_doc_props(obj->document); - doc_prop->formatoutput = Z_LVAL_P(newval); - } - - return SUCCESS; -} -/* }}} */ - -/* {{{ proto validateonParse boolean -readonly=no -*/ -int dom_document_validate_on_parse_read(dom_object *obj, zval **retval TSRMLS_DC) -{ - dom_doc_props *doc_prop; - - ALLOC_ZVAL(*retval); - if (obj->document) { - doc_prop = dom_get_doc_props(obj->document); - ZVAL_BOOL(*retval, doc_prop->validateonparse); - } else { - ZVAL_FALSE(*retval); - } - return SUCCESS; -} - -int dom_document_validate_on_parse_write(dom_object *obj, zval *newval TSRMLS_DC) -{ - dom_doc_props *doc_prop; - - if (obj->document && newval->type == IS_BOOL) { - doc_prop = dom_get_doc_props(obj->document); - doc_prop->validateonparse = Z_LVAL_P(newval); - } - - return SUCCESS; -} -/* }}} */ - - -/* {{{ proto resolveExternals boolean -readonly=no -*/ -int dom_document_resolve_externals_read(dom_object *obj, zval **retval TSRMLS_DC) -{ - dom_doc_props *doc_prop; - - ALLOC_ZVAL(*retval); - if (obj->document) { - doc_prop = dom_get_doc_props(obj->document); - ZVAL_BOOL(*retval, doc_prop->resolveexternals); - } else { - ZVAL_FALSE(*retval); - } - return SUCCESS; -} - -int dom_document_resolve_externals_write(dom_object *obj, zval *newval TSRMLS_DC) -{ - dom_doc_props *doc_prop; - - if (obj->document && newval->type == IS_BOOL) { - doc_prop = dom_get_doc_props(obj->document); - doc_prop->resolveexternals = Z_LVAL_P(newval); - } - - return SUCCESS; -} -/* }}} */ - - -/* {{{ proto preserveWhiteSpace boolean -readonly=no -*/ -int dom_document_preserve_whitespace_read(dom_object *obj, zval **retval TSRMLS_DC) -{ - dom_doc_props *doc_prop; - - ALLOC_ZVAL(*retval); - if (obj->document) { - doc_prop = dom_get_doc_props(obj->document); - ZVAL_BOOL(*retval, doc_prop->preservewhitespace); - } else { - ZVAL_FALSE(*retval); - } - return SUCCESS; -} - -int dom_document_preserve_whitespace_write(dom_object *obj, zval *newval TSRMLS_DC) -{ - dom_doc_props *doc_prop; - - if (obj->document && newval->type == IS_BOOL) { - doc_prop = dom_get_doc_props(obj->document); - doc_prop->preservewhitespace = Z_LVAL_P(newval); - } - - return SUCCESS; -} -/* }}} */ - - -/* {{{ proto substituteEntities boolean -readonly=no -*/ -int dom_document_substitue_entities_read(dom_object *obj, zval **retval TSRMLS_DC) -{ - dom_doc_props *doc_prop; - - ALLOC_ZVAL(*retval); - if (obj->document) { - doc_prop = dom_get_doc_props(obj->document); - ZVAL_BOOL(*retval, doc_prop->substituteentities); - } else { - ZVAL_FALSE(*retval); - } - return SUCCESS; -} - -int dom_document_substitue_entities_write(dom_object *obj, zval *newval TSRMLS_DC) -{ - dom_doc_props *doc_prop; - - if (obj->document && newval->type == IS_BOOL) { - doc_prop = dom_get_doc_props(obj->document); - doc_prop->substituteentities = Z_LVAL_P(newval); - } - - return SUCCESS; -} -/* }}} */ - - -/* {{{ proto document_uri string -readonly=no -URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-Document3-documentURI -Since: DOM Level 3 -*/ -int dom_document_document_uri_read(dom_object *obj, zval **retval TSRMLS_DC) -{ - xmlDoc *docp; - char *url; - - docp = (xmlDocPtr) dom_object_get_node(obj); - - ALLOC_ZVAL(*retval); - url = (char *) docp->URL; - if (url != NULL) { - ZVAL_STRING(*retval, url, 1); - } else { - ZVAL_NULL(*retval); - } - - return SUCCESS; -} - -int dom_document_document_uri_write(dom_object *obj, zval *newval TSRMLS_DC) -{ - xmlDoc *docp; - - docp = (xmlDocPtr) dom_object_get_node(obj); - if (docp->URL != NULL) { - xmlFree((xmlChar *) docp->URL); - } - - docp->URL = xmlStrdup((const xmlChar *) Z_STRVAL_P(newval)); - - return SUCCESS; -} - -/* }}} */ - - - -/* {{{ proto config domconfiguration -readonly=yes -URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-Document3-config -Since: DOM Level 3 -*/ -int dom_document_config_read(dom_object *obj, zval **retval TSRMLS_DC) -{ - ALLOC_ZVAL(*retval); - ZVAL_NULL(*retval); - return SUCCESS; -} - -/* }}} */ - - - -/* {{{ proto domelement dom_document_create_element(string tagName); -URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-2141741547 -Since: -*/ -PHP_FUNCTION(dom_document_create_element) -{ - zval *id, *rv = NULL; - xmlNode *node; - xmlDocPtr docp; - dom_object *intern; - int ret, name_len, value_len; - char *name, *value = NULL; - - DOM_GET_THIS_OBJ(docp, id, xmlDocPtr, intern); - - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|s", &name, &name_len, &value, &value_len) == FAILURE) { - return; - } - - node = xmlNewDocNode(docp, NULL, name, value); - if (!node) { - RETURN_FALSE; - } - - DOM_RET_OBJ(rv, node, &ret, intern); -} -/* }}} end dom_document_create_element */ - - -/* {{{ proto domdocumentfragment dom_document_create_document_fragment(); -URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-35CB04B5 -Since: -*/ -PHP_FUNCTION(dom_document_create_document_fragment) -{ - zval *id, *rv = NULL; - xmlNode *node; - xmlDocPtr docp; - dom_object *intern; - int ret; - - DOM_GET_THIS_OBJ(docp, id, xmlDocPtr, intern); - - node = xmlNewDocFragment(docp); - if (!node) { - RETURN_FALSE; - } - - DOM_RET_OBJ(rv, node, &ret, intern); -} -/* }}} end dom_document_create_document_fragment */ - - -/* {{{ proto domtext dom_document_create_text_node(string data); -URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-1975348127 -Since: -*/ -PHP_FUNCTION(dom_document_create_text_node) -{ - zval *id, *rv = NULL; - xmlNode *node; - xmlDocPtr docp; - int ret, value_len; - dom_object *intern; - char *value; - - DOM_GET_THIS_OBJ(docp, id, xmlDocPtr, intern); - - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &value, &value_len) == FAILURE) { - return; - } - - node = xmlNewDocText(docp, (xmlChar *) value); - if (!node) { - RETURN_FALSE; - } - - DOM_RET_OBJ(rv, node, &ret, intern); -} -/* }}} end dom_document_create_text_node */ - - -/* {{{ proto domcomment dom_document_create_comment(string data); -URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-1334481328 -Since: -*/ -PHP_FUNCTION(dom_document_create_comment) -{ - zval *id, *rv = NULL; - xmlNode *node; - xmlDocPtr docp; - int ret, value_len; - dom_object *intern; - char *value; - - DOM_GET_THIS_OBJ(docp, id, xmlDocPtr, intern); - - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &value, &value_len) == FAILURE) { - return; - } - - node = xmlNewDocComment(docp, (xmlChar *) value); - if (!node) { - RETURN_FALSE; - } - - DOM_RET_OBJ(rv, node, &ret, intern); -} -/* }}} end dom_document_create_comment */ - - -/* {{{ proto domcdatasection dom_document_create_cdatasection(string data); -URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-D26C0AF8 -Since: -*/ -PHP_FUNCTION(dom_document_create_cdatasection) -{ - zval *id, *rv = NULL; - xmlNode *node; - xmlDocPtr docp; - int ret, value_len; - dom_object *intern; - char *value; - - DOM_GET_THIS_OBJ(docp, id, xmlDocPtr, intern); - - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &value, &value_len) == FAILURE) { - return; - } - - node = xmlNewCDataBlock(docp, (xmlChar *) value, value_len); - if (!node) { - RETURN_FALSE; - } - - DOM_RET_OBJ(rv, node, &ret, intern); -} -/* }}} end dom_document_create_cdatasection */ - - -/* {{{ proto domprocessinginstruction dom_document_create_processing_instruction(string target, string data); -URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-135944439 -Since: -*/ -PHP_FUNCTION(dom_document_create_processing_instruction) -{ - zval *id, *rv = NULL; - xmlNode *node; - xmlDocPtr docp; - int ret, value_len, name_len; - dom_object *intern; - char *name, *value = NULL; - - DOM_GET_THIS_OBJ(docp, id, xmlDocPtr, intern); - - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|s", &name, &name_len, &value, &value_len) == FAILURE) { - return; - } - - node = xmlNewPI((xmlChar *) name, (xmlChar *) value); - if (!node) { - RETURN_FALSE; - } - - node->doc = docp; - - DOM_RET_OBJ(rv, node, &ret, intern); -} -/* }}} end dom_document_create_processing_instruction */ - - -/* {{{ proto domattr dom_document_create_attribute(string name); -URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-1084891198 -Since: -*/ -PHP_FUNCTION(dom_document_create_attribute) -{ - zval *id, *rv = NULL; - xmlAttrPtr node; - xmlDocPtr docp; - int ret, name_len; - dom_object *intern; - char *name; - - DOM_GET_THIS_OBJ(docp, id, xmlDocPtr, intern); - - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &name, &name_len) == FAILURE) { - return; - } - - if (name_len == 0) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Attribute name is required"); - RETURN_FALSE; - } - - node = xmlNewDocProp(docp, (xmlChar *) name, NULL); - if (!node) { - RETURN_FALSE; - } - - DOM_RET_OBJ(rv, (xmlNodePtr) node, &ret, intern); - -} -/* }}} end dom_document_create_attribute */ - - -/* {{{ proto domentityreference dom_document_create_entity_reference(string name); -URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-392B75AE -Since: -*/ -PHP_FUNCTION(dom_document_create_entity_reference) -{ - zval *id, *rv = NULL; - xmlNode *node; - xmlDocPtr docp = NULL; - dom_object *intern; - int ret, name_len; - char *name; - - DOM_GET_THIS_OBJ(docp, id, xmlDocPtr, intern); - - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &name, &name_len) == FAILURE) { - return; - } - - node = xmlNewReference(docp, name); - if (!node) { - RETURN_FALSE; - } - - DOM_RET_OBJ(rv, (xmlNodePtr) node, &ret, intern); -} -/* }}} end dom_document_create_entity_reference */ - - -/* {{{ proto domnodelist dom_document_get_elements_by_tag_name(string tagname); -URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-A6C9094 -Since: -*/ -PHP_FUNCTION(dom_document_get_elements_by_tag_name) -{ - zval *id; - xmlDocPtr docp; - int name_len; - dom_object *intern, *namednode; - char *name; - xmlChar *local; - - DOM_GET_THIS_OBJ(docp, id, xmlDocPtr, intern); - - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &name, &name_len) == FAILURE) { - return; - } - - php_dom_create_interator(return_value, DOM_NODELIST TSRMLS_CC); - namednode = (dom_object *)zend_objects_get_address(return_value TSRMLS_CC); - local = xmlCharStrndup(name, name_len); - dom_namednode_iter(intern, 0, namednode, NULL, local, NULL); -} -/* }}} end dom_document_get_elements_by_tag_name */ - - -/* {{{ proto domnode dom_document_import_node(node importedNode, boolean deep); -URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#Core-Document-importNode -Since: DOM Level 2 -*/ -PHP_FUNCTION(dom_document_import_node) -{ - zval *rv = NULL; - zval *id, *node; - xmlDocPtr docp; - xmlNodePtr nodep, retnodep; - dom_object *intern, *nodeobj; - int ret; - long recursive = 0; - - DOM_GET_THIS_OBJ(docp, id, xmlDocPtr, intern); - - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o|l", &node, &recursive) == FAILURE) { - return; - } - - DOM_GET_OBJ(nodep, node, xmlNodePtr, nodeobj); - - if (nodep->type == XML_HTML_DOCUMENT_NODE || nodep->type == XML_DOCUMENT_NODE - || nodep->type == XML_DOCUMENT_TYPE_NODE) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Cannot import: Node Type Not Supported"); - RETURN_FALSE; - } - - if (nodep->doc == docp) { - retnodep = nodep; - } else { - retnodep = xmlDocCopyNode(nodep, docp, recursive); - if (!retnodep) { - RETURN_FALSE; - } - } - - DOM_RET_OBJ(rv, (xmlNodePtr) retnodep, &ret, intern); -} -/* }}} end dom_document_import_node */ - - -/* {{{ proto domelement dom_document_create_element_ns(string namespaceURI, string qualifiedName); -URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-DocCrElNS -Since: DOM Level 2 -*/ -PHP_FUNCTION(dom_document_create_element_ns) -{ - zval *id, *rv = NULL; - xmlDocPtr docp; - xmlNodePtr nodep = NULL; - xmlNsPtr nsptr = NULL; - int ret, uri_len = 0, name_len = 0; - char *uri, *name; - char *localname = NULL, *prefix = NULL; - int errorcode; - dom_object *intern; - - DOM_GET_THIS_OBJ(docp, id, xmlDocPtr, intern); - - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s!s", &uri, &uri_len, &name, &name_len) == FAILURE) { - return; - } - - errorcode = dom_check_qname(name, &localname, &prefix, uri_len, name_len); - - if (errorcode == 0) { - nodep = xmlNewDocNode (docp, NULL, localname, NULL); - if (nodep != NULL && uri != NULL) { - nsptr = xmlSearchNsByHref (nodep->doc, nodep, uri); - if (nsptr == 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) { - xmlFreeNode(nodep); - } - php_dom_throw_error(errorcode, dom_get_strict_error(intern->document) TSRMLS_CC); - RETURN_FALSE; - } - - if (nodep == NULL) { - RETURN_FALSE; - } - - - nodep->ns = nsptr; - - DOM_RET_OBJ(rv, nodep, &ret, intern); -} -/* }}} end dom_document_create_element_ns */ - - -/* {{{ proto domattr dom_document_create_attribute_ns(string namespaceURI, string qualifiedName); -URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-DocCrAttrNS -Since: DOM Level 2 -*/ -PHP_FUNCTION(dom_document_create_attribute_ns) -{ - zval *id, *rv = NULL; - xmlDocPtr docp; - xmlNodePtr nodep = NULL, root; - xmlNsPtr nsptr; - int ret, uri_len = 0, name_len = 0; - char *uri, *name; - char *localname = NULL, *prefix = NULL; - dom_object *intern; - int errorcode; - - DOM_GET_THIS_OBJ(docp, id, xmlDocPtr, intern); - - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s!s", &uri, &uri_len, &name, &name_len) == FAILURE) { - return; - } - - root = xmlDocGetRootElement(docp); - if (root != NULL) { - errorcode = dom_check_qname(name, &localname, &prefix, uri_len, name_len); - if (errorcode == 0) { - nodep = (xmlNodePtr) xmlNewDocProp(docp, localname, NULL); - if (nodep != NULL && uri_len > 0) { - nsptr = xmlSearchNsByHref (nodep->doc, root, uri); - if (nsptr == NULL) { - nsptr = dom_get_ns(root, uri, &errorcode, prefix); - } - xmlSetNs(nodep, nsptr); - } - } - } else { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Document Missing Root Element"); - RETURN_FALSE; - } - - xmlFree(localname); - if (prefix != NULL) { - xmlFree(prefix); - } - - if (errorcode != 0) { - if (nodep != NULL) { - xmlFreeProp((xmlAttrPtr) nodep); - } - php_dom_throw_error(errorcode, dom_get_strict_error(intern->document) TSRMLS_CC); - RETURN_FALSE; - } - - if (nodep == NULL) { - RETURN_FALSE; - } - - DOM_RET_OBJ(rv, nodep, &ret, intern); -} -/* }}} end dom_document_create_attribute_ns */ - - -/* {{{ proto domnodelist dom_document_get_elements_by_tag_name_ns(string namespaceURI, string localName); -URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-getElBTNNS -Since: DOM Level 2 -*/ -PHP_FUNCTION(dom_document_get_elements_by_tag_name_ns) -{ - zval *id; - xmlDocPtr docp; - int uri_len, name_len; - dom_object *intern, *namednode; - char *uri, *name; - xmlChar *local, *nsuri; - - DOM_GET_THIS_OBJ(docp, id, xmlDocPtr, intern); - - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss", &uri, &uri_len, &name, &name_len) == FAILURE) { - return; - } - - php_dom_create_interator(return_value, DOM_NODELIST TSRMLS_CC); - namednode = (dom_object *)zend_objects_get_address(return_value TSRMLS_CC); - local = xmlCharStrndup(name, name_len); - nsuri = xmlCharStrndup(uri, uri_len); - dom_namednode_iter(intern, 0, namednode, NULL, local, nsuri); -} -/* }}} end dom_document_get_elements_by_tag_name_ns */ - - -/* {{{ proto domelement dom_document_get_element_by_id(string elementId); -URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-getElBId -Since: DOM Level 2 -*/ -PHP_FUNCTION(dom_document_get_element_by_id) -{ - zval *id, *rv = NULL; - xmlDocPtr docp; - xmlAttrPtr attrp; - int ret, idname_len; - dom_object *intern; - char *idname; - - DOM_GET_THIS_OBJ(docp, id, xmlDocPtr, intern); - - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &idname, &idname_len) == FAILURE) { - return; - } - attrp = xmlGetID(docp, (xmlChar *) idname); - - if (attrp && attrp->parent) { - DOM_RET_OBJ(rv, (xmlNodePtr) attrp->parent, &ret, intern); - } else { - RETVAL_NULL(); - } - -} -/* }}} end dom_document_get_element_by_id */ - - -/* {{{ proto domnode dom_document_adopt_node(node source); -URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-Document3-adoptNode -Since: DOM Level 3 -*/ -PHP_FUNCTION(dom_document_adopt_node) -{ - DOM_NOT_IMPLEMENTED(); -} -/* }}} end dom_document_adopt_node */ - - -/* {{{ proto dom_void dom_document_normalize_document(); -URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-Document3-normalizeDocument -Since: DOM Level 3 -*/ -PHP_FUNCTION(dom_document_normalize_document) -{ - zval *id; - xmlDocPtr docp; - dom_object *intern; - - DOM_GET_THIS_OBJ(docp, id, xmlDocPtr, intern); - - DOM_NO_ARGS(); - - dom_normalize((xmlNodePtr) docp TSRMLS_CC); -} -/* }}} end dom_document_normalize_document */ - - -/* {{{ proto domnode dom_document_rename_node(node n, string namespaceURI, string qualifiedName); -URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-Document3-renameNode -Since: DOM Level 3 -*/ -PHP_FUNCTION(dom_document_rename_node) -{ - DOM_NOT_IMPLEMENTED(); -} -/* }}} end dom_document_rename_node */ - -/* {{{ proto domnode dom_document_document([string version], [string encoding]); */ -PHP_FUNCTION(dom_document_document) -{ - - zval *id; - xmlDoc *docp = NULL, *olddoc; - dom_object *intern; - char *encoding, *version = NULL; - int encoding_len = 0, version_len = 0, refcount; - - 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) { - return; - } - - docp = xmlNewDoc(version); - if (!docp) - RETURN_FALSE; - - if (encoding_len > 0) { - docp->encoding = (const xmlChar*)xmlStrdup(encoding); - } - - intern = (dom_object *)zend_object_store_get_object(id TSRMLS_CC); - if (intern != NULL) { - olddoc = (xmlDocPtr) dom_object_get_node(intern); - if (olddoc != NULL) { - php_libxml_decrement_node_ptr((php_libxml_node_object *) intern TSRMLS_CC); - refcount = php_libxml_decrement_doc_ref((php_libxml_node_object *)intern TSRMLS_CC); - if (refcount != 0) { - olddoc->_private = NULL; - } - } - intern->document = NULL; - php_libxml_increment_doc_ref((php_libxml_node_object *)intern, docp TSRMLS_CC); - php_libxml_increment_node_ptr((php_libxml_node_object *)intern, (xmlNodePtr)docp, (void *)intern TSRMLS_CC); - } -} -/* }}} end dom_document_document */ - -char *_dom_get_valid_file_path(char *source, char *resolved_path, int resolved_path_len TSRMLS_DC) { - xmlURI *uri; - xmlChar *escsource; - char *file_dest; - int isFileUri = 0; - - uri = xmlCreateURI(); - escsource = xmlURIEscapeStr(source, ":"); - xmlParseURIReference(uri, escsource); - xmlFree(escsource); - - if (uri->scheme != NULL) { - /* absolute file uris - libxml only supports localhost or empty host */ - if (strncasecmp(source, "file:///",8) == 0) { - isFileUri = 1; -#ifdef PHP_WIN32 - source += 8; -#else - source += 7; -#endif - } else if (strncasecmp(source, "file://localhost/",17) == 0) { - isFileUri = 1; -#ifdef PHP_WIN32 - source += 17; -#else - source += 16; -#endif - } - } - - file_dest = source; - - if ((uri->scheme == NULL || isFileUri)) { - /* XXX possible buffer overflow if VCWD_REALPATH does not know size of resolved_path */ - if (! VCWD_REALPATH(source, resolved_path)) { - expand_filepath(source, resolved_path TSRMLS_CC); - } - file_dest = resolved_path; - } - - xmlFreeURI(uri); - - return file_dest; -} - - -/* {{{ */ -static xmlDocPtr dom_document_parser(zval *id, int mode, char *source TSRMLS_DC) { - xmlDocPtr ret; - xmlParserCtxtPtr ctxt = NULL; - dom_doc_props *doc_props; - dom_object *intern; - php_libxml_ref_obj *document = NULL; - int validate, resolve_externals, keep_blanks, substitute_ent; - int resolved_path_len; - char *directory=NULL, resolved_path[MAXPATHLEN]; - - if (id != NULL) { - intern = (dom_object *)zend_object_store_get_object(id TSRMLS_CC); - document = intern->document; - } - - doc_props = dom_get_doc_props(document); - validate = doc_props->validateonparse; - resolve_externals = doc_props->resolveexternals; - keep_blanks = doc_props->preservewhitespace; - substitute_ent = doc_props->substituteentities; - - if (document == NULL) { - efree(doc_props); - } - - xmlInitParser(); - - keep_blanks = xmlKeepBlanksDefault(keep_blanks); - - if (mode == DOM_LOAD_FILE) { - char *file_dest = _dom_get_valid_file_path(source, resolved_path, MAXPATHLEN TSRMLS_CC); - if (file_dest) { - ctxt = xmlCreateFileParserCtxt(file_dest); - } - - } else { - ctxt = xmlCreateDocParserCtxt(source); - } - - xmlKeepBlanksDefault(keep_blanks); - /* xmlIndentTreeOutput default is changed in xmlKeepBlanksDefault - reset back to 1 which is default value */ - - xmlIndentTreeOutput = 1; - - if (ctxt == NULL) { - return(NULL); - } - - /* If loading from memory, we need to set the base directory for the document */ - if (mode != DOM_LOAD_FILE) { -#if HAVE_GETCWD - directory = VCWD_GETCWD(resolved_path, MAXPATHLEN); -#elif HAVE_GETWD - directory = VCWD_GETWD(resolved_path); -#endif - if (directory) { - if(ctxt->directory != NULL) { - xmlFree((char *) ctxt->directory); - } - resolved_path_len = strlen(resolved_path); - if (resolved_path[resolved_path_len - 1] != DEFAULT_SLASH) { - resolved_path[resolved_path_len] = DEFAULT_SLASH; - resolved_path[++resolved_path_len] = '\0'; - } - ctxt->directory = (char *) xmlCanonicPath((const xmlChar *) resolved_path); - } - } - - ctxt->recovery = 0; - ctxt->validate = validate; - ctxt->loadsubset = (resolve_externals * XML_COMPLETE_ATTRS); - ctxt->replaceEntities = substitute_ent; - - ctxt->vctxt.error = php_libxml_ctx_error; - ctxt->vctxt.warning = php_libxml_ctx_warning; - - if (ctxt->sax != NULL) { - ctxt->sax->error = php_libxml_ctx_error; - ctxt->sax->warning = php_libxml_ctx_warning; - } - - xmlParseDocument(ctxt); - - if (ctxt->wellFormed) { - ret = ctxt->myDoc; - /* If loading from memory, set the base reference uri for the document */ - if (ret->URL == NULL && ctxt->directory != NULL) { - ret->URL = xmlStrdup(ctxt->directory); - } - } else { - ret = NULL; - xmlFreeDoc(ctxt->myDoc); - ctxt->myDoc = NULL; - } - - xmlFreeParserCtxt(ctxt); - - return(ret); -} -/* }}} */ - -/* {{{ static void dom_parse_document(INTERNAL_FUNCTION_PARAMETERS, int mode) */ -static void dom_parse_document(INTERNAL_FUNCTION_PARAMETERS, int mode) { - zval *id, *rv = NULL; - xmlDoc *docp = NULL, *newdoc; - dom_doc_props *doc_prop; - dom_object *intern; - char *source; - int source_len, refcount, ret; - - id = getThis(); - - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &source, &source_len) == FAILURE) { - return; - } - - if (!source_len) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Empty string supplied as input"); - RETURN_FALSE; - } - - newdoc = dom_document_parser(id, mode, source TSRMLS_CC); - - if (!newdoc) - RETURN_FALSE; - - if (id != NULL) { - intern = (dom_object *)zend_object_store_get_object(id TSRMLS_CC); - if (intern != NULL) { - docp = (xmlDocPtr) dom_object_get_node(intern); - doc_prop = NULL; - if (docp != NULL) { - php_libxml_decrement_node_ptr((php_libxml_node_object *) intern TSRMLS_CC); - doc_prop = intern->document->doc_props; - intern->document->doc_props = NULL; - refcount = php_libxml_decrement_doc_ref((php_libxml_node_object *)intern TSRMLS_CC); - if (refcount != 0) { - docp->_private = NULL; - } - } - intern->document = NULL; - php_libxml_increment_doc_ref((php_libxml_node_object *)intern, newdoc TSRMLS_CC); - intern->document->doc_props = doc_prop; - } - - php_libxml_increment_node_ptr((php_libxml_node_object *)intern, (xmlNodePtr)newdoc, (void *)intern TSRMLS_CC); - - RETURN_TRUE; - } else { - DOM_RET_OBJ(rv, (xmlNodePtr) newdoc, &ret, NULL); - } -} -/* }}} end dom_parser_document */ - -/* {{{ proto boolean domnode dom_document_load(string source); -URL: http://www.w3.org/TR/DOM-Level-3-LS/load-save.html#LS-DocumentLS-load -Since: DOM Level 3 -*/ -PHP_FUNCTION(dom_document_load) -{ - dom_parse_document(INTERNAL_FUNCTION_PARAM_PASSTHRU, DOM_LOAD_FILE); -} -/* }}} end dom_document_load */ - -/* {{{ proto boolean domnode dom_document_loadxml(string source); -URL: http://www.w3.org/TR/DOM-Level-3-LS/load-save.html#LS-DocumentLS-loadXML -Since: DOM Level 3 -*/ -PHP_FUNCTION(dom_document_loadxml) -{ - dom_parse_document(INTERNAL_FUNCTION_PARAM_PASSTHRU, DOM_LOAD_STRING); -} -/* }}} end dom_document_loadxml */ - -/* {{{ proto long domnode dom_document_save(string file); -Convenience method to save to file -*/ -PHP_FUNCTION(dom_document_save) -{ - zval *id; - xmlDoc *docp; - int file_len, bytes, format; - dom_object *intern; - dom_doc_props *doc_props; - char *file; - - DOM_GET_THIS_OBJ(docp, id, xmlDocPtr, intern); - - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &file, &file_len) == FAILURE) { - return; - } - - /* encoding handled by property on doc */ - - doc_props = dom_get_doc_props(intern->document); - format = doc_props->formatoutput; - bytes = xmlSaveFormatFileEnc(file, docp, NULL, format); - - if (bytes == -1) { - RETURN_FALSE; - } - RETURN_LONG(bytes); -} -/* }}} end dom_document_save */ - -/* {{{ proto string domnode dom_document_savexml([node n]); -URL: http://www.w3.org/TR/DOM-Level-3-LS/load-save.html#LS-DocumentLS-saveXML -Since: DOM Level 3 -*/ -PHP_FUNCTION(dom_document_savexml) -{ - zval *id, *nodep = NULL; - xmlDoc *docp; - xmlNode *node; - xmlBufferPtr buf; - xmlChar *mem; - dom_object *intern, *nodeobj; - dom_doc_props *doc_props; - int size, format; - - DOM_GET_THIS_OBJ(docp, id, xmlDocPtr, intern); - - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|o", &nodep) == FAILURE) { - return; - } - - doc_props = dom_get_doc_props(intern->document); - format = doc_props->formatoutput; - - if (nodep != NULL) { - /* Dump contents of Node */ - DOM_GET_OBJ(node, nodep, xmlNodePtr, nodeobj); - if (node->doc != docp) { - php_dom_throw_error(WRONG_DOCUMENT_ERR, dom_get_strict_error(intern->document) TSRMLS_CC); - RETURN_FALSE; - } - buf = xmlBufferCreate(); - if (!buf) { - php_error(E_WARNING, "Could not fetch buffer"); - RETURN_FALSE; - } - - xmlNodeDump(buf, docp, node, 0, format); - mem = (xmlChar*) xmlBufferContent(buf); - if (!mem) { - xmlBufferFree(buf); - RETURN_FALSE; - } - RETVAL_STRING(mem, 1); - xmlBufferFree(buf); - } else { - /* Encoding is handled from the encoding property set on the document */ - xmlDocDumpFormatMemory(docp, &mem, &size, format); - if (!size) { - RETURN_FALSE; - } - RETVAL_STRINGL(mem, size, 1); - xmlFree(mem); - } -} -/* }}} end dom_document_savexml */ - -static xmlNodePtr php_dom_free_xinclude_node(xmlNodePtr cur TSRMLS_DC) { - xmlNodePtr xincnode; - - xincnode = cur; - cur = cur->next; - xmlUnlinkNode(xincnode); - php_libxml_node_free_resource(xincnode TSRMLS_CC); - - return cur; -} - -static void php_dom_remove_xinclude_nodes(xmlNodePtr cur TSRMLS_DC) { - while(cur) { - if (cur->type == XML_XINCLUDE_START) { - cur = php_dom_free_xinclude_node(cur TSRMLS_CC); - - /* XML_XINCLUDE_END node will be a sibling of XML_XINCLUDE_START */ - while(cur && cur->type != XML_XINCLUDE_END) { - cur = cur->next; - } - - if (cur && cur->type == XML_XINCLUDE_END) { - cur = php_dom_free_xinclude_node(cur TSRMLS_CC); - } - } else { - if (cur->type == XML_ELEMENT_NODE) { - php_dom_remove_xinclude_nodes(cur->children TSRMLS_CC); - } - cur = cur->next; - } - } -} - -/* {{{ proto int dom_document_xinclude() - Substitutues xincludes in a DomDocument */ -PHP_FUNCTION(dom_document_xinclude) -{ - zval *id; - xmlDoc *docp; - xmlNodePtr root; - int err; - dom_object *intern; - - DOM_GET_THIS_OBJ(docp, id, xmlDocPtr, intern); - - err = xmlXIncludeProcess (docp); - - /* XML_XINCLUDE_START and XML_XINCLUDE_END nodes need to be removed as these - are added via xmlXIncludeProcess to mark beginning and ending of xincluded document - but are not wanted in resulting document - must be done even if err as it could fail after - having processed some xincludes */ - root = (xmlNodePtr) docp->children; - while(root && root->type != XML_ELEMENT_NODE && root->type != XML_XINCLUDE_START) { - root = root->next; - } - if (root) { - php_dom_remove_xinclude_nodes(root TSRMLS_CC); - } - - if (err) { - RETVAL_LONG(err); - } else { - RETVAL_FALSE; - } - -} - - -/* {{{ proto string domnode dom_document_validate(); -Since: DOM extended -*/ -PHP_FUNCTION(dom_document_validate) -{ - zval *id; - xmlDoc *docp; - dom_object *intern; - xmlValidCtxt *cvp; - - DOM_GET_THIS_OBJ(docp, id, xmlDocPtr, intern); - - if (docp->intSubset == NULL) { - php_error_docref(NULL TSRMLS_CC, E_NOTICE, "No DTD given in XML-Document"); - } - - cvp = xmlNewValidCtxt(); - - cvp->userData = NULL; - cvp->error = (xmlValidityErrorFunc) php_libxml_error_handler; - cvp->warning = (xmlValidityErrorFunc) php_libxml_error_handler; - - if (xmlValidateDocument(cvp, docp)) { - RETVAL_TRUE; - } else { - RETVAL_FALSE; - } - - xmlFreeValidCtxt(cvp); - -} - - -#if defined(LIBXML_SCHEMAS_ENABLED) -static void -_dom_document_schema_validate(INTERNAL_FUNCTION_PARAMETERS, int type) -{ - zval *id; - xmlDoc *docp; - dom_object *intern; - char *source = NULL, *valid_file = NULL; - int source_len = 0; - xmlSchemaParserCtxtPtr parser; - xmlSchemaPtr sptr; - xmlSchemaValidCtxtPtr vptr; - int is_valid; - char resolved_path[MAXPATHLEN + 1]; - - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &source, &source_len) == FAILURE) { - return; - } - - DOM_GET_THIS_OBJ(docp, id, xmlDocPtr, intern); - - switch (type) { - case DOM_LOAD_FILE: - valid_file = _dom_get_valid_file_path(source, resolved_path, MAXPATHLEN TSRMLS_CC); - if (!valid_file) { - php_error(E_WARNING, "Invalid Schema file source"); - RETURN_FALSE; - } - parser = xmlSchemaNewParserCtxt(valid_file); - break; - case DOM_LOAD_STRING: - parser = xmlSchemaNewMemParserCtxt(source, source_len); - /* If loading from memory, we need to set the base directory for the document - but it is not apparent how to do that for schema's */ - break; - default: - return; - } - - xmlSchemaSetParserErrors(parser, - (xmlSchemaValidityErrorFunc) php_libxml_error_handler, - (xmlSchemaValidityWarningFunc) php_libxml_error_handler, - parser); - sptr = xmlSchemaParse(parser); - xmlSchemaFreeParserCtxt(parser); - if (!sptr) { - php_error(E_WARNING, "Invalid Schema"); - RETURN_FALSE; - } - - docp = (xmlDocPtr) dom_object_get_node(intern); - - vptr = xmlSchemaNewValidCtxt(sptr); - if (!vptr) { - xmlSchemaFree(sptr); - php_error(E_ERROR, "Invalid Schema Validation Context"); - RETURN_FALSE; - } - - xmlSchemaSetValidErrors(vptr, php_libxml_error_handler, php_libxml_error_handler, vptr); - is_valid = xmlSchemaValidateDoc(vptr, docp); - xmlSchemaFree(sptr); - xmlSchemaFreeValidCtxt(vptr); - - if (is_valid == 0) { - RETURN_TRUE; - } else { - RETURN_FALSE; - } -} - -/* {{{ proto boolean domnode _dom_document_schema_validate(string filename); */ -PHP_FUNCTION(dom_document_schema_validate_file) -{ - _dom_document_schema_validate(INTERNAL_FUNCTION_PARAM_PASSTHRU, DOM_LOAD_FILE); -} -/* }}} end _dom_document_schema_validate */ - -/* {{{ proto boolean domnode _dom_document_schema_validate(string source); */ -PHP_FUNCTION(dom_document_schema_validate_xml) -{ - _dom_document_schema_validate(INTERNAL_FUNCTION_PARAM_PASSTHRU, DOM_LOAD_STRING); -} -/* }}} end _dom_document_schema_validate */ - - -static void -_dom_document_relaxNG_validate(INTERNAL_FUNCTION_PARAMETERS, int type) -{ - zval *id; - xmlDoc *docp; - dom_object *intern; - char *source = NULL, *valid_file = NULL; - int source_len = 0; - xmlRelaxNGParserCtxtPtr parser; - xmlRelaxNGPtr sptr; - xmlRelaxNGValidCtxtPtr vptr; - int is_valid; - char resolved_path[MAXPATHLEN + 1]; - - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &source, &source_len) == FAILURE) { - return; - } - - DOM_GET_THIS_OBJ(docp, id, xmlDocPtr, intern); - - switch (type) { - case DOM_LOAD_FILE: - valid_file = _dom_get_valid_file_path(source, resolved_path, MAXPATHLEN TSRMLS_CC); - if (!valid_file) { - php_error(E_WARNING, "Invalid RelaxNG file source"); - RETURN_FALSE; - } - parser = xmlRelaxNGNewParserCtxt(valid_file); - break; - case DOM_LOAD_STRING: - parser = xmlRelaxNGNewMemParserCtxt(source, source_len); - /* If loading from memory, we need to set the base directory for the document - but it is not apparent how to do that for schema's */ - break; - default: - return; - } - - xmlRelaxNGSetParserErrors(parser, - (xmlRelaxNGValidityErrorFunc) php_libxml_error_handler, - (xmlRelaxNGValidityWarningFunc) php_libxml_error_handler, - parser); - sptr = xmlRelaxNGParse(parser); - xmlRelaxNGFreeParserCtxt(parser); - if (!sptr) { - php_error(E_WARNING, "Invalid RelaxNG"); - RETURN_FALSE; - } - - docp = (xmlDocPtr) dom_object_get_node(intern); - - vptr = xmlRelaxNGNewValidCtxt(sptr); - if (!vptr) { - xmlRelaxNGFree(sptr); - php_error(E_ERROR, "Invalid RelaxNG Validation Context"); - RETURN_FALSE; - } - - xmlRelaxNGSetValidErrors(vptr, php_libxml_error_handler, php_libxml_error_handler, vptr); - is_valid = xmlRelaxNGValidateDoc(vptr, docp); - xmlRelaxNGFree(sptr); - xmlRelaxNGFreeValidCtxt(vptr); - - if (is_valid == 0) { - RETURN_TRUE; - } else { - RETURN_FALSE; - } -} - -/* {{{ proto boolean domnode dom_document_relaxNG_validate_file(string filename); */ -PHP_FUNCTION(dom_document_relaxNG_validate_file) -{ - _dom_document_relaxNG_validate(INTERNAL_FUNCTION_PARAM_PASSTHRU, DOM_LOAD_FILE); -} -/* }}} end dom_document_relaxNG_validate_file */ - -/* {{{ proto boolean domnode dom_document_relaxNG_validate_xml(string source); */ -PHP_FUNCTION(dom_document_relaxNG_validate_xml) -{ - _dom_document_relaxNG_validate(INTERNAL_FUNCTION_PARAM_PASSTHRU, DOM_LOAD_STRING); -} -/* }}} end dom_document_relaxNG_validate_xml */ - -#endif - -#if defined(LIBXML_HTML_ENABLED) - -static void dom_load_html(INTERNAL_FUNCTION_PARAMETERS, int mode) -{ - zval *id, *rv = NULL; - xmlDoc *docp = NULL, *newdoc; - dom_object *intern; - dom_doc_props *doc_prop; - char *source; - int source_len, refcount, ret; - htmlParserCtxtPtr ctxt; - - id = getThis(); - - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &source, &source_len) == FAILURE) { - return; - } - - if (!source_len) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Empty string supplied as input"); - RETURN_FALSE; - } - - if (mode == DOM_LOAD_FILE) { - ctxt = htmlCreateFileParserCtxt(source, NULL); - } else { - source_len = xmlStrlen(source); - ctxt = htmlCreateMemoryParserCtxt(source, source_len); - } - - if (!ctxt) { - RETURN_FALSE; - } - - ctxt->vctxt.error = php_libxml_ctx_error; - ctxt->vctxt.warning = php_libxml_ctx_warning; - if (ctxt->sax != NULL) { - ctxt->sax->error = php_libxml_ctx_error; - ctxt->sax->warning = php_libxml_ctx_warning; - } - htmlParseDocument(ctxt); - newdoc = ctxt->myDoc; - htmlFreeParserCtxt(ctxt); - - if (!newdoc) - RETURN_FALSE; - - if (id != NULL) { - intern = (dom_object *)zend_object_store_get_object(id TSRMLS_CC); - if (intern != NULL) { - docp = (xmlDocPtr) dom_object_get_node(intern); - doc_prop = NULL; - if (docp != NULL) { - php_libxml_decrement_node_ptr((php_libxml_node_object *) intern TSRMLS_CC); - doc_prop = intern->document->doc_props; - intern->document->doc_props = NULL; - refcount = php_libxml_decrement_doc_ref((php_libxml_node_object *)intern TSRMLS_CC); - if (refcount != 0) { - docp->_private = NULL; - } - } - intern->document = NULL; - php_libxml_increment_doc_ref((php_libxml_node_object *)intern, newdoc TSRMLS_CC); - intern->document->doc_props = doc_prop; - } - - php_libxml_increment_node_ptr((php_libxml_node_object *)intern, (xmlNodePtr)newdoc, (void *)intern TSRMLS_CC); - - RETURN_TRUE; - } else { - DOM_RET_OBJ(rv, (xmlNodePtr) newdoc, &ret, NULL); - } -} - -/* {{{ proto boolean domnode dom_document_load_html_file(string source); -Since: DOM extended -*/ -PHP_FUNCTION(dom_document_load_html_file) -{ - dom_load_html(INTERNAL_FUNCTION_PARAM_PASSTHRU, DOM_LOAD_FILE); -} -/* }}} end dom_document_load_html_file */ - -/* {{{ proto boolean domnode dom_document_load_html(string source); -Since: DOM extended -*/ -PHP_FUNCTION(dom_document_load_html) -{ - dom_load_html(INTERNAL_FUNCTION_PARAM_PASSTHRU, DOM_LOAD_STRING); -} -/* }}} end dom_document_load_html */ - -/* {{{ proto long dom_document_save_html_file(string file); -Convenience method to save to file as html -*/ -PHP_FUNCTION(dom_document_save_html_file) -{ - zval *id; - xmlDoc *docp; - int file_len, bytes, format; - dom_object *intern; - dom_doc_props *doc_props; - char *file; - - DOM_GET_THIS_OBJ(docp, id, xmlDocPtr, intern); - - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &file, &file_len) == FAILURE) { - return; - } - - /* encoding handled by property on doc */ - - doc_props = dom_get_doc_props(intern->document); - format = doc_props->formatoutput; - bytes = htmlSaveFileFormat(file, docp, NULL, format); - - if (bytes == -1) { - RETURN_FALSE; - } - RETURN_LONG(bytes); -} -/* }}} end dom_document_save_html_file */ - -/* {{{ proto string dom_document_save_html(); -Convenience method to output as html -*/ -PHP_FUNCTION(dom_document_save_html) -{ - zval *id; - xmlDoc *docp; - dom_object *intern; - xmlChar *mem; - int size; - - DOM_GET_THIS_OBJ(docp, id, xmlDocPtr, intern); - - htmlDocDumpMemory(docp, &mem, &size); - if (!size) { - if (mem) - xmlFree(mem); - RETURN_FALSE; - } - RETVAL_STRINGL(mem, size, 1); - xmlFree(mem); -} -/* }}} end dom_document_save_html */ - -#endif /* defined(LIBXML_HTML_ENABLED) */ - -#endif /* HAVE_LIBXML && HAVE_DOM */ diff --git a/ext/dom/documentfragment.c b/ext/dom/documentfragment.c deleted file mode 100644 index a51c7af5a3..0000000000 --- a/ext/dom/documentfragment.c +++ /dev/null @@ -1,71 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP Version 5 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2004 The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 3.0 of the PHP license, | - | that is bundled with this package in the file LICENSE, and is | - | available through the world-wide-web at the following url: | - | http://www.php.net/license/3_0.txt. | - | If you did not receive a copy of the PHP license and are unable to | - | obtain it through the world-wide-web, please send a note to | - | license@php.net so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - | Authors: Christian Stocker <chregu@php.net> | - | Rob Richards <rrichards@php.net> | - +----------------------------------------------------------------------+ -*/ - -/* $Id$ */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "php.h" -#if HAVE_LIBXML && HAVE_DOM -#include "php_dom.h" - - -/* -* class domdocumentfragment extends domnode -* -* URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#ID-B63ED1A3 -* Since: -*/ - -zend_function_entry php_dom_documentfragment_class_functions[] = { - PHP_FALIAS(domdocumentfragment, dom_documentfragment_documentfragment, NULL) - {NULL, NULL, NULL} -}; - -/* {{{ proto dom_documentfragment_documentfragment(); */ -PHP_FUNCTION(dom_documentfragment_documentfragment) -{ - - zval *id; - xmlNodePtr nodep = NULL, oldnode = NULL; - dom_object *intern; - - if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &id, dom_documentfragment_class_entry) == FAILURE) { - return; - } - - nodep = xmlNewDocFragment(NULL); - - if (!nodep) - RETURN_FALSE; - - intern = (dom_object *)zend_object_store_get_object(id TSRMLS_CC); - if (intern != NULL) { - oldnode = (xmlNodePtr)intern->ptr; - if (oldnode != NULL) { - php_libxml_node_free_resource(oldnode TSRMLS_CC); - } - //php_dom_set_object(intern, nodep TSRMLS_CC); - php_libxml_increment_node_ptr((php_libxml_node_object *)intern, nodep, (void *)intern TSRMLS_CC); - } -} -/* }}} end dom_documentfragment_documentfragment */ -#endif diff --git a/ext/dom/documenttype.c b/ext/dom/documenttype.c deleted file mode 100644 index 36d95a18ae..0000000000 --- a/ext/dom/documenttype.c +++ /dev/null @@ -1,205 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP Version 5 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2004 The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 3.0 of the PHP license, | - | that is bundled with this package in the file LICENSE, and is | - | available through the world-wide-web at the following url: | - | http://www.php.net/license/3_0.txt. | - | If you did not receive a copy of the PHP license and are unable to | - | obtain it through the world-wide-web, please send a note to | - | license@php.net so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - | Authors: Christian Stocker <chregu@php.net> | - | Rob Richards <rrichards@php.net> | - +----------------------------------------------------------------------+ -*/ - -/* $Id$ */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "php.h" -#if HAVE_LIBXML && HAVE_DOM -#include "php_dom.h" - -/* -* class domdocumenttype extends domnode -* -* URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-412266927 -* Since: -*/ - -zend_function_entry php_dom_documenttype_class_functions[] = { - {NULL, NULL, NULL} -}; - -/* {{{ attribute protos, not implemented yet */ - -/* {{{ proto name string -readonly=yes -URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-1844763134 -Since: -*/ -int dom_documenttype_name_read(dom_object *obj, zval **retval TSRMLS_DC) -{ - xmlDtdPtr dtdptr; - - dtdptr = (xmlDtdPtr) dom_object_get_node(obj); - ALLOC_ZVAL(*retval); - ZVAL_STRING(*retval, (char *) (dtdptr->name), 1); - - return SUCCESS; -} - -/* }}} */ - - - -/* {{{ proto entities namednodemap -readonly=yes -URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-1788794630 -Since: -*/ -int dom_documenttype_entities_read(dom_object *obj, zval **retval TSRMLS_DC) -{ - xmlDtdPtr doctypep; - xmlHashTable *entityht; - dom_object *intern; - - doctypep = (xmlDtdPtr) dom_object_get_node(obj); - - MAKE_STD_ZVAL(*retval); - php_dom_create_interator(*retval, DOM_NAMEDNODEMAP TSRMLS_CC); - - entityht = (xmlHashTable *) doctypep->entities; - - intern = (dom_object *)zend_objects_get_address(*retval TSRMLS_CC); - dom_namednode_iter(obj, XML_ENTITY_NODE, intern, entityht, NULL, NULL); - - return SUCCESS; -} - -/* }}} */ - - - -/* {{{ proto notations namednodemap -readonly=yes -URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-D46829EF -Since: -*/ -int dom_documenttype_notations_read(dom_object *obj, zval **retval TSRMLS_DC) -{ - xmlDtdPtr doctypep; - xmlHashTable *notationht; - dom_object *intern; - - doctypep = (xmlDtdPtr) dom_object_get_node(obj); - - MAKE_STD_ZVAL(*retval); - php_dom_create_interator(*retval, DOM_NAMEDNODEMAP TSRMLS_CC); - - notationht = (xmlHashTable *) doctypep->notations; - - intern = (dom_object *)zend_objects_get_address(*retval TSRMLS_CC); - dom_namednode_iter(obj, XML_NOTATION_NODE, intern, notationht, NULL, NULL); - - return SUCCESS; -} - -/* }}} */ - - - -/* {{{ proto public_id string -readonly=yes -URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-Core-DocType-publicId -Since: DOM Level 2 -*/ -int dom_documenttype_public_id_read(dom_object *obj, zval **retval TSRMLS_DC) -{ - xmlDtdPtr dtdptr; - - dtdptr = (xmlDtdPtr) dom_object_get_node(obj); - - ALLOC_ZVAL(*retval); - if (dtdptr->ExternalID) { - ZVAL_STRING(*retval, (char *) (dtdptr->ExternalID), 1); - } else { - ZVAL_EMPTY_STRING(*retval); - } - return SUCCESS; - -} - -/* }}} */ - - - -/* {{{ proto system_id string -readonly=yes -URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-Core-DocType-systemId -Since: DOM Level 2 -*/ -int dom_documenttype_system_id_read(dom_object *obj, zval **retval TSRMLS_DC) -{ - xmlDtdPtr dtdptr; - - dtdptr = (xmlDtdPtr) dom_object_get_node(obj); - - ALLOC_ZVAL(*retval); - if (dtdptr->SystemID) { - ZVAL_STRING(*retval, (char *) (dtdptr->ExternalID), 1); - } else { - ZVAL_EMPTY_STRING(*retval); - } - return SUCCESS; -} - -/* }}} */ - - - -/* {{{ proto internal_subset string -readonly=yes -URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-Core-DocType-internalSubset -Since: DOM Level 2 -*/ -int dom_documenttype_internal_subset_read(dom_object *obj, zval **retval TSRMLS_DC) -{ - - xmlDtdPtr dtdptr; - xmlDtd *intsubset; - xmlOutputBuffer *buff = NULL; - xmlChar *strintsubset; - - dtdptr = (xmlDtdPtr) dom_object_get_node(obj); - - ALLOC_ZVAL(*retval); - - if (dtdptr->doc != NULL && ((intsubset = dtdptr->doc->intSubset) != NULL)) { - buff = xmlAllocOutputBuffer(NULL); - if (buff != NULL) { - xmlNodeDumpOutput (buff, NULL, (xmlNodePtr) intsubset, 0, 0, NULL); - xmlOutputBufferFlush(buff); - strintsubset = xmlStrndup(buff->buffer->content, buff->buffer->use); - (void)xmlOutputBufferClose(buff); - ZVAL_STRING(*retval, (char *) strintsubset, 1); - return SUCCESS; - } - } - - ZVAL_EMPTY_STRING(*retval); - - return SUCCESS; - -} - -/* }}} */ - -#endif diff --git a/ext/dom/dom.dsp b/ext/dom/dom.dsp deleted file mode 100644 index f2ae5b1a76..0000000000 --- a/ext/dom/dom.dsp +++ /dev/null @@ -1,250 +0,0 @@ -# Microsoft Developer Studio Project File - Name="dom" - Package Owner=<4>
-# Microsoft Developer Studio Generated Build File, Format Version 6.00
-# ** DO NOT EDIT **
-
-# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
-
-CFG=dom - Win32 Release_TS
-!MESSAGE This is not a valid makefile. To build this project using NMAKE,
-!MESSAGE use the Export Makefile command and run
-!MESSAGE
-!MESSAGE NMAKE /f "dom.mak".
-!MESSAGE
-!MESSAGE You can specify a configuration when running NMAKE
-!MESSAGE by defining the macro CFG on the command line. For example:
-!MESSAGE
-!MESSAGE NMAKE /f "dom.mak" CFG="dom - Win32 Release_TS"
-!MESSAGE
-!MESSAGE Possible choices for configuration are:
-!MESSAGE
-!MESSAGE "dom - Win32 Release_TS" (based on "Win32 (x86) Dynamic-Link Library")
-!MESSAGE "dom - Win32 Debug_TS" (based on "Win32 (x86) Dynamic-Link Library")
-!MESSAGE
-
-# Begin Project
-# PROP AllowPerConfigDependencies 0
-# PROP Scc_ProjName ""
-# PROP Scc_LocalPath ""
-CPP=cl.exe
-MTL=midl.exe
-RSC=rc.exe
-
-!IF "$(CFG)" == "dom - Win32 Release_TS"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "Release_TS"
-# PROP BASE Intermediate_Dir "Release_TS"
-# PROP BASE Ignore_Export_Lib 0
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "Release_TS"
-# PROP Intermediate_Dir "Release_TS"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MT /W3 /GX /O2 /I "..\.." /I "..\..\..\Zend" /I "..\..\..\TSRM" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "COMPILE_DL_DOM" /D ZTS=1 /YX /FD /c
-# ADD CPP /nologo /MD /W3 /GX /O2 /I "..\.." /I "..\..\Zend" /I "..\..\TSRM" /I "..\..\main" /D ZEND_DEBUG=0 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "DOM_EXPORTS" /D "COMPILE_DL_DOM" /D ZTS=1 /D "ZEND_WIN32" /D "PHP_WIN32" /D HAVE_DOM=1 /D "LIBXML_THREAD_ENABLED" /YX /FD /c
-# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
-# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
-# ADD BASE RSC /l 0x406 /d "NDEBUG"
-# ADD RSC /l 0x406 /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib php5ts.lib /nologo /dll /machine:I386
-# ADD LINK32 wsock32.lib php5ts.lib resolv.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /incremental:yes /machine:I386 /out:"..\..\Release_TS/php_dom.dll" /implib:"..\..\Release_TS/php_dom.lib" /libpath:"..\..\Release_TS" /libpath:"..\..\Release_TS_Inline" /libpath:"..\..\..\bindlib_w32\Release"
-# SUBTRACT LINK32 /pdb:none
-
-!ELSEIF "$(CFG)" == "dom - Win32 Debug_TS"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "Debug_TS"
-# PROP BASE Intermediate_Dir "Debug_TS"
-# PROP BASE Ignore_Export_Lib 0
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "Debug_TS"
-# PROP Intermediate_Dir "Debug_TS"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MT /W3 /GX /O2 /I "..\.." /I "..\..\Zend" /I "..\..\TSRM" /I "mssql-70" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "COMPILE_DL_DOM" /D ZTS=1 /YX /FD /c
-# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "..\.." /I "..\..\Zend" /I "..\..\TSRM" /I "..\..\main" /D ZEND_DEBUG=1 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "DOM_EXPORTS" /D "COMPILE_DL_DOM" /D ZTS=1 /D "ZEND_WIN32" /D "PHP_WIN32" /D HAVE_DOM=1 /D LIBXML_THREAD_ENABLED=1 /FR /YX /FD /c
-# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
-# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
-# ADD BASE RSC /l 0x406 /d "NDEBUG"
-# ADD RSC /l 0x406 /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib php5ts.lib /nologo /dll /machine:I386
-# ADD LINK32 php5ts_debug.lib ws2_32.lib resolv.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /incremental:yes /debug /machine:I386 /nodefaultlib:"msvcrt" /out:"..\..\Debug_TS\php_dom.dll" /implib:"..\..\Debug_TS/php_dom.lib" /libpath:"..\..\Debug_TS" /libpath:"..\..\..\bindlib_w32\Release"
-
-!ENDIF
-
-# Begin Target
-
-# Name "dom - Win32 Release_TS"
-# Name "dom - Win32 Debug_TS"
-# Begin Group "Source Files"
-
-# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
-# Begin Source File
-
-SOURCE=.\attr.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\cdatasection.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\characterdata.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\comment.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\document.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\documentfragment.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\documenttype.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\domconfiguration.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\domerror.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\domerrorhandler.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\domexception.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\domimplementation.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\domimplementationlist.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\domimplementationsource.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\domlocator.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\domstringlist.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\element.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\entity.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\entityreference.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\namednodemap.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\namelist.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\node.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\nodelist.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\notation.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\php_dom.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\processinginstruction.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\string_extend.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\text.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\typeinfo.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\userdatahandler.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\xpath.c
-# End Source File
-# End Group
-# Begin Group "Header Files"
-
-# PROP Default_Filter "h;hpp;hxx;hm;inl"
-# Begin Source File
-
-SOURCE=.\dom_ce.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\dom_fe.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\dom_properties.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\php_dom.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\xml_common.h
-# End Source File
-# End Group
-# Begin Group "Resource Files"
-
-# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
-# End Group
-# End Target
-# End Project
diff --git a/ext/dom/dom_ce.h b/ext/dom/dom_ce.h deleted file mode 100644 index ba6d05f721..0000000000 --- a/ext/dom/dom_ce.h +++ /dev/null @@ -1,57 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP Version 5 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2004 The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 3.0 of the PHP license, | - | that is bundled with this package in the file LICENSE, and is | - | available through the world-wide-web at the following url: | - | http://www.php.net/license/3_0.txt. | - | If you did not receive a copy of the PHP license and are unable to | - | obtain it through the world-wide-web, please send a note to | - | license@php.net so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - | Authors: Christian Stocker <chregu@php.net> | - | Rob Richards <rrichards@php.net> | - +----------------------------------------------------------------------+ -*/ - -/* $Id$ */ -#ifndef DOM_CE_H -#define DOM_CE_H - -zend_class_entry *dom_domexception_class_entry; -zend_class_entry *dom_domstringlist_class_entry; -zend_class_entry *dom_namelist_class_entry; -zend_class_entry *dom_domimplementationlist_class_entry; -zend_class_entry *dom_domimplementationsource_class_entry; -zend_class_entry *dom_domimplementation_class_entry; -zend_class_entry *dom_documentfragment_class_entry; -zend_class_entry *dom_document_class_entry; -zend_class_entry *dom_nodelist_class_entry; -zend_class_entry *dom_namednodemap_class_entry; -zend_class_entry *dom_characterdata_class_entry; -zend_class_entry *dom_attr_class_entry; -zend_class_entry *dom_element_class_entry; -zend_class_entry *dom_text_class_entry; -zend_class_entry *dom_comment_class_entry; -zend_class_entry *dom_typeinfo_class_entry; -zend_class_entry *dom_userdatahandler_class_entry; -zend_class_entry *dom_domerror_class_entry; -zend_class_entry *dom_domerrorhandler_class_entry; -zend_class_entry *dom_domlocator_class_entry; -zend_class_entry *dom_domconfiguration_class_entry; -zend_class_entry *dom_cdatasection_class_entry; -zend_class_entry *dom_documenttype_class_entry; -zend_class_entry *dom_notation_class_entry; -zend_class_entry *dom_entity_class_entry; -zend_class_entry *dom_entityreference_class_entry; -zend_class_entry *dom_processinginstruction_class_entry; -zend_class_entry *dom_string_extend_class_entry; -#if defined(LIBXML_XPATH_ENABLED) -zend_class_entry *dom_xpath_class_entry; -#endif -zend_class_entry *dom_namespace_node_class_entry; - -#endif /* DOM_CE_H */ diff --git a/ext/dom/dom_fe.h b/ext/dom/dom_fe.h deleted file mode 100644 index b9d91c8480..0000000000 --- a/ext/dom/dom_fe.h +++ /dev/null @@ -1,261 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP Version 5 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2004 The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 3.0 of the PHP license, | - | that is bundled with this package in the file LICENSE, and is | - | available through the world-wide-web at the following url: | - | http://www.php.net/license/3_0.txt. | - | If you did not receive a copy of the PHP license and are unable to | - | obtain it through the world-wide-web, please send a note to | - | license@php.net so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - | Authors: Christian Stocker <chregu@php.net> | - | Rob Richards <rrichards@php.net> | - +----------------------------------------------------------------------+ -*/ - -/* $Id$ */ -#ifndef DOM_FE_H -#define DOM_FE_H - -extern zend_function_entry php_dom_domexception_class_functions[]; -extern zend_function_entry php_dom_domstringlist_class_functions[]; -extern zend_function_entry php_dom_namelist_class_functions[]; -extern zend_function_entry php_dom_domimplementationlist_class_functions[]; -extern zend_function_entry php_dom_domimplementationsource_class_functions[]; -extern zend_function_entry php_dom_domimplementation_class_functions[]; -extern zend_function_entry php_dom_documentfragment_class_functions[]; -extern zend_function_entry php_dom_document_class_functions[]; -extern zend_function_entry php_dom_node_class_functions[]; -extern zend_function_entry php_dom_nodelist_class_functions[]; -extern zend_function_entry php_dom_namednodemap_class_functions[]; -extern zend_function_entry php_dom_characterdata_class_functions[]; -extern zend_function_entry php_dom_attr_class_functions[]; -extern zend_function_entry php_dom_element_class_functions[]; -extern zend_function_entry php_dom_text_class_functions[]; -extern zend_function_entry php_dom_comment_class_functions[]; -extern zend_function_entry php_dom_typeinfo_class_functions[]; -extern zend_function_entry php_dom_userdatahandler_class_functions[]; -extern zend_function_entry php_dom_domerror_class_functions[]; -extern zend_function_entry php_dom_domerrorhandler_class_functions[]; -extern zend_function_entry php_dom_domlocator_class_functions[]; -extern zend_function_entry php_dom_domconfiguration_class_functions[]; -extern zend_function_entry php_dom_cdatasection_class_functions[]; -extern zend_function_entry php_dom_documenttype_class_functions[]; -extern zend_function_entry php_dom_notation_class_functions[]; -extern zend_function_entry php_dom_entity_class_functions[]; -extern zend_function_entry php_dom_entityreference_class_functions[]; -extern zend_function_entry php_dom_processinginstruction_class_functions[]; -extern zend_function_entry php_dom_string_extend_class_functions[]; -extern zend_function_entry php_dom_xpath_class_functions[]; - -/* domexception errors */ -typedef enum { - INDEX_SIZE_ERR = 1, - DOMSTRING_SIZE_ERR = 2, - HIERARCHY_REQUEST_ERR = 3, - WRONG_DOCUMENT_ERR = 4, - INVALID_CHARACTER_ERR = 5, - NO_DATA_ALLOWED_ERR = 6, - NO_MODIFICATION_ALLOWED_ERR = 7, - NOT_FOUND_ERR = 8, - NOT_SUPPORTED_ERR = 9, - INUSE_ATTRIBUTE_ERR = 10, -// Introduced in DOM Level 2: - INVALID_STATE_ERR = 11, -// Introduced in DOM Level 2: - SYNTAX_ERR = 12, -// Introduced in DOM Level 2: - INVALID_MODIFICATION_ERR = 13, -// Introduced in DOM Level 2: - NAMESPACE_ERR = 14, -// Introduced in DOM Level 2: - INVALID_ACCESS_ERR = 15, -// Introduced in DOM Level 3: - VALIDATION_ERR = 16 -} dom_exception_code; - -/* domstringlist methods */ -PHP_FUNCTION(dom_domstringlist_item); - -/* domnamelist methods */ -PHP_FUNCTION(dom_namelist_get_name); -PHP_FUNCTION(dom_namelist_get_namespace_uri); - -/* domimplementationlist methods */ -PHP_FUNCTION(dom_domimplementationlist_item); - -/* domimplementationsource methods */ -PHP_FUNCTION(dom_domimplementationsource_get_domimplementation); -PHP_FUNCTION(dom_domimplementationsource_get_domimplementations); - -/* domimplementation methods */ -PHP_FUNCTION(dom_domimplementation_has_feature); -PHP_FUNCTION(dom_domimplementation_create_document_type); -PHP_FUNCTION(dom_domimplementation_create_document); -PHP_FUNCTION(dom_domimplementation_get_feature); - -/* domdocumentfragment methods */ -PHP_FUNCTION(dom_documentfragment_documentfragment); - -/* domdocument methods */ -PHP_FUNCTION(dom_document_create_element); -PHP_FUNCTION(dom_document_create_document_fragment); -PHP_FUNCTION(dom_document_create_text_node); -PHP_FUNCTION(dom_document_create_comment); -PHP_FUNCTION(dom_document_create_cdatasection); -PHP_FUNCTION(dom_document_create_processing_instruction); -PHP_FUNCTION(dom_document_create_attribute); -PHP_FUNCTION(dom_document_create_entity_reference); -PHP_FUNCTION(dom_document_get_elements_by_tag_name); -PHP_FUNCTION(dom_document_import_node); -PHP_FUNCTION(dom_document_create_element_ns); -PHP_FUNCTION(dom_document_create_attribute_ns); -PHP_FUNCTION(dom_document_get_elements_by_tag_name_ns); -PHP_FUNCTION(dom_document_get_element_by_id); -PHP_FUNCTION(dom_document_adopt_node); -PHP_FUNCTION(dom_document_normalize_document); -PHP_FUNCTION(dom_document_rename_node); -PHP_FUNCTION(dom_document_document); - /* convienience methods */ -PHP_FUNCTION(dom_document_load); -PHP_FUNCTION(dom_document_save); -PHP_FUNCTION(dom_document_loadxml); -PHP_FUNCTION(dom_document_savexml); -PHP_FUNCTION(dom_document_validate); -PHP_FUNCTION(dom_document_xinclude); - -#if defined(LIBXML_HTML_ENABLED) -PHP_FUNCTION(dom_document_load_html); -PHP_FUNCTION(dom_document_load_html_file); -PHP_FUNCTION(dom_document_save_html); -PHP_FUNCTION(dom_document_save_html_file); -#endif /* defined(LIBXML_HTML_ENABLED) */ - -#if defined(LIBXML_SCHEMAS_ENABLED) -PHP_FUNCTION(dom_document_schema_validate_file); -PHP_FUNCTION(dom_document_schema_validate_xml); -PHP_FUNCTION(dom_document_relaxNG_validate_file); -PHP_FUNCTION(dom_document_relaxNG_validate_xml); -#endif - -/* domnode methods */ -PHP_FUNCTION(dom_node_insert_before); -PHP_FUNCTION(dom_node_replace_child); -PHP_FUNCTION(dom_node_remove_child); -PHP_FUNCTION(dom_node_append_child); -PHP_FUNCTION(dom_node_has_child_nodes); -PHP_FUNCTION(dom_node_clone_node); -PHP_FUNCTION(dom_node_normalize); -PHP_FUNCTION(dom_node_is_supported); -PHP_FUNCTION(dom_node_has_attributes); -PHP_FUNCTION(dom_node_compare_document_position); -PHP_FUNCTION(dom_node_is_same_node); -PHP_FUNCTION(dom_node_lookup_prefix); -PHP_FUNCTION(dom_node_is_default_namespace); -PHP_FUNCTION(dom_node_lookup_namespace_uri); -PHP_FUNCTION(dom_node_is_equal_node); -PHP_FUNCTION(dom_node_get_feature); -PHP_FUNCTION(dom_node_set_user_data); -PHP_FUNCTION(dom_node_get_user_data); - -/* domnodelist methods */ -PHP_FUNCTION(dom_nodelist_item); - -/* domnamednodemap methods */ -PHP_FUNCTION(dom_namednodemap_get_named_item); -PHP_FUNCTION(dom_namednodemap_set_named_item); -PHP_FUNCTION(dom_namednodemap_remove_named_item); -PHP_FUNCTION(dom_namednodemap_item); -PHP_FUNCTION(dom_namednodemap_get_named_item_ns); -PHP_FUNCTION(dom_namednodemap_set_named_item_ns); -PHP_FUNCTION(dom_namednodemap_remove_named_item_ns); - -/* domcharacterdata methods */ -PHP_FUNCTION(dom_characterdata_substring_data); -PHP_FUNCTION(dom_characterdata_append_data); -PHP_FUNCTION(dom_characterdata_insert_data); -PHP_FUNCTION(dom_characterdata_delete_data); -PHP_FUNCTION(dom_characterdata_replace_data); - -/* domattr methods */ -PHP_FUNCTION(dom_attr_is_id); -PHP_FUNCTION(dom_attr_attr); - -/* domelement methods */ -PHP_FUNCTION(dom_element_get_attribute); -PHP_FUNCTION(dom_element_set_attribute); -PHP_FUNCTION(dom_element_remove_attribute); -PHP_FUNCTION(dom_element_get_attribute_node); -PHP_FUNCTION(dom_element_set_attribute_node); -PHP_FUNCTION(dom_element_remove_attribute_node); -PHP_FUNCTION(dom_element_get_elements_by_tag_name); -PHP_FUNCTION(dom_element_get_attribute_ns); -PHP_FUNCTION(dom_element_set_attribute_ns); -PHP_FUNCTION(dom_element_remove_attribute_ns); -PHP_FUNCTION(dom_element_get_attribute_node_ns); -PHP_FUNCTION(dom_element_set_attribute_node_ns); -PHP_FUNCTION(dom_element_get_elements_by_tag_name_ns); -PHP_FUNCTION(dom_element_has_attribute); -PHP_FUNCTION(dom_element_has_attribute_ns); -PHP_FUNCTION(dom_element_set_id_attribute); -PHP_FUNCTION(dom_element_set_id_attribute_ns); -PHP_FUNCTION(dom_element_set_id_attribute_node); -PHP_FUNCTION(dom_element_element); - -/* domtext methods */ -PHP_FUNCTION(dom_text_split_text); -PHP_FUNCTION(dom_text_is_whitespace_in_element_content); -PHP_FUNCTION(dom_text_replace_whole_text); -PHP_FUNCTION(dom_text_text); - -/* domcomment methods */ -PHP_FUNCTION(dom_comment_comment); - -/* domtypeinfo methods */ - -/* domuserdatahandler methods */ -PHP_FUNCTION(dom_userdatahandler_handle); - -/* domdomerror methods */ - -/* domerrorhandler methods */ -PHP_FUNCTION(dom_domerrorhandler_handle_error); - -/* domlocator methods */ - -/* domconfiguration methods */ -PHP_FUNCTION(dom_domconfiguration_set_parameter); -PHP_FUNCTION(dom_domconfiguration_get_parameter); -PHP_FUNCTION(dom_domconfiguration_can_set_parameter); - -/* domcdatasection methods */ -PHP_FUNCTION(dom_cdatasection_cdatasection); - -/* domdocumenttype methods */ - -/* domnotation methods */ - -/* domentity methods */ - -/* domentityreference methods */ -PHP_FUNCTION(dom_entityreference_entityreference); - -/* domprocessinginstruction methods */ -PHP_FUNCTION(dom_processinginstruction_processinginstruction); - -/* string_extend methods */ -PHP_FUNCTION(dom_string_extend_find_offset16); -PHP_FUNCTION(dom_string_extend_find_offset32); - -#if defined(LIBXML_XPATH_ENABLED) -/* xpath methods */ -PHP_FUNCTION(dom_xpath_xpath); -PHP_FUNCTION(dom_xpath_register_ns); -PHP_FUNCTION(dom_xpath_query); -#endif - -#endif /* DOM_FE_H */ diff --git a/ext/dom/dom_iterators.c b/ext/dom/dom_iterators.c deleted file mode 100644 index 6e027c243e..0000000000 --- a/ext/dom/dom_iterators.c +++ /dev/null @@ -1,310 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP Version 5 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2004 The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 3.0 of the PHP license, | - | that is bundled with this package in the file LICENSE, and is | - | available through the world-wide-web at the following url: | - | http://www.php.net/license/3_0.txt. | - | If you did not receive a copy of the PHP license and are unable to | - | obtain it through the world-wide-web, please send a note to | - | license@php.net so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - | Authors: Christian Stocker <chregu@php.net> | - | Rob Richards <rrichards@php.net> | - +----------------------------------------------------------------------+ -*/ - -/* $Id$ */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "php.h" -#if HAVE_LIBXML && HAVE_DOM -#include "php_dom.h" -#include "dom_ce.h" - -typedef struct _nodeIterator nodeIterator; -struct _nodeIterator { - int cur; - int index; - xmlNode *node; -}; - -typedef struct _notationIterator notationIterator; -struct _notationIterator { - int cur; - int index; - xmlNotation *notation; -}; - -static void itemHashScanner (void *payload, void *data, xmlChar *name) { - nodeIterator *priv = (nodeIterator *)data; - - if(priv->cur < priv->index) { - priv->cur++; - } else { - if(priv->node == NULL) { - priv->node = (xmlNode *)payload; - } - } -} - -xmlNodePtr create_notation(const xmlChar *name, - const xmlChar *ExternalID, const xmlChar *SystemID) { - xmlEntityPtr ret; - - ret = (xmlEntityPtr) xmlMalloc(sizeof(xmlEntity)); - memset(ret, 0, sizeof(xmlEntity)); - ret->type = XML_NOTATION_NODE; - ret->name = xmlStrdup(name); - ret->ExternalID = xmlStrdup(ExternalID); - ret->SystemID = xmlStrdup(SystemID); - ret->length = 0; - ret->content = NULL; - ret->URI = NULL; - ret->orig = NULL; - ret->children = NULL; - ret->parent = NULL; - ret->doc = NULL; - ret->_private = NULL; - ret->last = NULL; - ret->prev = NULL; - return((xmlNodePtr) ret); -} - -xmlNode *php_dom_libxml_hash_iter(xmlHashTable *ht, int index) -{ - xmlNode *nodep = NULL; - nodeIterator *iter; - int htsize; - - if ((htsize = xmlHashSize(ht)) > 0 && index < htsize) { - iter = emalloc(sizeof(nodeIterator)); - iter->cur = 0; - iter->index = index; - iter->node = NULL; - xmlHashScan(ht, itemHashScanner, iter); - nodep = iter->node; - efree(iter); - return nodep; - } else { - return NULL; - } -} - -xmlNode *php_dom_libxml_notation_iter(xmlHashTable *ht, int index) -{ - notationIterator *iter; - xmlNotation *notep = NULL; - int htsize; - - if ((htsize = xmlHashSize(ht)) > 0 && index < htsize) { - iter = emalloc(sizeof(notationIterator)); - iter->cur = 0; - iter->index = index; - iter->notation = NULL; - xmlHashScan(ht, itemHashScanner, iter); - notep = iter->notation; - efree(iter); - return create_notation(notep->name, notep->PublicID, notep->SystemID); - } else { - return NULL; - } -} - -static void php_dom_iterator_dtor(zend_object_iterator *iter TSRMLS_DC) -{ - php_dom_iterator *iterator = (php_dom_iterator *)iter; - - zval_ptr_dtor((zval**)&iterator->intern.data); - - if (iterator->curobj) { - zval_ptr_dtor((zval**)&iterator->curobj); - } - - efree(iterator); -} - -static int php_dom_iterator_has_more(zend_object_iterator *iter TSRMLS_DC) -{ - - php_dom_iterator *iterator = (php_dom_iterator *)iter; - - if (iterator->curobj) { - return SUCCESS; - } else { - return FAILURE; - } -} - -static void php_dom_iterator_current_data(zend_object_iterator *iter, zval ***data TSRMLS_DC) -{ - php_dom_iterator *iterator = (php_dom_iterator *)iter; - - *data = &iterator->curobj; -} - -static int php_dom_iterator_current_key(zend_object_iterator *iter, char **str_key, uint *str_key_len, ulong *int_key TSRMLS_DC) -{ - zval *curobj; - xmlNodePtr curnode = NULL; - dom_object *intern; - zval *object; - int namelen; - - php_dom_iterator *iterator = (php_dom_iterator *)iter; - - object = (zval *)iterator->intern.data; - - if (instanceof_function(Z_OBJCE_P(object), dom_nodelist_class_entry TSRMLS_CC)) { - *int_key = iter->index - 1; - return HASH_KEY_IS_LONG; - } else { - curobj = iterator->curobj; - - intern = (dom_object *)zend_object_store_get_object(curobj TSRMLS_CC); - if (intern != NULL && intern->ptr != NULL) { - curnode = (xmlNodePtr)((php_libxml_node_ptr *)intern->ptr)->node; - } - - namelen = xmlStrlen(curnode->name); - *str_key = estrndup(curnode->name, namelen); - *str_key_len = namelen + 1; - return HASH_KEY_IS_STRING; - } -} - -static void php_dom_iterator_move_forward(zend_object_iterator *iter TSRMLS_DC) -{ - zval *curobj, *curattr = NULL; - zval *object; - xmlNodePtr curnode = NULL, basenode; - dom_object *intern; - dom_object *nnmap; - dom_nnodemap_object *objmap; - int ret, previndex=1; - HashTable *nodeht; - pval **entry; - - php_dom_iterator *iterator = (php_dom_iterator *)iter; - - object = (zval *)iterator->intern.data; - nnmap = (dom_object *)zend_object_store_get_object(object TSRMLS_CC); - objmap = (dom_nnodemap_object *)nnmap->ptr; - - curobj = iterator->curobj; - intern = (dom_object *)zend_object_store_get_object(curobj TSRMLS_CC); - if (intern != NULL && intern->ptr != NULL) { - if (objmap->ht == NULL) { - if (objmap->nodetype == DOM_NODESET) { - nodeht = HASH_OF(objmap->baseobjptr); - zend_hash_move_forward(nodeht); - if (zend_hash_get_current_data(nodeht, (void **) &entry)==SUCCESS) { - curattr = *entry; - curattr->refcount++; - } - } else { - curnode = (xmlNodePtr)((php_libxml_node_ptr *)intern->ptr)->node; - if (objmap->nodetype == XML_ATTRIBUTE_NODE || objmap->nodetype == XML_ELEMENT_NODE) { - curnode = curnode->next; - } else { - /* Nav the tree evey time as this is LIVE */ - basenode = dom_object_get_node(objmap->baseobj); - if (basenode && (basenode->type == XML_DOCUMENT_NODE || basenode->type == XML_HTML_DOCUMENT_NODE)) { - basenode = xmlDocGetRootElement((xmlDoc *) basenode); - } else { - basenode = basenode->children; - } - curnode = dom_get_elements_by_tag_name_ns_raw(basenode, objmap->ns, objmap->local, &previndex, iter->index); - } - } - } else { - if (objmap->nodetype == XML_ENTITY_NODE) { - curnode = php_dom_libxml_hash_iter(objmap->ht, iter->index); - } else { - curnode = php_dom_libxml_notation_iter(objmap->ht, iter->index); - } - } - } - - zval_ptr_dtor((zval**)&curobj); - if (curnode) { - MAKE_STD_ZVAL(curattr); - curattr = php_dom_create_object(curnode, &ret, NULL, curattr, objmap->baseobj TSRMLS_CC); - } - - iterator->curobj = curattr; -} - -zend_object_iterator_funcs php_dom_iterator_funcs = { - php_dom_iterator_dtor, - php_dom_iterator_has_more, - php_dom_iterator_current_data, - php_dom_iterator_current_key, - php_dom_iterator_move_forward, - NULL -}; - -zend_object_iterator *php_dom_get_iterator(zend_class_entry *ce, zval *object TSRMLS_DC) -{ - dom_object *intern; - dom_nnodemap_object *objmap; - xmlNodePtr nodep, curnode=NULL; - zval *curattr = NULL; - int ret, curindex = 0; - HashTable *nodeht; - pval **entry; - - php_dom_iterator *iterator = emalloc(sizeof(php_dom_iterator)); - - object->refcount++; - iterator->intern.data = (void*)object; - iterator->intern.funcs = &php_dom_iterator_funcs; - - intern = (dom_object *)zend_object_store_get_object(object TSRMLS_CC); - objmap = (dom_nnodemap_object *)intern->ptr; - if (objmap->ht == NULL) { - if (objmap->nodetype == DOM_NODESET) { - nodeht = HASH_OF(objmap->baseobjptr); - zend_hash_internal_pointer_reset(nodeht); - if (zend_hash_get_current_data(nodeht, (void **) &entry)==SUCCESS) { - curattr = *entry; - curattr->refcount++; - } - } else { - nodep = (xmlNode *)dom_object_get_node(objmap->baseobj); - if (objmap->nodetype == XML_ATTRIBUTE_NODE || objmap->nodetype == XML_ELEMENT_NODE) { - if (objmap->nodetype == XML_ATTRIBUTE_NODE) { - curnode = (xmlNodePtr) nodep->properties; - } else { - curnode = (xmlNodePtr) nodep->children; - } - } else { - if (nodep->type == XML_DOCUMENT_NODE || nodep->type == XML_HTML_DOCUMENT_NODE) { - nodep = xmlDocGetRootElement((xmlDoc *) nodep); - } else { - nodep = nodep->children; - } - curnode = dom_get_elements_by_tag_name_ns_raw(nodep, objmap->ns, objmap->local, &curindex, 0); - } - } - } else { - curnode = php_dom_libxml_hash_iter(objmap->ht, 0); - } - - if (curnode) { - MAKE_STD_ZVAL(curattr); - curattr = php_dom_create_object(curnode, &ret, NULL, curattr, objmap->baseobj TSRMLS_CC); - } - - iterator->curobj = curattr; - - return (zend_object_iterator*)iterator; -} - -#endif diff --git a/ext/dom/dom_properties.h b/ext/dom/dom_properties.h deleted file mode 100644 index f371a7ff37..0000000000 --- a/ext/dom/dom_properties.h +++ /dev/null @@ -1,160 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP Version 5 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2004 The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 3.0 of the PHP license, | - | that is bundled with this package in the file LICENSE, and is | - | available through the world-wide-web at the following url: | - | http://www.php.net/license/3_0.txt. | - | If you did not receive a copy of the PHP license and are unable to | - | obtain it through the world-wide-web, please send a note to | - | license@php.net so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - | Authors: Christian Stocker <chregu@php.net> | - | Rob Richards <rrichards@php.net> | - +----------------------------------------------------------------------+ -*/ - -/* $Id$ */ -#ifndef DOM_PROPERTIES_H -#define DOM_PROPERTIES_H - -/* attr properties */ -int dom_attr_name_read(dom_object *obj, zval **retval TSRMLS_DC); -int dom_attr_specified_read(dom_object *obj, zval **retval TSRMLS_DC); -int dom_attr_value_read(dom_object *obj, zval **retval TSRMLS_DC); -int dom_attr_value_write(dom_object *obj, zval *newval TSRMLS_DC); -int dom_attr_owner_element_read(dom_object *obj, zval **retval TSRMLS_DC); -int dom_attr_schema_type_info_read(dom_object *obj, zval **retval TSRMLS_DC); - -/* characterdata properties */ -int dom_characterdata_data_read(dom_object *obj, zval **retval TSRMLS_DC); -int dom_characterdata_data_write(dom_object *obj, zval *newval TSRMLS_DC); -int dom_characterdata_length_read(dom_object *obj, zval **retval TSRMLS_DC); - -/* document properties */ -int dom_document_doctype_read(dom_object *obj, zval **retval TSRMLS_DC); -int dom_document_implementation_read(dom_object *obj, zval **retval TSRMLS_DC); -int dom_document_document_element_read(dom_object *obj, zval **retval TSRMLS_DC); -int dom_document_actual_encoding_read(dom_object *obj, zval **retval TSRMLS_DC); -int dom_document_actual_encoding_write(dom_object *obj, zval *newval TSRMLS_DC); -int dom_document_encoding_read(dom_object *obj, zval **retval TSRMLS_DC); -int dom_document_encoding_write(dom_object *obj, zval *newval TSRMLS_DC); -int dom_document_standalone_read(dom_object *obj, zval **retval TSRMLS_DC); -int dom_document_standalone_write(dom_object *obj, zval *newval TSRMLS_DC); -int dom_document_version_read(dom_object *obj, zval **retval TSRMLS_DC); -int dom_document_version_write(dom_object *obj, zval *newval TSRMLS_DC); -int dom_document_strict_error_checking_read(dom_object *obj, zval **retval TSRMLS_DC); -int dom_document_strict_error_checking_write(dom_object *obj, zval *newval TSRMLS_DC); -int dom_document_document_uri_read(dom_object *obj, zval **retval TSRMLS_DC); -int dom_document_document_uri_write(dom_object *obj, zval *newval TSRMLS_DC); -int dom_document_config_read(dom_object *obj, zval **retval TSRMLS_DC); -int dom_document_format_output_read(dom_object *obj, zval **retval TSRMLS_DC); -int dom_document_format_output_write(dom_object *obj, zval *newval TSRMLS_DC); -int dom_document_validate_on_parse_read(dom_object *obj, zval **retval TSRMLS_DC); -int dom_document_validate_on_parse_write(dom_object *obj, zval *newval TSRMLS_DC); -int dom_document_resolve_externals_read(dom_object *obj, zval **retval TSRMLS_DC); -int dom_document_resolve_externals_write(dom_object *obj, zval *newval TSRMLS_DC); -int dom_document_preserve_whitespace_read(dom_object *obj, zval **retval TSRMLS_DC); -int dom_document_preserve_whitespace_write(dom_object *obj, zval *newval TSRMLS_DC); -int dom_document_substitue_entities_read(dom_object *obj, zval **retval TSRMLS_DC); -int dom_document_substitue_entities_write(dom_object *obj, zval *newval TSRMLS_DC); - -/* documenttype properties */ -int dom_documenttype_name_read(dom_object *obj, zval **retval TSRMLS_DC); -int dom_documenttype_entities_read(dom_object *obj, zval **retval TSRMLS_DC); -int dom_documenttype_notations_read(dom_object *obj, zval **retval TSRMLS_DC); -int dom_documenttype_public_id_read(dom_object *obj, zval **retval TSRMLS_DC); -int dom_documenttype_system_id_read(dom_object *obj, zval **retval TSRMLS_DC); -int dom_documenttype_internal_subset_read(dom_object *obj, zval **retval TSRMLS_DC); - -/* domerror properties */ -int dom_domerror_severity_read(dom_object *obj, zval **retval TSRMLS_DC); -int dom_domerror_message_read(dom_object *obj, zval **retval TSRMLS_DC); -int dom_domerror_type_read(dom_object *obj, zval **retval TSRMLS_DC); -int dom_domerror_related_exception_read(dom_object *obj, zval **retval TSRMLS_DC); -int dom_domerror_related_data_read(dom_object *obj, zval **retval TSRMLS_DC); -int dom_domerror_location_read(dom_object *obj, zval **retval TSRMLS_DC); - -/* domimplementationlist properties */ -int dom_domimplementationlist_length_read(dom_object *obj, zval **retval TSRMLS_DC); - -/* domlocator properties */ -int dom_domlocator_line_number_read(dom_object *obj, zval **retval TSRMLS_DC); -int dom_domlocator_column_number_read(dom_object *obj, zval **retval TSRMLS_DC); -int dom_domlocator_offset_read(dom_object *obj, zval **retval TSRMLS_DC); -int dom_domlocator_related_node_read(dom_object *obj, zval **retval TSRMLS_DC); -int dom_domlocator_uri_read(dom_object *obj, zval **retval TSRMLS_DC); - -/* domstringlist properties */ -int dom_domstringlist_length_read(dom_object *obj, zval **retval TSRMLS_DC); - -/* element properties */ -int dom_element_tag_name_read(dom_object *obj, zval **retval TSRMLS_DC); -int dom_element_schema_type_info_read(dom_object *obj, zval **retval TSRMLS_DC); - -/* entity properties */ -int dom_entity_public_id_read(dom_object *obj, zval **retval TSRMLS_DC); -int dom_entity_system_id_read(dom_object *obj, zval **retval TSRMLS_DC); -int dom_entity_notation_name_read(dom_object *obj, zval **retval TSRMLS_DC); -int dom_entity_actual_encoding_read(dom_object *obj, zval **retval TSRMLS_DC); -int dom_entity_actual_encoding_write(dom_object *obj, zval *newval TSRMLS_DC); -int dom_entity_encoding_read(dom_object *obj, zval **retval TSRMLS_DC); -int dom_entity_encoding_write(dom_object *obj, zval *newval TSRMLS_DC); -int dom_entity_version_read(dom_object *obj, zval **retval TSRMLS_DC); -int dom_entity_version_write(dom_object *obj, zval *newval TSRMLS_DC); - -/* namednodemap properties */ -int dom_namednodemap_length_read(dom_object *obj, zval **retval TSRMLS_DC); - -/* namelist properties */ -int dom_namelist_length_read(dom_object *obj, zval **retval TSRMLS_DC); - -/* node properties */ -int dom_node_node_name_read(dom_object *obj, zval **retval TSRMLS_DC); -int dom_node_node_value_read(dom_object *obj, zval **retval TSRMLS_DC); -int dom_node_node_value_write(dom_object *obj, zval *newval TSRMLS_DC); -int dom_node_node_type_read(dom_object *obj, zval **retval TSRMLS_DC); -int dom_node_parent_node_read(dom_object *obj, zval **retval TSRMLS_DC); -int dom_node_child_nodes_read(dom_object *obj, zval **retval TSRMLS_DC); -int dom_node_first_child_read(dom_object *obj, zval **retval TSRMLS_DC); -int dom_node_last_child_read(dom_object *obj, zval **retval TSRMLS_DC); -int dom_node_previous_sibling_read(dom_object *obj, zval **retval TSRMLS_DC); -int dom_node_next_sibling_read(dom_object *obj, zval **retval TSRMLS_DC); -int dom_node_attributes_read(dom_object *obj, zval **retval TSRMLS_DC); -int dom_node_owner_document_read(dom_object *obj, zval **retval TSRMLS_DC); -int dom_node_namespace_uri_read(dom_object *obj, zval **retval TSRMLS_DC); -int dom_node_prefix_read(dom_object *obj, zval **retval TSRMLS_DC); -int dom_node_prefix_write(dom_object *obj, zval *newval TSRMLS_DC); -int dom_node_local_name_read(dom_object *obj, zval **retval TSRMLS_DC); -int dom_node_base_uri_read(dom_object *obj, zval **retval TSRMLS_DC); -int dom_node_text_content_read(dom_object *obj, zval **retval TSRMLS_DC); -int dom_node_text_content_write(dom_object *obj, zval *newval TSRMLS_DC); - -/* nodelist properties */ -int dom_nodelist_length_read(dom_object *obj, zval **retval TSRMLS_DC); - -/* notation properties */ -int dom_notation_public_id_read(dom_object *obj, zval **retval TSRMLS_DC); -int dom_notation_system_id_read(dom_object *obj, zval **retval TSRMLS_DC); - -/* processinginstruction properties */ -int dom_processinginstruction_target_read(dom_object *obj, zval **retval TSRMLS_DC); -int dom_processinginstruction_data_read(dom_object *obj, zval **retval TSRMLS_DC); -int dom_processinginstruction_data_write(dom_object *obj, zval *newval TSRMLS_DC); - -/* text properties */ -int dom_text_whole_text_read(dom_object *obj, zval **retval TSRMLS_DC); - -/* typeinfo properties */ -int dom_typeinfo_type_name_read(dom_object *obj, zval **retval TSRMLS_DC); -int dom_typeinfo_type_namespace_read(dom_object *obj, zval **retval TSRMLS_DC); - -#if defined(LIBXML_XPATH_ENABLED) -/* xpath properties */ -int dom_xpath_document_read(dom_object *obj, zval **retval TSRMLS_DC); -#endif - -#endif /* DOM_PROPERTIERS_H */ diff --git a/ext/dom/domconfiguration.c b/ext/dom/domconfiguration.c deleted file mode 100644 index c82bcae1c6..0000000000 --- a/ext/dom/domconfiguration.c +++ /dev/null @@ -1,79 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP Version 5 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2004 The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 3.0 of the PHP license, | - | that is bundled with this package in the file LICENSE, and is | - | available through the world-wide-web at the following url: | - | http://www.php.net/license/3_0.txt. | - | If you did not receive a copy of the PHP license and are unable to | - | obtain it through the world-wide-web, please send a note to | - | license@php.net so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - | Authors: Christian Stocker <chregu@php.net> | - | Rob Richards <rrichards@php.net> | - +----------------------------------------------------------------------+ -*/ - -/* $Id$ */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "php.h" -#if HAVE_LIBXML && HAVE_DOM -#include "php_dom.h" - - -/* -* class domdomconfiguration -* -* URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#DOMConfiguration -* Since: DOM Level 3 -*/ - -zend_function_entry php_dom_domconfiguration_class_functions[] = { - PHP_FALIAS(setParameter, dom_domconfiguration_set_parameter, NULL) - PHP_FALIAS(getParameter, dom_domconfiguration_get_parameter, NULL) - PHP_FALIAS(canSetParameter, dom_domconfiguration_can_set_parameter, NULL) - {NULL, NULL, NULL} -}; - -/* {{{ attribute protos, not implemented yet */ - - -/* {{{ proto dom_void dom_domconfiguration_set_parameter(string name, domuserdata value); -URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#DOMConfiguration-property -Since: -*/ -PHP_FUNCTION(dom_domconfiguration_set_parameter) -{ - DOM_NOT_IMPLEMENTED(); -} -/* }}} end dom_domconfiguration_set_parameter */ - - -/* {{{ proto domdomuserdata dom_domconfiguration_get_parameter(string name); -URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#DOMConfiguration-getParameter -Since: -*/ -PHP_FUNCTION(dom_domconfiguration_get_parameter) -{ - DOM_NOT_IMPLEMENTED(); -} -/* }}} end dom_domconfiguration_get_parameter */ - - -/* {{{ proto boolean dom_domconfiguration_can_set_parameter(string name, domuserdata value); -URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#DOMConfiguration-canSetParameter -Since: -*/ -PHP_FUNCTION(dom_domconfiguration_can_set_parameter) -{ - DOM_NOT_IMPLEMENTED(); -} -/* }}} end dom_domconfiguration_can_set_parameter */ -#endif diff --git a/ext/dom/domerror.c b/ext/dom/domerror.c deleted file mode 100644 index 002632e863..0000000000 --- a/ext/dom/domerror.c +++ /dev/null @@ -1,138 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP Version 5 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2004 The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 3.0 of the PHP license, | - | that is bundled with this package in the file LICENSE, and is | - | available through the world-wide-web at the following url: | - | http://www.php.net/license/3_0.txt. | - | If you did not receive a copy of the PHP license and are unable to | - | obtain it through the world-wide-web, please send a note to | - | license@php.net so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - | Authors: Christian Stocker <chregu@php.net> | - | Rob Richards <rrichards@php.net> | - +----------------------------------------------------------------------+ -*/ - -/* $Id$ */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "php.h" -#if HAVE_LIBXML && HAVE_DOM -#include "php_dom.h" - - -/* -* class domerror -* -* URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#ERROR-Interfaces-DOMError -* Since: DOM Level 3 -*/ - -zend_function_entry php_dom_domerror_class_functions[] = { - {NULL, NULL, NULL} -}; - -/* {{{ attribute protos, not implemented yet */ - -/* {{{ proto severity unsigned short -readonly=yes -URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#ERROR-DOMError-severity -Since: -*/ -int dom_domerror_severity_read(dom_object *obj, zval **retval TSRMLS_DC) -{ - ALLOC_ZVAL(*retval); - ZVAL_STRING(*retval, "TEST", 1); - return SUCCESS; -} - -/* }}} */ - - - -/* {{{ proto message string -readonly=yes -URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#ERROR-DOMError-message -Since: -*/ -int dom_domerror_message_read(dom_object *obj, zval **retval TSRMLS_DC) -{ - ALLOC_ZVAL(*retval); - ZVAL_STRING(*retval, "TEST", 1); - return SUCCESS; -} - -/* }}} */ - - - -/* {{{ proto type string -readonly=yes -URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#ERROR-DOMError-type -Since: -*/ -int dom_domerror_type_read(dom_object *obj, zval **retval TSRMLS_DC) -{ - ALLOC_ZVAL(*retval); - ZVAL_STRING(*retval, "TEST", 1); - return SUCCESS; -} - -/* }}} */ - - - -/* {{{ proto relatedException object -readonly=yes -URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#ERROR-DOMError-relatedException -Since: -*/ -int dom_domerror_related_exception_read(dom_object *obj, zval **retval TSRMLS_DC) -{ - ALLOC_ZVAL(*retval); - ZVAL_STRING(*retval, "TEST", 1); - return SUCCESS; -} - -/* }}} */ - - - -/* {{{ proto relatedData domobject -readonly=yes -URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#ERROR-DOMError-relatedData -Since: -*/ -int dom_domerror_related_data_read(dom_object *obj, zval **retval TSRMLS_DC) -{ - ALLOC_ZVAL(*retval); - ZVAL_STRING(*retval, "TEST", 1); - return SUCCESS; -} - -/* }}} */ - - - -/* {{{ proto location domlocator -readonly=yes -URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#ERROR-DOMError-location -Since: -*/ -int dom_domerror_location_read(dom_object *obj, zval **retval TSRMLS_DC) -{ - ALLOC_ZVAL(*retval); - ZVAL_STRING(*retval, "TEST", 1); - return SUCCESS; -} - -/* }}} */ - -#endif diff --git a/ext/dom/domerrorhandler.c b/ext/dom/domerrorhandler.c deleted file mode 100644 index e052d483eb..0000000000 --- a/ext/dom/domerrorhandler.c +++ /dev/null @@ -1,55 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP Version 5 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2004 The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 3.0 of the PHP license, | - | that is bundled with this package in the file LICENSE, and is | - | available through the world-wide-web at the following url: | - | http://www.php.net/license/3_0.txt. | - | If you did not receive a copy of the PHP license and are unable to | - | obtain it through the world-wide-web, please send a note to | - | license@php.net so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - | Authors: Christian Stocker <chregu@php.net> | - | Rob Richards <rrichards@php.net> | - +----------------------------------------------------------------------+ -*/ - -/* $Id$ */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "php.h" -#if HAVE_LIBXML && HAVE_DOM -#include "php_dom.h" - - -/* -* class domerrorhandler -* -* URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#ERROR-Interfaces-DOMErrorHandler -* Since: DOM Level 3 -*/ - -zend_function_entry php_dom_domerrorhandler_class_functions[] = { - PHP_FALIAS(handleError, dom_domerrorhandler_handle_error, NULL) - {NULL, NULL, NULL} -}; - -/* {{{ attribute protos, not implemented yet */ - - -/* {{{ proto dom_boolean dom_domerrorhandler_handle_error(domerror error); -URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#ID-ERRORS-DOMErrorHandler-handleError -Since: -*/ -PHP_FUNCTION(dom_domerrorhandler_handle_error) -{ - DOM_NOT_IMPLEMENTED(); -} -/* }}} end dom_domerrorhandler_handle_error */ -#endif diff --git a/ext/dom/domexception.c b/ext/dom/domexception.c deleted file mode 100644 index 860daab727..0000000000 --- a/ext/dom/domexception.c +++ /dev/null @@ -1,111 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP Version 5 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2004 The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 3.0 of the PHP license, | - | that is bundled with this package in the file LICENSE, and is | - | available through the world-wide-web at the following url: | - | http://www.php.net/license/3_0.txt. | - | If you did not receive a copy of the PHP license and are unable to | - | obtain it through the world-wide-web, please send a note to | - | license@php.net so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - | Authors: Christian Stocker <chregu@php.net> | - | Rob Richards <rrichards@php.net> | - +----------------------------------------------------------------------+ -*/ - -/* $Id$ */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "php.h" -#if HAVE_LIBXML && HAVE_DOM -#include "php_dom.h" - - -/* -* class domexception -* -* URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-17189187 -* Since: -*/ - -extern zend_class_entry *dom_domexception_class_entry; - -zend_function_entry php_dom_domexception_class_functions[] = { - {NULL, NULL, NULL} -}; - -/* {{{ php_dom_throw_error */ -void php_dom_throw_error(int error_code, int strict_error TSRMLS_DC) -{ - char *error_message; - - switch (error_code) - { - case INDEX_SIZE_ERR: - error_message = "Index Size Error"; - break; - case DOMSTRING_SIZE_ERR: - error_message = "DOM String Size Error"; - break; - case HIERARCHY_REQUEST_ERR: - error_message = "Hierarchy Request Error"; - break; - case WRONG_DOCUMENT_ERR: - error_message = "Wrong Document Error"; - break; - case INVALID_CHARACTER_ERR: - error_message = "Invalid Character Error"; - break; - case NO_DATA_ALLOWED_ERR: - error_message = "No Data Allowed Error"; - break; - case NO_MODIFICATION_ALLOWED_ERR: - error_message = "No Modification Allowed Error"; - break; - case NOT_FOUND_ERR: - error_message = "Not Found Error"; - break; - case NOT_SUPPORTED_ERR: - error_message = "Not Supported Error"; - break; - case INUSE_ATTRIBUTE_ERR: - error_message = "Inuse Attribute Error"; - break; - case INVALID_STATE_ERR: - error_message = "Invalid State Error"; - break; - case SYNTAX_ERR: - error_message = "Syntax Error"; - break; - case INVALID_MODIFICATION_ERR: - error_message = "Invalid Modification Error"; - break; - case NAMESPACE_ERR: - error_message = "Namespace Error"; - break; - case INVALID_ACCESS_ERR: - error_message = "Invalid Access Error"; - break; - case VALIDATION_ERR: - error_message = "Validation Error"; - break; - default: - error_message = "Unhandled Error"; - } - - if (strict_error == 1) { - zend_throw_exception(dom_domexception_class_entry, error_message, error_code TSRMLS_CC); - } else { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", error_message); - } -} -/* }}} end php_dom_throw_error */ - -#endif /* HAVE_LIBXML && HAVE_DOM */ diff --git a/ext/dom/domimplementation.c b/ext/dom/domimplementation.c deleted file mode 100644 index 13d92ed68e..0000000000 --- a/ext/dom/domimplementation.c +++ /dev/null @@ -1,236 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP Version 5 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2004 The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 3.0 of the PHP license, | - | that is bundled with this package in the file LICENSE, and is | - | available through the world-wide-web at the following url: | - | http://www.php.net/license/3_0.txt. | - | If you did not receive a copy of the PHP license and are unable to | - | obtain it through the world-wide-web, please send a note to | - | license@php.net so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - | Authors: Christian Stocker <chregu@php.net> | - | Rob Richards <rrichards@php.net> | - +----------------------------------------------------------------------+ -*/ - -/* $Id$ */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "php.h" -#if HAVE_LIBXML && HAVE_DOM -#include "php_dom.h" - -/* -* class domimplementation -* -* URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#ID-102161490 -* Since: -*/ - -zend_function_entry php_dom_domimplementation_class_functions[] = { - PHP_FALIAS(hasFeature, dom_domimplementation_has_feature, NULL) - PHP_FALIAS(createDocumentType, dom_domimplementation_create_document_type, NULL) - PHP_FALIAS(createDocument, dom_domimplementation_create_document, NULL) - PHP_FALIAS(getFeature, dom_domimplementation_get_feature, NULL) - {NULL, NULL, NULL} -}; - -/* {{{ attribute protos, not implemented yet */ - - -/* {{{ proto boolean dom_domimplementation_has_feature(string feature, string version); -URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#ID-5CED94D7 -Since: -*/ -PHP_FUNCTION(dom_domimplementation_has_feature) -{ - int feature_len, version_len; - char *feature, *version; - - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss", &feature, &feature_len, &version, &version_len) == FAILURE) { - return; - } - - if (dom_has_feature(feature, version)) { - RETURN_TRUE; - } else { - RETURN_FALSE; - } -} -/* }}} end dom_domimplementation_has_feature */ - - -/* {{{ proto domdocumenttype dom_domimplementation_create_document_type(string qualifiedName, string publicId, string systemId); -URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#Level-2-Core-DOM-createDocType -Since: DOM Level 2 -*/ -PHP_FUNCTION(dom_domimplementation_create_document_type) -{ - zval *rv = NULL; - xmlDtd *doctype; - int ret, name_len, publicid_len, systemid_len; - char *name, *publicid, *systemid; - xmlChar *pch1 = NULL, *pch2 = NULL, *localname = NULL; - xmlURIPtr uri; - - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|sss", &name, &name_len, &publicid, &publicid_len, &systemid, &systemid_len) == FAILURE) { - return; - } - - if (name_len == 0) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "qualifiedName is required"); - RETURN_FALSE; - } - - if (publicid_len > 0) - pch1 = publicid; - if (systemid_len > 0) - pch2 = systemid; - - uri = xmlParseURI(name); - if (uri->opaque != NULL) { - localname = xmlStrdup(uri->opaque); - if (xmlStrchr(localname, (xmlChar) ':') != NULL) { - php_dom_throw_error(NAMESPACE_ERR, 1 TSRMLS_CC); - xmlFreeURI(uri); - xmlFree(localname); - RETURN_FALSE; - } - } else { - localname = xmlStrdup(name); - } - - /* TODO: Test that localname has no invalid chars - php_dom_throw_error(INVALID_CHARACTER_ERR, TSRMLS_CC); - */ - - xmlFreeURI(uri); - - doctype = xmlCreateIntSubset(NULL, localname, pch1, pch2); - xmlFree(localname); - - DOM_RET_OBJ(rv, (xmlNodePtr) doctype, &ret, NULL); -} -/* }}} end dom_domimplementation_create_document_type */ - - -/* {{{ proto domdocument dom_domimplementation_create_document(string namespaceURI, string qualifiedName, documenttype doctype); -URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#Level-2-Core-DOM-createDocument -Since: DOM Level 2 -*/ -PHP_FUNCTION(dom_domimplementation_create_document) -{ - zval *node = NULL, *rv = NULL; - xmlDoc *docp; - xmlNode *nodep; - xmlDtdPtr doctype = NULL; - xmlNsPtr nsptr = NULL; - int ret, uri_len = 0, name_len = 0, errorcode = 0; - char *uri, *name; - char *prefix = NULL, *localname = NULL; - dom_object *doctobj; - - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|sso", &uri, &uri_len, &name, &name_len, &node) == FAILURE) { - return; - } - - if (node != NULL) { - DOM_GET_OBJ(doctype, node, xmlDtdPtr, doctobj); - if (doctype->type == XML_DOCUMENT_TYPE_NODE) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid DocumentType object"); - RETURN_FALSE; - } - if (doctype->doc != NULL) { - php_dom_throw_error(WRONG_DOCUMENT_ERR, 1 TSRMLS_CC); - RETURN_FALSE; - } - } else { - doctobj = NULL; - } - - if (name_len > 0) { - errorcode = dom_check_qname(name, &localname, &prefix, 1, name_len); - if (errorcode == 0 && uri_len > 0 && ((nsptr = xmlNewNs(NULL, uri, prefix)) == NULL)) { - errorcode = NAMESPACE_ERR; - } - } - - if (prefix != NULL) { - xmlFree(prefix); - } - - if (errorcode != 0) { - if (localname != NULL) { - xmlFree(localname); - } - php_dom_throw_error(errorcode, 1 TSRMLS_CC); - RETURN_FALSE; - } - - /* currently letting libxml2 set the version string */ - docp = xmlNewDoc(NULL); - if (!docp) { - if (localname != NULL) { - xmlFree(localname); - } - RETURN_FALSE; - } - - if (doctype != NULL) { - docp->intSubset = doctype; - doctype->parent = docp; - doctype->doc = docp; - docp->children = (xmlNodePtr) doctype; - docp->last = (xmlNodePtr) doctype; - } - - if (localname != NULL) { - nodep = xmlNewDocNode (docp, nsptr, localname, NULL); - if (!nodep) { - if (doctype != NULL) { - docp->intSubset = NULL; - doctype->parent = NULL; - doctype->doc = NULL; - docp->children = NULL; - docp->last = NULL; - } - xmlFreeDoc(docp); - xmlFree(localname); - /* Need some type of error here */ - php_error(E_WARNING, "Unexpected Error"); - RETURN_FALSE; - } - - nodep->nsDef = nsptr; - - xmlDocSetRootElement(docp, nodep); - xmlFree(localname); - } - - DOM_RET_OBJ(rv, (xmlNodePtr) docp, &ret, NULL); - - if (doctobj != NULL) { - doctobj->document = ((dom_object *)((php_libxml_node_ptr *)docp->_private)->_private)->document; - php_libxml_increment_doc_ref((php_libxml_node_object *)doctobj, docp TSRMLS_CC); - } -} -/* }}} end dom_domimplementation_create_document */ - - -/* {{{ proto domnode dom_domimplementation_get_feature(string feature, string version); -URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#DOMImplementation3-getFeature -Since: DOM Level 3 -*/ -PHP_FUNCTION(dom_domimplementation_get_feature) -{ - DOM_NOT_IMPLEMENTED(); -} -/* }}} end dom_domimplementation_get_feature */ -#endif diff --git a/ext/dom/domimplementationlist.c b/ext/dom/domimplementationlist.c deleted file mode 100644 index 7a71e46c4b..0000000000 --- a/ext/dom/domimplementationlist.c +++ /dev/null @@ -1,71 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP Version 5 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2004 The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 3.0 of the PHP license, | - | that is bundled with this package in the file LICENSE, and is | - | available through the world-wide-web at the following url: | - | http://www.php.net/license/3_0.txt. | - | If you did not receive a copy of the PHP license and are unable to | - | obtain it through the world-wide-web, please send a note to | - | license@php.net so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - | Authors: Christian Stocker <chregu@php.net> | - | Rob Richards <rrichards@php.net> | - +----------------------------------------------------------------------+ -*/ - -/* $Id$ */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "php.h" -#if HAVE_LIBXML && HAVE_DOM -#include "php_dom.h" - - -/* -* class domimplementationlist -* -* URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#DOMImplementationList -* Since: DOM Level 3 -*/ - -zend_function_entry php_dom_domimplementationlist_class_functions[] = { - PHP_FALIAS(item, dom_domimplementationlist_item, NULL) - {NULL, NULL, NULL} -}; - -/* {{{ attribute protos, not implemented yet */ - -/* {{{ proto length unsigned long -readonly=yes -URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#DOMImplementationList-length -Since: -*/ -int dom_domimplementationlist_length_read(dom_object *obj, zval **retval TSRMLS_DC) -{ - ALLOC_ZVAL(*retval); - ZVAL_STRING(*retval, "TEST", 1); - return SUCCESS; -} - -/* }}} */ - - - - -/* {{{ proto domdomimplementation dom_domimplementationlist_item(unsigned long index); -URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#DOMImplementationList-item -Since: -*/ -PHP_FUNCTION(dom_domimplementationlist_item) -{ - DOM_NOT_IMPLEMENTED(); -} -/* }}} end dom_domimplementationlist_item */ -#endif diff --git a/ext/dom/domimplementationsource.c b/ext/dom/domimplementationsource.c deleted file mode 100644 index 92cad20750..0000000000 --- a/ext/dom/domimplementationsource.c +++ /dev/null @@ -1,67 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP Version 5 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2004 The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 3.0 of the PHP license, | - | that is bundled with this package in the file LICENSE, and is | - | available through the world-wide-web at the following url: | - | http://www.php.net/license/3_0.txt. | - | If you did not receive a copy of the PHP license and are unable to | - | obtain it through the world-wide-web, please send a note to | - | license@php.net so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - | Authors: Christian Stocker <chregu@php.net> | - | Rob Richards <rrichards@php.net> | - +----------------------------------------------------------------------+ -*/ - -/* $Id$ */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "php.h" -#if HAVE_LIBXML && HAVE_DOM -#include "php_dom.h" - - -/* -* class domimplementationsource -* -* URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#DOMImplementationSource -* Since: DOM Level 3 -*/ - -zend_function_entry php_dom_domimplementationsource_class_functions[] = { - PHP_FALIAS(getDomimplementation, dom_domimplementationsource_get_domimplementation, NULL) - PHP_FALIAS(getDomimplementations, dom_domimplementationsource_get_domimplementations, NULL) - {NULL, NULL, NULL} -}; - -/* {{{ attribute protos, not implemented yet */ - - -/* {{{ proto domdomimplementation dom_domimplementationsource_get_domimplementation(string features); -URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#ID-getDOMImpl -Since: -*/ -PHP_FUNCTION(dom_domimplementationsource_get_domimplementation) -{ - DOM_NOT_IMPLEMENTED(); -} -/* }}} end dom_domimplementationsource_get_domimplementation */ - - -/* {{{ proto domimplementationlist dom_domimplementationsource_get_domimplementations(string features); -URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#ID-getDOMImpls -Since: -*/ -PHP_FUNCTION(dom_domimplementationsource_get_domimplementations) -{ - DOM_NOT_IMPLEMENTED(); -} -/* }}} end dom_domimplementationsource_get_domimplementations */ -#endif diff --git a/ext/dom/domlocator.c b/ext/dom/domlocator.c deleted file mode 100644 index eae848f94e..0000000000 --- a/ext/dom/domlocator.c +++ /dev/null @@ -1,123 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP Version 5 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2004 The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 3.0 of the PHP license, | - | that is bundled with this package in the file LICENSE, and is | - | available through the world-wide-web at the following url: | - | http://www.php.net/license/3_0.txt. | - | If you did not receive a copy of the PHP license and are unable to | - | obtain it through the world-wide-web, please send a note to | - | license@php.net so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - | Authors: Christian Stocker <chregu@php.net> | - | Rob Richards <rrichards@php.net> | - +----------------------------------------------------------------------+ -*/ - -/* $Id$ */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "php.h" -#if HAVE_LIBXML && HAVE_DOM -#include "php_dom.h" - - -/* -* class domlocator -* -* URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#Interfaces-DOMLocator -* Since: DOM Level 3 -*/ - -zend_function_entry php_dom_domlocator_class_functions[] = { - {NULL, NULL, NULL} -}; - -/* {{{ attribute protos, not implemented yet */ - -/* {{{ proto line_number long -readonly=yes -URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#DOMLocator-line-number -Since: -*/ -int dom_domlocator_line_number_read(dom_object *obj, zval **retval TSRMLS_DC) -{ - ALLOC_ZVAL(*retval); - ZVAL_STRING(*retval, "TEST", 1); - return SUCCESS; -} - -/* }}} */ - - - -/* {{{ proto column_number long -readonly=yes -URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#DOMLocator-column-number -Since: -*/ -int dom_domlocator_column_number_read(dom_object *obj, zval **retval TSRMLS_DC) -{ - ALLOC_ZVAL(*retval); - ZVAL_STRING(*retval, "TEST", 1); - return SUCCESS; -} - -/* }}} */ - - - -/* {{{ proto offset long -readonly=yes -URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#DOMLocator-offset -Since: -*/ -int dom_domlocator_offset_read(dom_object *obj, zval **retval TSRMLS_DC) -{ - ALLOC_ZVAL(*retval); - ZVAL_STRING(*retval, "TEST", 1); - return SUCCESS; -} - -/* }}} */ - - - -/* {{{ proto related_node node -readonly=yes -URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#DOMLocator-node -Since: -*/ -int dom_domlocator_related_node_read(dom_object *obj, zval **retval TSRMLS_DC) -{ - ALLOC_ZVAL(*retval); - ZVAL_STRING(*retval, "TEST", 1); - return SUCCESS; -} - -/* }}} */ - - - -/* {{{ proto uri string -readonly=yes -URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#DOMLocator-uri -Since: -*/ -int dom_domlocator_uri_read(dom_object *obj, zval **retval TSRMLS_DC) -{ - ALLOC_ZVAL(*retval); - ZVAL_STRING(*retval, "TEST", 1); - return SUCCESS; -} - -/* }}} */ - - -#endif diff --git a/ext/dom/domstringlist.c b/ext/dom/domstringlist.c deleted file mode 100644 index b75a7cc63c..0000000000 --- a/ext/dom/domstringlist.c +++ /dev/null @@ -1,71 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP Version 5 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2004 The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 3.0 of the PHP license, | - | that is bundled with this package in the file LICENSE, and is | - | available through the world-wide-web at the following url: | - | http://www.php.net/license/3_0.txt. | - | If you did not receive a copy of the PHP license and are unable to | - | obtain it through the world-wide-web, please send a note to | - | license@php.net so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - | Authors: Christian Stocker <chregu@php.net> | - | Rob Richards <rrichards@php.net> | - +----------------------------------------------------------------------+ -*/ - -/* $Id$ */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "php.h" -#if HAVE_LIBXML && HAVE_DOM -#include "php_dom.h" - - -/* -* class domstringlist -* -* URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#DOMStringList -* Since: DOM Level 3 -*/ - -zend_function_entry php_dom_domstringlist_class_functions[] = { - PHP_FALIAS(item, dom_domstringlist_item, NULL) - {NULL, NULL, NULL} -}; - -/* {{{ attribute protos, not implemented yet */ - -/* {{{ proto length unsigned long -readonly=yes -URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#DOMStringList-length -Since: -*/ -int dom_domstringlist_length_read(dom_object *obj, zval **retval TSRMLS_DC) -{ - ALLOC_ZVAL(*retval); - ZVAL_STRING(*retval, "TEST", 1); - return SUCCESS; -} - -/* }}} */ - - - - -/* {{{ proto domstring dom_domstringlist_item(unsigned long index); -URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#DOMStringList-item -Since: -*/ -PHP_FUNCTION(dom_domstringlist_item) -{ - DOM_NOT_IMPLEMENTED(); -} -/* }}} end dom_domstringlist_item */ -#endif diff --git a/ext/dom/element.c b/ext/dom/element.c deleted file mode 100644 index 545e58a90c..0000000000 --- a/ext/dom/element.c +++ /dev/null @@ -1,830 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP Version 5 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2004 The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 3.0 of the PHP license, | - | that is bundled with this package in the file LICENSE, and is | - | available through the world-wide-web at the following url: | - | http://www.php.net/license/3_0.txt. | - | If you did not receive a copy of the PHP license and are unable to | - | obtain it through the world-wide-web, please send a note to | - | license@php.net so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - | Authors: Christian Stocker <chregu@php.net> | - | Rob Richards <rrichards@php.net> | - +----------------------------------------------------------------------+ -*/ - -/* $Id$ */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "php.h" -#if HAVE_LIBXML && HAVE_DOM -#include "php_dom.h" - - -/* -* class domelement extends domnode -* -* URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-745549614 -* Since: -*/ - -zend_function_entry php_dom_element_class_functions[] = { - PHP_FALIAS(getAttribute, dom_element_get_attribute, NULL) - PHP_FALIAS(setAttribute, dom_element_set_attribute, NULL) - PHP_FALIAS(removeAttribute, dom_element_remove_attribute, NULL) - PHP_FALIAS(getAttributeNode, dom_element_get_attribute_node, NULL) - PHP_FALIAS(setAttributeNode, dom_element_set_attribute_node, NULL) - PHP_FALIAS(removeAttributeNode, dom_element_remove_attribute_node, NULL) - PHP_FALIAS(getElementsByTagName, dom_element_get_elements_by_tag_name, NULL) - PHP_FALIAS(getAttributeNS, dom_element_get_attribute_ns, NULL) - PHP_FALIAS(setAttributeNS, dom_element_set_attribute_ns, NULL) - PHP_FALIAS(removeAttributeNS, dom_element_remove_attribute_ns, NULL) - PHP_FALIAS(getAttributeNodeNS, dom_element_get_attribute_node_ns, NULL) - PHP_FALIAS(setAttributeNodeNS, dom_element_set_attribute_node_ns, NULL) - PHP_FALIAS(getElementsByTagNameNS, dom_element_get_elements_by_tag_name_ns, NULL) - PHP_FALIAS(hasAttribute, dom_element_has_attribute, NULL) - PHP_FALIAS(hasAttributeNS, dom_element_has_attribute_ns, NULL) - PHP_FALIAS(setIdAttribute, dom_element_set_id_attribute, NULL) - PHP_FALIAS(setIdAttributeNS, dom_element_set_id_attribute_ns, NULL) - PHP_FALIAS(setIdAttributeNode, dom_element_set_id_attribute_node, NULL) - PHP_FALIAS(domelement, dom_element_element, NULL) - {NULL, NULL, NULL} -}; - -/* {{{ proto domnode dom_element_element(string name, [string value]); */ -PHP_FUNCTION(dom_element_element) -{ - - zval *id; - xmlNodePtr nodep = NULL, oldnode = NULL; - dom_object *intern; - char *name, *value = NULL; - int name_len, value_len = 0; - - 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) { - return; - } - - if (name_len == 0) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Element name is required"); - RETURN_FALSE; - } - - nodep = xmlNewNode(NULL, (xmlChar *) name); - - if (!nodep) - RETURN_FALSE; - - if (value_len > 0) { - xmlNodeSetContentLen(nodep, value, value_len); - } - - intern = (dom_object *)zend_object_store_get_object(id TSRMLS_CC); - if (intern != NULL) { - oldnode = (xmlNodePtr)intern->ptr; - if (oldnode != NULL) { - php_libxml_node_free_resource(oldnode TSRMLS_CC); - } - php_libxml_increment_node_ptr((php_libxml_node_object *)intern, nodep, (void *)intern TSRMLS_CC); - } -} -/* }}} end dom_element_element */ - -/* {{{ proto tagName string -readonly=yes -URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-104682815 -Since: -*/ -int dom_element_tag_name_read(dom_object *obj, zval **retval TSRMLS_DC) -{ - xmlNodePtr nodep; - xmlNsPtr ns; - xmlChar *qname; - - nodep = dom_object_get_node(obj); - ALLOC_ZVAL(*retval); - ns = nodep->ns; - if (ns != NULL && ns->prefix) { - qname = xmlStrdup(ns->prefix); - qname = xmlStrcat(qname, ":"); - qname = xmlStrcat(qname, nodep->name); - ZVAL_STRING(*retval, qname, 1); - xmlFree(qname); - } else { - ZVAL_STRING(*retval, (char *) nodep->name, 1); - } - - return SUCCESS; -} - -/* }}} */ - - - -/* {{{ proto schemaTypeInfo typeinfo -readonly=yes -URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#Element-schemaTypeInfo -Since: DOM Level 3 -*/ -int dom_element_schema_type_info_read(dom_object *obj, zval **retval TSRMLS_DC) -{ - ALLOC_ZVAL(*retval); - ZVAL_NULL(*retval); - return SUCCESS; -} - -/* }}} */ - - - -/* {{{ proto domstring dom_element_get_attribute(string name); -URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-666EE0F9 -Since: -*/ -PHP_FUNCTION(dom_element_get_attribute) -{ - zval *id; - xmlNode *nodep; - char *name, *value; - dom_object *intern; - int name_len; - - - DOM_GET_THIS_OBJ(nodep, id, xmlNodePtr, intern); - - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &name, &name_len) == FAILURE) { - return; - } - - value = xmlGetProp(nodep, name); - if (value == NULL) { - RETURN_EMPTY_STRING(); - } else { - RETVAL_STRING(value, 1); - xmlFree(value); - } -} -/* }}} end dom_element_get_attribute */ - - -/* {{{ proto dom_void dom_element_set_attribute(string name, string value); -URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-F68F082 -Since: -*/ -PHP_FUNCTION(dom_element_set_attribute) -{ - zval *id, *rv = NULL; - xmlNode *nodep; - xmlAttr *attr; - int ret, name_len, value_len; - dom_object *intern; - char *name, *value; - - - DOM_GET_THIS_OBJ(nodep, id, xmlNodePtr, intern); - - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss", &name, &name_len, &value, &value_len) == FAILURE) { - return; - } - - if (dom_node_is_read_only(nodep) == SUCCESS) { - php_dom_throw_error(NO_MODIFICATION_ALLOWED_ERR, dom_get_strict_error(intern->document) TSRMLS_CC); - RETURN_FALSE; - } - - attr = xmlHasProp(nodep,name); - if (attr != NULL) { - node_list_unlink(attr->children TSRMLS_CC); - } - attr = xmlSetProp(nodep, name, value); - if (!attr) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "No such attribute '%s'", name); - RETURN_FALSE; - } - - DOM_RET_OBJ(rv, (xmlNodePtr) attr, &ret, intern); - -} -/* }}} end dom_element_set_attribute */ - - -/* {{{ proto dom_void dom_element_remove_attribute(string name); -URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-6D6AC0F9 -Since: -*/ -PHP_FUNCTION(dom_element_remove_attribute) -{ - zval *id; - xmlNode *nodep; - xmlAttr *attrp; - dom_object *intern; - int name_len; - char *name; - - DOM_GET_THIS_OBJ(nodep, id, xmlNodePtr, intern); - - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &name, &name_len) == FAILURE) { - return; - } - - if (dom_node_is_read_only(nodep) == SUCCESS) { - php_dom_throw_error(NO_MODIFICATION_ALLOWED_ERR, dom_get_strict_error(intern->document) TSRMLS_CC); - RETURN_FALSE; - } - - attrp = xmlHasProp(nodep,name); - if (attrp == NULL) { - 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); - } - - RETURN_TRUE; -} -/* }}} end dom_element_remove_attribute */ - - -/* {{{ proto domattr dom_element_get_attribute_node(string name); -URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-217A91B8 -Since: -*/ -PHP_FUNCTION(dom_element_get_attribute_node) -{ - zval *id, *rv = NULL; - xmlNode *nodep; - xmlAttr *attrp; - int name_len, ret; - dom_object *intern; - char *name; - - DOM_GET_THIS_OBJ(nodep, id, xmlNodePtr, intern); - - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &name, &name_len) == FAILURE) { - return; - } - - attrp = xmlHasProp(nodep,name); - if (attrp == NULL) { - RETURN_FALSE; - } - - DOM_RET_OBJ(rv, (xmlNodePtr) attrp, &ret, intern); -} -/* }}} end dom_element_get_attribute_node */ - - -/* {{{ proto domattr dom_element_set_attribute_node(attr newAttr); -URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-887236154 -Since: -*/ -PHP_FUNCTION(dom_element_set_attribute_node) -{ - zval *id, *node, *rv = NULL; - xmlNode *nodep; - xmlAttr *attrp, *existattrp = NULL; - dom_object *intern, *attrobj, *oldobj; - int ret; - - DOM_GET_THIS_OBJ(nodep, id, xmlNodePtr, intern); - - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o", &node) == FAILURE) { - return; - } - - if (dom_node_is_read_only(nodep) == SUCCESS) { - php_dom_throw_error(NO_MODIFICATION_ALLOWED_ERR, dom_get_strict_error(intern->document) TSRMLS_CC); - RETURN_FALSE; - } - - DOM_GET_OBJ(attrp, node, xmlAttrPtr, attrobj); - - if (attrp->type != XML_ATTRIBUTE_NODE) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Attribute node is required"); - RETURN_FALSE; - } - - existattrp = xmlHasProp(nodep, attrp->name); - if (existattrp != NULL) { - if ((oldobj = php_dom_object_get_data((xmlNodePtr) existattrp)) != NULL && - ((php_libxml_node_ptr *)oldobj->ptr)->node == (xmlNodePtr) attrp) - { - RETURN_NULL(); - } - xmlUnlinkNode((xmlNodePtr) existattrp); - } - - if (attrp->doc == NULL && nodep->doc != NULL) { - attrobj->document = intern->document; - php_libxml_increment_doc_ref((php_libxml_node_object *)attrobj, NULL TSRMLS_CC); - } - - xmlAddChild(nodep, (xmlNodePtr) attrp); - - /* Returns old property if removed otherwise NULL */ - if (existattrp != NULL) { - DOM_RET_OBJ(rv, (xmlNodePtr) existattrp, &ret, intern); - } else { - RETVAL_NULL(); - } - -} -/* }}} end dom_element_set_attribute_node */ - - -/* {{{ proto domattr dom_element_remove_attribute_node(attr oldAttr); -URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-D589198 -Since: -*/ -PHP_FUNCTION(dom_element_remove_attribute_node) -{ - zval *id, *node, *rv = NULL; - xmlNode *nodep; - xmlAttr *attrp; - dom_object *intern, *attrobj; - int ret; - - DOM_GET_THIS_OBJ(nodep, id, xmlNodePtr, intern); - - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o", &node) == FAILURE) { - return; - } - - if (dom_node_is_read_only(nodep) == SUCCESS) { - php_dom_throw_error(NO_MODIFICATION_ALLOWED_ERR, dom_get_strict_error(intern->document) TSRMLS_CC); - RETURN_FALSE; - } - - DOM_GET_OBJ(attrp, node, xmlAttrPtr, attrobj); - - if (attrp->type != XML_ATTRIBUTE_NODE || attrp->parent != nodep) { - php_dom_throw_error(NOT_FOUND_ERR, dom_get_strict_error(intern->document) TSRMLS_CC); - RETURN_FALSE; - } - - xmlUnlinkNode((xmlNodePtr) attrp); - - DOM_RET_OBJ(rv, (xmlNodePtr) attrp, &ret, intern); - -} -/* }}} end dom_element_remove_attribute_node */ - - -/* {{{ proto domnodelist dom_element_get_elements_by_tag_name(string name); -URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-1938918D -Since: -*/ -PHP_FUNCTION(dom_element_get_elements_by_tag_name) -{ - zval *id; - xmlNodePtr elemp; - int name_len; - dom_object *intern, *namednode; - char *name; - xmlChar *local; - - DOM_GET_THIS_OBJ(elemp, id, xmlNodePtr, intern); - - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &name, &name_len) == FAILURE) { - return; - } - - php_dom_create_interator(return_value, DOM_NODELIST TSRMLS_CC); - namednode = (dom_object *)zend_objects_get_address(return_value TSRMLS_CC); - local = xmlCharStrndup(name, name_len); - dom_namednode_iter(intern, 0, namednode, NULL, local, NULL); -} -/* }}} end dom_element_get_elements_by_tag_name */ - - -/* {{{ proto domstring dom_element_get_attribute_ns(string namespaceURI, string localName); -URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-ElGetAttrNS -Since: DOM Level 2 -*/ -PHP_FUNCTION(dom_element_get_attribute_ns) -{ - zval *id; - xmlNodePtr elemp; - xmlNsPtr nsptr; - dom_object *intern; - int uri_len = 0, name_len = 0; - char *uri, *name, *strattr; - - DOM_GET_THIS_OBJ(elemp, id, xmlNodePtr, intern); - - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss", &uri, &uri_len, &name, &name_len) == FAILURE) { - return; - } - strattr = xmlGetNsProp(elemp, name, uri); - - if (strattr != NULL) { - RETVAL_STRING(strattr, 1); - xmlFree(strattr); - } else { - if (xmlStrEqual(uri, DOM_XMLNS_NAMESPACE)) { - nsptr = dom_get_nsdecl(elemp, name); - if (nsptr != NULL) { - RETVAL_STRING((char *) nsptr->href, 1); - } else { - RETVAL_EMPTY_STRING(); - } - } else { - RETVAL_EMPTY_STRING(); - } - } - -} -/* }}} end dom_element_get_attribute_ns */ - - -/* {{{ proto dom_void dom_element_set_attribute_ns(string namespaceURI, string qualifiedName, string value); -URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-ElSetAttrNS -Since: DOM Level 2 -*/ -PHP_FUNCTION(dom_element_set_attribute_ns) -{ - zval *id; - xmlNodePtr elemp, nodep = NULL; - xmlNsPtr nsptr; - xmlAttr *attr; - int uri_len = 0, name_len = 0, value_len = 0; - char *uri, *name, *value; - char *localname = NULL, *prefix = NULL; - dom_object *intern; - int errorcode = 0, stricterror, is_xmlns = 0; - - DOM_GET_THIS_OBJ(elemp, id, xmlNodePtr, intern); - - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s!ss", &uri, &uri_len, &name, &name_len, &value, &value_len) == FAILURE) { - return; - } - - stricterror = dom_get_strict_error(intern->document); - - if (dom_node_is_read_only(elemp) == SUCCESS) { - php_dom_throw_error(NO_MODIFICATION_ALLOWED_ERR, stricterror TSRMLS_CC); - RETURN_NULL(); - } - - errorcode = dom_check_qname(name, &localname, &prefix, uri_len, name_len); - - if (errorcode == 0) { - if (uri_len > 0) { - nodep = (xmlNodePtr) xmlHasNsProp(elemp, localname, uri); - if (nodep != NULL) { - node_list_unlink(nodep->children TSRMLS_CC); - } - - if (xmlStrEqual(prefix,"xmlns") && xmlStrEqual(uri, DOM_XMLNS_NAMESPACE)) { - is_xmlns = 1; - nsptr = dom_get_nsdecl(elemp, localname); - } else { - nsptr = xmlSearchNsByHref(elemp->doc, elemp, uri); - while (nsptr && nsptr->prefix == NULL) { - nsptr = nsptr->next; - } - } - - if (nsptr == NULL) { - if (prefix == NULL) { - errorcode = NAMESPACE_ERR; - } else { - if (is_xmlns == 1) { - xmlNewNs(elemp, value, localname); - } else { - nsptr = dom_get_ns(elemp, uri, &errorcode, prefix); - } - } - } else { - if (is_xmlns == 1) { - if (nsptr->href) { - xmlFree((xmlChar *) nsptr->href); - } - nsptr->href = xmlStrdup(value); - } - } - - if (errorcode == 0 && is_xmlns == 0) { - attr = xmlSetNsProp(elemp, nsptr, localname, value); - } - } else { - attr = xmlHasProp(elemp, localname); - if (attr != NULL) { - node_list_unlink(attr->children TSRMLS_CC); - } - attr = xmlSetProp(elemp, localname, value); - } - } - - xmlFree(localname); - if (prefix != NULL) { - xmlFree(prefix); - } - - if (errorcode != 0) { - php_dom_throw_error(errorcode, stricterror TSRMLS_CC); - } - - RETURN_NULL(); -} -/* }}} end dom_element_set_attribute_ns */ - - -/* {{{ proto dom_void dom_element_remove_attribute_ns(string namespaceURI, string localName); -URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-ElRemAtNS -Since: DOM Level 2 -*/ -PHP_FUNCTION(dom_element_remove_attribute_ns) -{ - zval *id; - xmlNode *nodep; - xmlAttr *attrp; - xmlNsPtr nsptr; - dom_object *intern; - int name_len, uri_len; - char *name, *uri; - - DOM_GET_THIS_OBJ(nodep, id, xmlNodePtr, intern); - - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss", &uri, &uri_len, &name, &name_len) == FAILURE) { - return; - } - - if (dom_node_is_read_only(nodep) == SUCCESS) { - php_dom_throw_error(NO_MODIFICATION_ALLOWED_ERR, dom_get_strict_error(intern->document) TSRMLS_CC); - RETURN_NULL(); - } - - attrp = xmlHasNsProp(nodep, name, uri); - - nsptr = dom_get_nsdecl(nodep, name); - if (nsptr != NULL) { - if (xmlStrEqual(uri, nsptr->href)) { - if (nsptr->href != NULL) { - xmlFree((char *) nsptr->href); - nsptr->href = NULL; - } - if (nsptr->prefix != NULL) { - xmlFree((char *) nsptr->prefix); - nsptr->prefix = NULL; - } - } else { - RETURN_NULL(); - } - } - - if (attrp) { - 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_NULL(); -} -/* }}} end dom_element_remove_attribute_ns */ - - -/* {{{ proto domattr dom_element_get_attribute_node_ns(string namespaceURI, string localName); -URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-ElGetAtNodeNS -Since: DOM Level 2 -*/ -PHP_FUNCTION(dom_element_get_attribute_node_ns) -{ - zval *id, *rv = NULL; - xmlNodePtr elemp; - xmlAttrPtr attrp; - dom_object *intern; - int uri_len, name_len, ret; - char *uri, *name; - - DOM_GET_THIS_OBJ(elemp, id, xmlNodePtr, intern); - - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss", &uri, &uri_len, &name, &name_len) == FAILURE) { - return; - } - - attrp = xmlHasNsProp(elemp, name, uri); - - if (attrp == NULL) { - RETURN_NULL(); - } - - DOM_RET_OBJ(rv, (xmlNodePtr) attrp, &ret, intern); - -} -/* }}} end dom_element_get_attribute_node_ns */ - - -/* {{{ proto domattr dom_element_set_attribute_node_ns(attr newAttr); -URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-ElSetAtNodeNS -Since: DOM Level 2 -*/ -PHP_FUNCTION(dom_element_set_attribute_node_ns) -{ - zval *id, *node, *rv = NULL; - xmlNode *nodep; - xmlNs *nsp; - xmlAttr *attrp, *existattrp = NULL; - dom_object *intern, *attrobj, *oldobj; - int ret; - - DOM_GET_THIS_OBJ(nodep, id, xmlNodePtr, intern); - - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o", &node) == FAILURE) { - return; - } - - if (dom_node_is_read_only(nodep) == SUCCESS) { - php_dom_throw_error(NO_MODIFICATION_ALLOWED_ERR, dom_get_strict_error(intern->document) TSRMLS_CC); - RETURN_FALSE; - } - - DOM_GET_OBJ(attrp, node, xmlAttrPtr, attrobj); - - if (attrp->type != XML_ATTRIBUTE_NODE) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Attribute node is required"); - RETURN_FALSE; - } - - nsp = attrp->ns; - if (nsp != NULL) { - existattrp = xmlHasNsProp(nodep, nsp->href, attrp->name); - } else { - existattrp = xmlHasProp(nodep, attrp->name); - } - - if (existattrp != NULL) { - if ((oldobj = php_dom_object_get_data((xmlNodePtr) existattrp)) != NULL && - ((php_libxml_node_ptr *)oldobj->ptr)->node == (xmlNodePtr) attrp) - { - RETURN_NULL(); - } - xmlUnlinkNode((xmlNodePtr) existattrp); - } - - if (attrp->doc == NULL && nodep->doc != NULL) { - attrobj->document = intern->document; - php_libxml_increment_doc_ref((php_libxml_node_object *)attrobj, NULL TSRMLS_CC); - } - - xmlAddChild(nodep, (xmlNodePtr) attrp); - - /* Returns old property if removed otherwise NULL */ - if (existattrp != NULL) { - DOM_RET_OBJ(rv, (xmlNodePtr) existattrp, &ret, intern); - } else { - RETVAL_NULL(); - } - -} -/* }}} end dom_element_set_attribute_node_ns */ - - - -/* {{{ proto domnodelist dom_element_get_elements_by_tag_name_ns(string namespaceURI, string localName); -URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-A6C90942 -Since: DOM Level 2 -*/ -PHP_FUNCTION(dom_element_get_elements_by_tag_name_ns) -{ - zval *id; - xmlNodePtr elemp; - int uri_len, name_len; - dom_object *intern, *namednode; - char *uri, *name; - xmlChar *local, *nsuri; -// xmlHashTable *ht; - - DOM_GET_THIS_OBJ(elemp, id, xmlNodePtr, intern); - - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss", &uri, &uri_len, &name, &name_len) == FAILURE) { - return; - } - - php_dom_create_interator(return_value, DOM_NODELIST TSRMLS_CC); - namednode = (dom_object *)zend_objects_get_address(return_value TSRMLS_CC); - local = xmlCharStrndup(name, name_len); - nsuri = xmlCharStrndup(uri, uri_len); - dom_namednode_iter(intern, 0, namednode, NULL, local, nsuri); - -} -/* }}} end dom_element_get_elements_by_tag_name_ns */ - - -/* {{{ proto boolean dom_element_has_attribute(string name); -URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-ElHasAttr -Since: DOM Level 2 -*/ -PHP_FUNCTION(dom_element_has_attribute) -{ - zval *id; - xmlNode *nodep; - dom_object *intern; - char *name, *value; - int name_len; - - DOM_GET_THIS_OBJ(nodep, id, xmlNodePtr, intern); - - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &name, &name_len) == FAILURE) { - return; - } - - value = xmlGetProp(nodep, name); - if (value == NULL) { - RETURN_FALSE; - } else { - xmlFree(value); - RETURN_TRUE; - } -} -/* }}} end dom_element_has_attribute */ - - -/* {{{ proto boolean dom_element_has_attribute_ns(string namespaceURI, string localName); -URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-ElHasAttrNS -Since: DOM Level 2 -*/ -PHP_FUNCTION(dom_element_has_attribute_ns) -{ - zval *id; - xmlNodePtr elemp; - xmlNs *nsp; - dom_object *intern; - int uri_len, name_len; - char *uri, *name, *value; - - DOM_GET_THIS_OBJ(elemp, id, xmlNodePtr, intern); - - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss", &uri, &uri_len, &name, &name_len) == FAILURE) { - return; - } - - value = xmlGetNsProp(elemp, name, uri); - - if (value != NULL) { - xmlFree(value); - RETURN_TRUE; - } else { - if (xmlStrEqual(uri, DOM_XMLNS_NAMESPACE)) { - nsp = dom_get_nsdecl(elemp, name); - if (nsp != NULL) { - RETURN_TRUE; - } - } - } - - RETURN_FALSE; -} -/* }}} end dom_element_has_attribute_ns */ - - -/* {{{ proto dom_void dom_element_set_id_attribute(string name, boolean isId); -URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-ElSetIdAttr -Since: DOM Level 3 -*/ -PHP_FUNCTION(dom_element_set_id_attribute) -{ - DOM_NOT_IMPLEMENTED(); -} -/* }}} end dom_element_set_id_attribute */ - - -/* {{{ proto dom_void dom_element_set_id_attribute_ns(string namespaceURI, string localName, boolean isId); -URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-ElSetIdAttrNS -Since: DOM Level 3 -*/ -PHP_FUNCTION(dom_element_set_id_attribute_ns) -{ - DOM_NOT_IMPLEMENTED(); -} -/* }}} end dom_element_set_id_attribute_ns */ - - -/* {{{ proto dom_void dom_element_set_id_attribute_node(attr idAttr, boolean isId); -URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-ElSetIdAttrNode -Since: DOM Level 3 -*/ -PHP_FUNCTION(dom_element_set_id_attribute_node) -{ - DOM_NOT_IMPLEMENTED(); -} -/* }}} end dom_element_set_id_attribute_node */ - -#endif diff --git a/ext/dom/entity.c b/ext/dom/entity.c deleted file mode 100644 index c8327808cd..0000000000 --- a/ext/dom/entity.c +++ /dev/null @@ -1,183 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP Version 5 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2004 The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 3.0 of the PHP license, | - | that is bundled with this package in the file LICENSE, and is | - | available through the world-wide-web at the following url: | - | http://www.php.net/license/3_0.txt. | - | If you did not receive a copy of the PHP license and are unable to | - | obtain it through the world-wide-web, please send a note to | - | license@php.net so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - | Authors: Christian Stocker <chregu@php.net> | - | Rob Richards <rrichards@php.net> | - +----------------------------------------------------------------------+ -*/ - -/* $Id$ */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "php.h" -#if HAVE_LIBXML && HAVE_DOM -#include "php_dom.h" - - -/* -* class domentity extends domnode -* -* URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#ID-527DCFF2 -* Since: -*/ - -zend_function_entry php_dom_entity_class_functions[] = { - {NULL, NULL, NULL} -}; - -/* {{{ attribute protos, not implemented yet */ - -/* {{{ proto public_id string -readonly=yes -URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#ID-D7303025 -Since: -*/ -int dom_entity_public_id_read(dom_object *obj, zval **retval TSRMLS_DC) -{ - xmlEntity *nodep; - - nodep = (xmlEntity *) dom_object_get_node(obj); - - ALLOC_ZVAL(*retval); - if (nodep->etype != XML_EXTERNAL_GENERAL_UNPARSED_ENTITY) { - ZVAL_NULL(*retval); - } else { - ZVAL_STRING(*retval, (char *) (nodep->ExternalID), 1); - } - - return SUCCESS; -} - -/* }}} */ - - - -/* {{{ proto system_id string -readonly=yes -URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#ID-D7C29F3E -Since: -*/ -int dom_entity_system_id_read(dom_object *obj, zval **retval TSRMLS_DC) -{ - xmlEntity *nodep; - - nodep = (xmlEntity *) dom_object_get_node(obj); - - ALLOC_ZVAL(*retval); - if (nodep->etype != XML_EXTERNAL_GENERAL_UNPARSED_ENTITY) { - ZVAL_NULL(*retval); - } else { - ZVAL_STRING(*retval, (char *) (nodep->SystemID), 1); - } - - return SUCCESS; -} - -/* }}} */ - - - -/* {{{ proto notation_name string -readonly=yes -URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#ID-6ABAEB38 -Since: -*/ -int dom_entity_notation_name_read(dom_object *obj, zval **retval TSRMLS_DC) -{ - xmlEntity *nodep; - char *content; - - nodep = (xmlEntity *) dom_object_get_node(obj); - - ALLOC_ZVAL(*retval); - if (nodep->etype != XML_EXTERNAL_GENERAL_UNPARSED_ENTITY) { - ZVAL_NULL(*retval); - } else { - content = xmlNodeGetContent((xmlNodePtr) nodep); - ZVAL_STRING(*retval, content, 1); - xmlFree(content); - } - - return SUCCESS; -} - -/* }}} */ - - - -/* {{{ proto actual_encoding string -readonly=no -URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#Entity3-actualEncoding -Since: DOM Level 3 -*/ -int dom_entity_actual_encoding_read(dom_object *obj, zval **retval TSRMLS_DC) -{ - ALLOC_ZVAL(*retval); - ZVAL_NULL(*retval); - return SUCCESS; -} - -int dom_entity_actual_encoding_write(dom_object *obj, zval *newval TSRMLS_DC) -{ - return SUCCESS; -} - -/* }}} */ - - - -/* {{{ proto encoding string -readonly=no -URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#Entity3-encoding -Since: DOM Level 3 -*/ -int dom_entity_encoding_read(dom_object *obj, zval **retval TSRMLS_DC) -{ - ALLOC_ZVAL(*retval); - ZVAL_NULL(*retval); - return SUCCESS; -} - -int dom_entity_encoding_write(dom_object *obj, zval *newval TSRMLS_DC) -{ - return SUCCESS; -} - -/* }}} */ - - - -/* {{{ proto version string -readonly=no -URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#Entity3-version -Since: DOM Level 3 -*/ -int dom_entity_version_read(dom_object *obj, zval **retval TSRMLS_DC) -{ - ALLOC_ZVAL(*retval); - ZVAL_NULL(*retval); - return SUCCESS; -} - -int dom_entity_version_write(dom_object *obj, zval *newval TSRMLS_DC) -{ - return SUCCESS; -} - -/* }}} */ - -#endif diff --git a/ext/dom/entityreference.c b/ext/dom/entityreference.c deleted file mode 100644 index 9d8039f577..0000000000 --- a/ext/dom/entityreference.c +++ /dev/null @@ -1,78 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP Version 5 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2004 The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 3.0 of the PHP license, | - | that is bundled with this package in the file LICENSE, and is | - | available through the world-wide-web at the following url: | - | http://www.php.net/license/3_0.txt. | - | If you did not receive a copy of the PHP license and are unable to | - | obtain it through the world-wide-web, please send a note to | - | license@php.net so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - | Authors: Christian Stocker <chregu@php.net> | - | Rob Richards <rrichards@php.net> | - +----------------------------------------------------------------------+ -*/ - -/* $Id$ */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "php.h" -#if HAVE_LIBXML && HAVE_DOM -#include "php_dom.h" - - -/* -* class domentityreference extends domnode -* -* URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#ID-11C98490 -* Since: -*/ - -zend_function_entry php_dom_entityreference_class_functions[] = { - PHP_FALIAS(domentityreference, dom_entityreference_entityreference, NULL) - {NULL, NULL, NULL} -}; - -/* {{{ proto domnode dom_entityreference_entityreference(string name); */ -PHP_FUNCTION(dom_entityreference_entityreference) -{ - zval *id; - xmlNode *node; - xmlNodePtr oldnode = NULL; - dom_object *intern; - char *name; - int name_len; - - if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os", &id, dom_entityreference_class_entry, &name, &name_len) == FAILURE) { - return; - } - - if (name_len == 0) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Entity Reference name is required"); - RETURN_FALSE; - } - - node = xmlNewReference(NULL, name); - - if (!node) - RETURN_FALSE; - - intern = (dom_object *)zend_object_store_get_object(id TSRMLS_CC); - if (intern != NULL) { - oldnode = (xmlNodePtr)intern->ptr; - if (oldnode != NULL) { - php_libxml_node_free_resource(oldnode TSRMLS_CC); - } - php_libxml_increment_node_ptr((php_libxml_node_object *)intern, node, (void *)intern TSRMLS_CC); - } -} - -/* }}} end dom_entityreference_entityreference */ -#endif diff --git a/ext/dom/examples/dom1.inc b/ext/dom/examples/dom1.inc deleted file mode 100644 index 792d6f2dbc..0000000000 --- a/ext/dom/examples/dom1.inc +++ /dev/null @@ -1,43 +0,0 @@ -<?PHP -$xmlstr = "<?xml version='1.0' standalone='yes'?> -<!DOCTYPE chapter SYSTEM '/share/sgml/Norman_Walsh/db3xml10/db3xml10.dtd' -[ <!ENTITY sp \"spanish\"> -]> -<!-- lsfj --> -<chapter language='en'><title language='en'>Title</title> -<para language='ge'> -&sp; -<!-- comment --> -<informaltable language='&sp;kkk'> -<tgroup cols='3'> -<tbody> -<row><entry>a1</entry><entry morerows='1'>b1</entry><entry>c1</entry></row> -<row><entry>a2</entry><entry>c2</entry></row> -<row><entry>a3</entry><entry>b3</entry><entry>c3</entry></row> -</tbody> -</tgroup> -</informaltable> -</para> -</chapter> "; - -function print_node($node) -{ - print "Node Name: " . $node->nodeName; - print "\nNode Type: " . $node->nodeType; - $child_count = $node->childNodes->length; - print "\nNum Children: " . $child_count; - if($child_count <= 1){ - print "\nNode Content: " . $node->nodeValue; - } - print "\n\n"; -} - -function print_node_list($nodelist) -{ - foreach($nodelist as $node) - { - print_node($node); - } -} - -?> diff --git a/ext/dom/examples/dom1.php b/ext/dom/examples/dom1.php deleted file mode 100644 index 8ea367458d..0000000000 --- a/ext/dom/examples/dom1.php +++ /dev/null @@ -1,94 +0,0 @@ -<?php -require_once("dom1.inc"); - -echo "Test 1: accessing single nodes from php\n"; -$dom = new domDocument; -$dom->loadxml($xmlstr); -if(!$dom) { - echo "Error while parsing the document\n"; - exit; -} - -// children() of of document would result in a memleak -//$children = $dom->children(); -//print_node_list($children); - -echo "--------- root\n"; -$rootnode = $dom->documentElement; -print_node($rootnode); - -echo "--------- children of root\n"; -$children = $rootnode->childNodes; -print_node_list($children); - -// The last node should be identical with the last entry in the children array -echo "--------- last\n"; -$last = $rootnode->lastChild; -print_node($last); - -// The parent of this last node is the root again -echo "--------- parent\n"; -$parent = $last->parentNode; -print_node($parent); - -// The children of this parent are the same children as one above -echo "--------- children of parent\n"; -$children = $parent->childNodes; -print_node_list($children); - -echo "--------- creating a new attribute\n"; -//This is worthless -//$attr = $dom->createAttribute("src", "picture.gif"); -//print_r($attr); - -//$rootnode->set_attributeNode($attr); -$attr = $rootnode->setAttribute("src", "picture.gif"); -$attr = $rootnode->getAttribute("src"); -print_r($attr); -print "\n"; - -echo "--------- Get Attribute Node\n"; -$attr = $rootnode->getAttributeNode("src"); -print_node($attr); - -echo "--------- Remove Attribute Node\n"; -$attr = $rootnode->removeAttribute("src"); -print "Removed " . $attr . " attributes.\n"; - -echo "--------- attributes of rootnode\n"; -$attrs = $rootnode->attributes; -print_node_list($attrs); - -echo "--------- children of an attribute\n"; -$children = $attrs->item(0)->childNodes; -print_node_list($children); - -echo "--------- Add child to root\n"; -$myelement = new domElement("Silly", "Symphony"); -$newchild = $rootnode->appendChild($myelement); -print_node($newchild); -print $dom->saveXML(); -print "\n"; - -echo "--------- Find element by tagname\n"; -echo " Using dom\n"; -$children = $dom->getElementsByTagname("Silly"); -print_node_list($children); - -echo " Using elem\n"; -$children = $rootnode->getElementsByTagName("Silly"); -print_node_list($children); - -echo "--------- Unlink Node\n"; -print_node($children->item(0)); -$rootnode->removeChild($children->item(0)); -print_node_list($rootnode->childNodes); -print $dom->savexml(); - -echo "--------- Find element by id\n"; -print ("Not implemented\n"); - -echo "--------- Check various node_name return values\n"; -print ("Not needed\n"); - -?> diff --git a/ext/dom/examples/note-invalid.xml b/ext/dom/examples/note-invalid.xml deleted file mode 100644 index 58d4e65044..0000000000 --- a/ext/dom/examples/note-invalid.xml +++ /dev/null @@ -1,9 +0,0 @@ -<?xml version="1.0"?> -<!DOCTYPE note SYSTEM "note.dtd"> -<note> -<to>PHP User Group</to> -<from>Shane</from> -<heading>Reminder</heading> -<body>Don't forget the meeting tonight!</body> -<footer>Or I'll clobber you!</footer> -</note> diff --git a/ext/dom/examples/note.dtd b/ext/dom/examples/note.dtd deleted file mode 100644 index 4016eb5811..0000000000 --- a/ext/dom/examples/note.dtd +++ /dev/null @@ -1,6 +0,0 @@ -<?xml version="1.0" ?> -<!ELEMENT note (to,from,heading,body)> -<!ELEMENT to (#PCDATA)> -<!ELEMENT from (#PCDATA)> -<!ELEMENT heading (#PCDATA)> -<!ELEMENT body (#PCDATA)>
\ No newline at end of file diff --git a/ext/dom/examples/note.php b/ext/dom/examples/note.php deleted file mode 100644 index a8695f3664..0000000000 --- a/ext/dom/examples/note.php +++ /dev/null @@ -1,19 +0,0 @@ -<?php - -$dom = new domDocument; -$dom->load('note.xml'); -if (!$dom->validate('note.dtd')) { - print "Document note.dtd is not valid\n"; -} else { - print "Document note.dtd is valid\n"; -} - -$dom = new domDocument; -$dom->load('note-invalid.xml'); -if (!$dom->validate('note.dtd')) { - print "Document note-invalid.xml is not valid\n"; -} else { - print "Document note-invalid.xml is valid\n"; -} - -?> diff --git a/ext/dom/examples/note.xml b/ext/dom/examples/note.xml deleted file mode 100644 index 49614a1b52..0000000000 --- a/ext/dom/examples/note.xml +++ /dev/null @@ -1,8 +0,0 @@ -<?xml version="1.0"?> -<!DOCTYPE note SYSTEM "note.dtd"> -<note> -<to>PHP User Group</to> -<from>Shane</from> -<heading>Reminder</heading> -<body>Don't forget the meeting tonight!</body> -</note> diff --git a/ext/dom/examples/relaxNG.php b/ext/dom/examples/relaxNG.php deleted file mode 100644 index d265fd988e..0000000000 --- a/ext/dom/examples/relaxNG.php +++ /dev/null @@ -1,11 +0,0 @@ -<?php - -$dom = new domDocument; -$dom->load('relaxNG.xml'); -if (!$dom->relaxNGValidate('relaxNG.rng')) { - print "Document is not valid"; -} else { - print "Document is valid"; -} - -?>
\ No newline at end of file diff --git a/ext/dom/examples/relaxNG.rng b/ext/dom/examples/relaxNG.rng deleted file mode 100644 index f4357e04ef..0000000000 --- a/ext/dom/examples/relaxNG.rng +++ /dev/null @@ -1,11 +0,0 @@ -<?xml version="1.0" encoding="iso-8859-1"?> -<grammar xmlns="http://relaxng.org/ns/structure/1.0" - datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes"> - -<include href="relaxNG2.rng"> -<define name="TEI.prose"><ref name="INCLUDE"/></define> -</include> -</grammar> - - - diff --git a/ext/dom/examples/relaxNG.xml b/ext/dom/examples/relaxNG.xml deleted file mode 100644 index 6b0cac1225..0000000000 --- a/ext/dom/examples/relaxNG.xml +++ /dev/null @@ -1 +0,0 @@ -<TEI.2>hello</TEI.2>
\ No newline at end of file diff --git a/ext/dom/examples/relaxNG2.rng b/ext/dom/examples/relaxNG2.rng deleted file mode 100644 index 4adae7b151..0000000000 --- a/ext/dom/examples/relaxNG2.rng +++ /dev/null @@ -1,23 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<grammar xmlns="http://relaxng.org/ns/structure/1.0" xmlns:t="http://www.thaiopensource.com/ns/annotations" xmlns:a="http://relaxng.org/ns/compatibility/annotations/1.0" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes"> - - <start> - <ref name="TEI.2"/> - </start> - <define name="IGNORE"> - <notAllowed/> - </define> - <define name="INCLUDE"> - <empty/> - </define> - - - <include href="relaxNG3.rng"/> - - <define name="TEI.2"> - <element name="TEI.2"> - <text/> - </element> - </define> - -</grammar>
\ No newline at end of file diff --git a/ext/dom/examples/relaxNG3.rng b/ext/dom/examples/relaxNG3.rng deleted file mode 100644 index 73e1eb6165..0000000000 --- a/ext/dom/examples/relaxNG3.rng +++ /dev/null @@ -1,8 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<grammar xmlns="http://relaxng.org/ns/structure/1.0" xmlns:t="http://www.thaiopensource.com/ns/annotations" xmlns:a="http://relaxng.org/ns/compatibility/annotations/1.0" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes"> - - <define name="TEI.prose" combine="interleave"> - <ref name="IGNORE"/> - </define> - -</grammar>
\ No newline at end of file diff --git a/ext/dom/examples/shipping.php b/ext/dom/examples/shipping.php deleted file mode 100644 index 5205fd2014..0000000000 --- a/ext/dom/examples/shipping.php +++ /dev/null @@ -1,11 +0,0 @@ -<?php - -$dom = new domDocument; -$dom->load('shipping.xml'); -if (!$dom->schemaValidate('shipping.xsd')) { - print "Document is not valid"; -} else { - print "Document is valid"; -} - -?>
\ No newline at end of file diff --git a/ext/dom/examples/shipping.xml b/ext/dom/examples/shipping.xml deleted file mode 100644 index dc8a09e301..0000000000 --- a/ext/dom/examples/shipping.xml +++ /dev/null @@ -1,21 +0,0 @@ -<?xml version="1.0"?> -<shipOrder> - <shipTo> - <name>Tove Svendson</name> - <street>Ragnhildvei 2</street> - <address>4000 Stavanger</address> - <country>Norway</country> - </shipTo> - <items> - <item> - <title>Empire Burlesque</title> - <quantity>1</quantity> - <price>10.90</price> - </item> - <item> - <title>Hide your heart</title> - <quantity>1</quantity> - <price>9.90</price> - </item> - </items> -</shipOrder>
\ No newline at end of file diff --git a/ext/dom/examples/shipping.xsd b/ext/dom/examples/shipping.xsd deleted file mode 100644 index 8b16b7c03a..0000000000 --- a/ext/dom/examples/shipping.xsd +++ /dev/null @@ -1,36 +0,0 @@ -<?xml version="1.0"?> -<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"> - - <xsd:element name="shipOrder" type="order"/> - - <xsd:complexType name="order"> - <xsd:all> - <xsd:element name="shipTo" type="shipAddress"/> - <xsd:element name="items" type="cdItems"/> - </xsd:all> - </xsd:complexType> - - <xsd:complexType name="shipAddress"> - <xsd:all> - <xsd:element name="name" type="xsd:string"/> - <xsd:element name="street" type="xsd:string"/> - <xsd:element name="address" type="xsd:string"/> - <xsd:element name="country" type="xsd:string"/> - </xsd:all> - </xsd:complexType> - - <xsd:complexType name="cdItems"> - <xsd:sequence> - <xsd:element name="item" type="cdItem" maxOccurs="unbounded" minOccurs="1"/> - </xsd:sequence> - </xsd:complexType> - - <xsd:complexType name="cdItem"> - <xsd:all> - <xsd:element name="title" type="xsd:string"/> - <xsd:element name="quantity" type="xsd:positiveInteger"/> - <xsd:element name="price" type="xsd:decimal"/> - </xsd:all> - </xsd:complexType> - -</xsd:schema>
\ No newline at end of file diff --git a/ext/dom/namednodemap.c b/ext/dom/namednodemap.c deleted file mode 100644 index 877845fbcf..0000000000 --- a/ext/dom/namednodemap.c +++ /dev/null @@ -1,278 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP Version 5 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2004 The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 3.0 of the PHP license, | - | that is bundled with this package in the file LICENSE, and is | - | available through the world-wide-web at the following url: | - | http://www.php.net/license/3_0.txt. | - | If you did not receive a copy of the PHP license and are unable to | - | obtain it through the world-wide-web, please send a note to | - | license@php.net so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - | Authors: Christian Stocker <chregu@php.net> | - | Rob Richards <rrichards@php.net> | - +----------------------------------------------------------------------+ -*/ - -/* $Id$ */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "php.h" -#if HAVE_LIBXML && HAVE_DOM -#include "php_dom.h" - - -/* -* class domnamednodemap -* -* URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-1780488922 -* Since: -*/ - -zend_function_entry php_dom_namednodemap_class_functions[] = { - PHP_FALIAS(getNamedItem, dom_namednodemap_get_named_item, NULL) - PHP_FALIAS(setNamedItem, dom_namednodemap_set_named_item, NULL) - PHP_FALIAS(removeNamedItem, dom_namednodemap_remove_named_item, NULL) - PHP_FALIAS(item, dom_namednodemap_item, NULL) - PHP_FALIAS(getNamedItemNS, dom_namednodemap_get_named_item_ns, NULL) - PHP_FALIAS(setNamedItemNS, dom_namednodemap_set_named_item_ns, NULL) - PHP_FALIAS(removeNamedItemNS, dom_namednodemap_remove_named_item_ns, NULL) - {NULL, NULL, NULL} -}; - -/* {{{ attribute protos, not implemented yet */ - -/* {{{ proto length unsigned long -readonly=yes -URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-6D0FB19E -Since: -*/ -int dom_namednodemap_length_read(dom_object *obj, zval **retval TSRMLS_DC) -{ - dom_nnodemap_object *objmap; - xmlAttrPtr curnode; - xmlNodePtr nodep; - int count = 0; - - objmap = (dom_nnodemap_object *)obj->ptr; - if (objmap->ht) { - count = xmlHashSize(objmap->ht); - } else { - nodep = dom_object_get_node(objmap->baseobj); - if (nodep) { - curnode = nodep->properties; - if (curnode) { - count++; - while (curnode->next != NULL) { - count++; - curnode = curnode->next; - } - } - } - } - - MAKE_STD_ZVAL(*retval); - ZVAL_LONG(*retval, count); - return SUCCESS; -} - -/* }}} */ - - - - -/* {{{ proto domnode dom_namednodemap_get_named_item(string name); -URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-1074577549 -Since: -*/ -PHP_FUNCTION(dom_namednodemap_get_named_item) -{ - zval *id, *rv = NULL; - int ret, namedlen=0; - dom_object *intern; - xmlNodePtr itemnode = NULL; - char *named; - - dom_nnodemap_object *objmap; - xmlNodePtr nodep; - xmlNotation *notep = NULL; - - if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os", &id, dom_namednodemap_class_entry, &named, &namedlen) == FAILURE) { - return; - } - - intern = (dom_object *)zend_object_store_get_object(id TSRMLS_CC); - - objmap = (dom_nnodemap_object *)intern->ptr; - if (objmap->ht) { - if (objmap->nodetype == XML_ENTITY_NODE) { - itemnode = (xmlNodePtr)xmlHashLookup(objmap->ht, named); - } else { - notep = (xmlNotation *)xmlHashLookup(objmap->ht, named); - itemnode = create_notation(notep->name, notep->PublicID, notep->SystemID); - } - } else { - nodep = dom_object_get_node(objmap->baseobj); - if (nodep) { - itemnode = (xmlNodePtr)xmlHasProp(nodep, named); - } - } - - if (itemnode) { - DOM_RET_OBJ(rv, itemnode, &ret, objmap->baseobj); - } else { - RETVAL_NULL(); - } -} -/* }}} end dom_namednodemap_get_named_item */ - - -/* {{{ proto domnode dom_namednodemap_set_named_item(node arg); -URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-1025163788 -Since: -*/ -PHP_FUNCTION(dom_namednodemap_set_named_item) -{ - DOM_NOT_IMPLEMENTED(); -} -/* }}} end dom_namednodemap_set_named_item */ - - -/* {{{ proto domnode dom_namednodemap_remove_named_item(string name); -URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-D58B193 -Since: -*/ -PHP_FUNCTION(dom_namednodemap_remove_named_item) -{ - DOM_NOT_IMPLEMENTED(); -} -/* }}} end dom_namednodemap_remove_named_item */ - - -/* {{{ proto domnode dom_namednodemap_item(unsigned long index); -URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-349467F9 -Since: -*/ -PHP_FUNCTION(dom_namednodemap_item) -{ - zval *id, *rv = NULL; - int index, ret; - dom_object *intern; - xmlNodePtr itemnode = NULL; - - dom_nnodemap_object *objmap; - xmlNodePtr nodep, curnode; - int count; - - if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Ol", &id, dom_namednodemap_class_entry, &index) == FAILURE) { - return; - } - - if (index >= 0) { - intern = (dom_object *)zend_object_store_get_object(id TSRMLS_CC); - - objmap = (dom_nnodemap_object *)intern->ptr; - if (objmap->ht) { - if (objmap->nodetype == XML_ENTITY_NODE) { - itemnode = php_dom_libxml_hash_iter(objmap->ht, index); - } else { - itemnode = php_dom_libxml_notation_iter(objmap->ht, index); - } - } else { - nodep = dom_object_get_node(objmap->baseobj); - if (nodep) { - curnode = (xmlNodePtr)nodep->properties; - count = 0; - while (count < index && curnode != NULL) { - count++; - curnode = (xmlNodePtr)curnode->next; - } - itemnode = curnode; - } - } - } else { - RETURN_NULL(); - } - - if (itemnode) { - DOM_RET_OBJ(rv, itemnode, &ret, objmap->baseobj); - } else { - RETVAL_NULL(); - } -} -/* }}} end dom_namednodemap_item */ - - -/* {{{ proto domnode dom_namednodemap_get_named_item_ns(string namespaceURI, string localName); -URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-getNamedItemNS -Since: DOM Level 2 -*/ -PHP_FUNCTION(dom_namednodemap_get_named_item_ns) -{ - zval *id, *rv = NULL; - int ret, namedlen=0, urilen=0; - dom_object *intern; - xmlNodePtr itemnode = NULL; - char *uri, *named; - - dom_nnodemap_object *objmap; - xmlNodePtr nodep; - xmlNotation *notep = NULL; - - if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os!s", &id, dom_namednodemap_class_entry, &uri, &urilen, &named, &namedlen) == FAILURE) { - return; - } - - intern = (dom_object *)zend_object_store_get_object(id TSRMLS_CC); - - objmap = (dom_nnodemap_object *)intern->ptr; - if (objmap->ht) { - if (objmap->nodetype == XML_ENTITY_NODE) { - itemnode = (xmlNodePtr)xmlHashLookup(objmap->ht, named); - } else { - notep = (xmlNotation *)xmlHashLookup(objmap->ht, named); - itemnode = create_notation(notep->name, notep->PublicID, notep->SystemID); - } - } else { - nodep = dom_object_get_node(objmap->baseobj); - if (nodep) { - itemnode = (xmlNodePtr)xmlHasNsProp(nodep, named, uri); - } - } - - if (itemnode) { - DOM_RET_OBJ(rv, itemnode, &ret, objmap->baseobj); - } else { - RETVAL_NULL(); - } -} -/* }}} end dom_namednodemap_get_named_item_ns */ - - -/* {{{ proto domnode dom_namednodemap_set_named_item_ns(node arg); -URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-setNamedItemNS -Since: DOM Level 2 -*/ -PHP_FUNCTION(dom_namednodemap_set_named_item_ns) -{ - DOM_NOT_IMPLEMENTED(); -} -/* }}} end dom_namednodemap_set_named_item_ns */ - - -/* {{{ proto domnode dom_namednodemap_remove_named_item_ns(string namespaceURI, string localName); -URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-removeNamedItemNS -Since: DOM Level 2 -*/ -PHP_FUNCTION(dom_namednodemap_remove_named_item_ns) -{ - DOM_NOT_IMPLEMENTED(); -} -/* }}} end dom_namednodemap_remove_named_item_ns */ -#endif diff --git a/ext/dom/namelist.c b/ext/dom/namelist.c deleted file mode 100644 index fcbe85c052..0000000000 --- a/ext/dom/namelist.c +++ /dev/null @@ -1,83 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP Version 5 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2004 The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 3.0 of the PHP license, | - | that is bundled with this package in the file LICENSE, and is | - | available through the world-wide-web at the following url: | - | http://www.php.net/license/3_0.txt. | - | If you did not receive a copy of the PHP license and are unable to | - | obtain it through the world-wide-web, please send a note to | - | license@php.net so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - | Authors: Christian Stocker <chregu@php.net> | - | Rob Richards <rrichards@php.net> | - +----------------------------------------------------------------------+ -*/ - -/* $Id$ */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "php.h" -#if HAVE_LIBXML && HAVE_DOM -#include "php_dom.h" - - -/* -* class domnamelist -* -* URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#NameList -* Since: DOM Level 3 -*/ - -zend_function_entry php_dom_namelist_class_functions[] = { - PHP_FALIAS(getName, dom_namelist_get_name, NULL) - PHP_FALIAS(getNamespaceURI, dom_namelist_get_namespace_uri, NULL) - {NULL, NULL, NULL} -}; - -/* {{{ attribute protos, not implemented yet */ - -/* {{{ proto length unsigned long -readonly=yes -URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#NameList-length -Since: -*/ -int dom_namelist_length_read(dom_object *obj, zval **retval TSRMLS_DC) -{ - ALLOC_ZVAL(*retval); - ZVAL_STRING(*retval, "TEST", 1); - return SUCCESS; -} - -/* }}} */ - - - - -/* {{{ proto domstring dom_namelist_get_name(unsigned long index); -URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#NameList-getName -Since: -*/ -PHP_FUNCTION(dom_namelist_get_name) -{ - DOM_NOT_IMPLEMENTED(); -} -/* }}} end dom_namelist_get_name */ - - -/* {{{ proto domstring dom_namelist_get_namespace_uri(unsigned long index); -URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#NameList-getNamespaceURI -Since: -*/ -PHP_FUNCTION(dom_namelist_get_namespace_uri) -{ - DOM_NOT_IMPLEMENTED(); -} -/* }}} end dom_namelist_get_namespace_uri */ -#endif diff --git a/ext/dom/node.c b/ext/dom/node.c deleted file mode 100644 index e93e0122fa..0000000000 --- a/ext/dom/node.c +++ /dev/null @@ -1,1476 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP Version 5 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2004 The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 3.0 of the PHP license, | - | that is bundled with this package in the file LICENSE, and is | - | available through the world-wide-web at the following url: | - | http://www.php.net/license/3_0.txt. | - | If you did not receive a copy of the PHP license and are unable to | - | obtain it through the world-wide-web, please send a note to | - | license@php.net so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - | Authors: Christian Stocker <chregu@php.net> | - | Rob Richards <rrichards@php.net> | - +----------------------------------------------------------------------+ -*/ - -/* $Id$ */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "php.h" -#if HAVE_LIBXML && HAVE_DOM -#include "php_dom.h" - -/* -* class domnode -* -* URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-1950641247 -* Since: -*/ - -zend_function_entry php_dom_node_class_functions[] = { - PHP_FALIAS(insertBefore, dom_node_insert_before, NULL) - PHP_FALIAS(replaceChild, dom_node_replace_child, NULL) - PHP_FALIAS(removeChild, dom_node_remove_child, NULL) - PHP_FALIAS(appendChild, dom_node_append_child, NULL) - PHP_FALIAS(hasChildNodes, dom_node_has_child_nodes, NULL) - PHP_FALIAS(cloneNode, dom_node_clone_node, NULL) - PHP_FALIAS(normalize, dom_node_normalize, NULL) - PHP_FALIAS(isSupported, dom_node_is_supported, NULL) - PHP_FALIAS(hasAttributes, dom_node_has_attributes, NULL) - PHP_FALIAS(compareDocumentPosition, dom_node_compare_document_position, NULL) - PHP_FALIAS(isSameNode, dom_node_is_same_node, NULL) - PHP_FALIAS(lookupPrefix, dom_node_lookup_prefix, NULL) - PHP_FALIAS(isDefaultNamespace, dom_node_is_default_namespace, NULL) - PHP_FALIAS(lookupNamespaceUri, dom_node_lookup_namespace_uri, NULL) - PHP_FALIAS(isEqualNode, dom_node_is_equal_node, NULL) - PHP_FALIAS(getFeature, dom_node_get_feature, NULL) - PHP_FALIAS(setUserData, dom_node_set_user_data, NULL) - PHP_FALIAS(getUserData, dom_node_get_user_data, NULL) - {NULL, NULL, NULL} -}; - -static void dom_reconcile_ns(xmlDocPtr doc, xmlNodePtr nodep) { - xmlNsPtr nsptr; - - if (nodep->type == XML_ELEMENT_NODE) { - /* Following if block primarily used for inserting nodes created via createElementNS */ - if (nodep->nsDef != NULL && nodep->nsDef->href != NULL) { - if((nsptr = xmlSearchNsByHref(doc, nodep->parent, nodep->nsDef->href)) && - (nodep->nsDef->prefix == NULL || xmlStrEqual(nsptr->prefix, nodep->nsDef->prefix))) { - dom_set_old_ns(doc, nodep->nsDef); - nodep->nsDef = NULL; - } - } - xmlReconciliateNs(doc, nodep); - } -} - -/* {{{ proto nodeName string -readonly=yes -URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-F68D095 -Since: -*/ -int dom_node_node_name_read(dom_object *obj, zval **retval TSRMLS_DC) -{ - xmlNode *nodep; - xmlNsPtr ns; - char *str = NULL; - xmlChar *qname = NULL; - - nodep = dom_object_get_node(obj); - - switch (nodep->type) { - case XML_ATTRIBUTE_NODE: - case XML_ELEMENT_NODE: - ns = nodep->ns; - if (ns != NULL && ns->prefix) { - qname = xmlStrdup(ns->prefix); - qname = xmlStrcat(qname, ":"); - qname = xmlStrcat(qname, nodep->name); - str = qname; - } else { - str = (char *) nodep->name; - } - break; - case XML_NAMESPACE_DECL: - ns = nodep->ns; - if (ns != NULL && ns->prefix) { - qname = xmlStrdup("xmlns"); - qname = xmlStrcat(qname, ":"); - qname = xmlStrcat(qname, nodep->name); - str = qname; - } else { - str = (char *) nodep->name; - } - break; - case XML_DOCUMENT_TYPE_NODE: - case XML_DTD_NODE: - case XML_PI_NODE: - case XML_ENTITY_DECL: - case XML_ENTITY_REF_NODE: - case XML_NOTATION_NODE: - str = (char *) nodep->name; - break; - case XML_CDATA_SECTION_NODE: - str = "#cdata-section"; - break; - case XML_COMMENT_NODE: - str = "#comment"; - break; - case XML_HTML_DOCUMENT_NODE: - case XML_DOCUMENT_NODE: - str = "#document"; - break; - case XML_DOCUMENT_FRAG_NODE: - str = "#document-fragment"; - break; - case XML_TEXT_NODE: - str = "#text"; - break; - default: - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid Node Type"); - return FAILURE; - } - - ALLOC_ZVAL(*retval); - - if(str != NULL) { - ZVAL_STRING(*retval, str, 1); - } else { - ZVAL_EMPTY_STRING(*retval); - } - - if (qname != NULL) { - xmlFree(qname); - } - - return SUCCESS; - -} - -/* }}} */ - - - -/* {{{ proto nodeValue string -readonly=no -URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-F68D080 -Since: -*/ -int dom_node_node_value_read(dom_object *obj, zval **retval TSRMLS_DC) -{ - xmlNode *nodep; - char *str = NULL; - - nodep = dom_object_get_node(obj); - /* Access to Element node is implemented as a convience method */ - switch (nodep->type) { - case XML_ATTRIBUTE_NODE: - case XML_TEXT_NODE: - case XML_ELEMENT_NODE: - case XML_COMMENT_NODE: - case XML_CDATA_SECTION_NODE: - case XML_PI_NODE: - str = xmlNodeGetContent(nodep); - break; - case XML_NAMESPACE_DECL: - str = xmlNodeGetContent(nodep->children); - break; - default: - str = NULL; - break; - } - - ALLOC_ZVAL(*retval); - - if(str != NULL) { - ZVAL_STRING(*retval, str, 1); - xmlFree(str); - } else { - ZVAL_NULL(*retval); - } - - - return SUCCESS; - -} - -int dom_node_node_value_write(dom_object *obj, zval *newval TSRMLS_DC) -{ - xmlNode *nodep; - - nodep = dom_object_get_node(obj); - - /* Access to Element node is implemented as a convience method */ - switch (nodep->type) { - case XML_ELEMENT_NODE: - case XML_ATTRIBUTE_NODE: - if (nodep->children) { - node_list_unlink(nodep->children TSRMLS_CC); - } - case XML_TEXT_NODE: - case XML_COMMENT_NODE: - case XML_CDATA_SECTION_NODE: - case XML_PI_NODE: - convert_to_string(newval); - xmlNodeSetContentLen(nodep, Z_STRVAL_P(newval), Z_STRLEN_P(newval) + 1); - break; - default: - break; - } - - return SUCCESS; -} - -/* }}} */ - - - -/* {{{ proto nodeType unsigned short -readonly=yes -URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-111237558 -Since: -*/ -int dom_node_node_type_read(dom_object *obj, zval **retval TSRMLS_DC) -{ - xmlNode *nodep; - - nodep = dom_object_get_node(obj); - - ALLOC_ZVAL(*retval); - - /* Specs dictate that they are both type XML_DOCUMENT_TYPE_NODE */ - if (nodep->type == XML_DTD_NODE) { - ZVAL_LONG(*retval, XML_DOCUMENT_TYPE_NODE); - } else { - ZVAL_LONG(*retval, nodep->type); - } - - return SUCCESS; -} - -/* }}} */ - - - -/* {{{ proto parentNode node -readonly=yes -URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-1060184317 -Since: -*/ -int dom_node_parent_node_read(dom_object *obj, zval **retval TSRMLS_DC) -{ - xmlNode *nodep, *nodeparent; - int ret; - - nodep = dom_object_get_node(obj); - - nodeparent = nodep->parent; - if (!nodeparent) { - return FAILURE; - } - - ALLOC_ZVAL(*retval); - - if (NULL == (*retval = php_dom_create_object(nodeparent, &ret, NULL, *retval, obj TSRMLS_CC))) { - php_error(E_WARNING, "Cannot create required DOM object"); - return FAILURE; - } - return SUCCESS; -} - -/* }}} */ - - - -/* {{{ proto childNodes nodelist -readonly=yes -URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-1451460987 -Since: -*/ -int dom_node_child_nodes_read(dom_object *obj, zval **retval TSRMLS_DC) -{ - xmlNode *nodep; - dom_object *intern; - - nodep = dom_object_get_node(obj); - - ALLOC_ZVAL(*retval); - - if (dom_node_children_valid(nodep) == FAILURE) { - ZVAL_NULL(*retval); - } else { - php_dom_create_interator(*retval, DOM_NODELIST TSRMLS_CC); - intern = (dom_object *)zend_objects_get_address(*retval TSRMLS_CC); - dom_namednode_iter(obj, XML_ELEMENT_NODE, intern, NULL, NULL, NULL); - } - - return SUCCESS; -} - -/* }}} */ - - - -/* {{{ proto firstChild node -readonly=yes -URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-169727388 -Since: -*/ -int dom_node_first_child_read(dom_object *obj, zval **retval TSRMLS_DC) -{ - xmlNode *nodep, *first = NULL; - int ret; - - nodep = dom_object_get_node(obj); - - if (dom_node_children_valid(nodep) == SUCCESS) { - first = nodep->children; - } - - if (!first) { - return FAILURE; - } - - ALLOC_ZVAL(*retval); - - if (NULL == (*retval = php_dom_create_object(first, &ret, NULL, *retval, obj TSRMLS_CC))) { - php_error(E_WARNING, "Cannot create required DOM object"); - return FAILURE; - } - return SUCCESS; -} - -/* }}} */ - - - -/* {{{ proto lastChild node -readonly=yes -URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-61AD09FB -Since: -*/ -int dom_node_last_child_read(dom_object *obj, zval **retval TSRMLS_DC) -{ - xmlNode *nodep, *last = NULL; - int ret; - - nodep = dom_object_get_node(obj); - - if (dom_node_children_valid(nodep) == SUCCESS) { - last = nodep->last; - } - - if (!last) { - return FAILURE; - } - - ALLOC_ZVAL(*retval); - - if (NULL == (*retval = php_dom_create_object(last, &ret, NULL, *retval, obj TSRMLS_CC))) { - php_error(E_WARNING, "Cannot create required DOM object"); - return FAILURE; - } - return SUCCESS; -} - -/* }}} */ - - - -/* {{{ proto previousSibling node -readonly=yes -URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-640FB3C8 -Since: -*/ -int dom_node_previous_sibling_read(dom_object *obj, zval **retval TSRMLS_DC) -{ - xmlNode *nodep, *prevsib; - int ret; - - nodep = dom_object_get_node(obj); - - prevsib = nodep->prev; - if (!prevsib) { - return FAILURE; - } - - ALLOC_ZVAL(*retval); - - if (NULL == (*retval = php_dom_create_object(prevsib, &ret, NULL, *retval, obj TSRMLS_CC))) { - php_error(E_WARNING, "Cannot create required DOM object"); - return FAILURE; - } - return SUCCESS; -} - -/* }}} */ - - - -/* {{{ proto nextSibling node -readonly=yes -URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-6AC54C2F -Since: -*/ -int dom_node_next_sibling_read(dom_object *obj, zval **retval TSRMLS_DC) -{ - xmlNode *nodep, *nextsib; - int ret; - - nodep = dom_object_get_node(obj); - - nextsib = nodep->next; - if (!nextsib) { - return FAILURE; - } - - ALLOC_ZVAL(*retval); - - if (NULL == (*retval = php_dom_create_object(nextsib, &ret, NULL, *retval, obj TSRMLS_CC))) { - php_error(E_WARNING, "Cannot create required DOM object"); - return FAILURE; - } - return SUCCESS; -} - -/* }}} */ - - - -/* {{{ proto attributes namednodemap -readonly=yes -URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-84CF096 -Since: -*/ -int dom_node_attributes_read(dom_object *obj, zval **retval TSRMLS_DC) -{ - xmlNode *nodep; - dom_object *intern; - - nodep = dom_object_get_node(obj); - - ALLOC_ZVAL(*retval); - - if (nodep->type == XML_ELEMENT_NODE) { - php_dom_create_interator(*retval, DOM_NAMEDNODEMAP TSRMLS_CC); - intern = (dom_object *)zend_objects_get_address(*retval TSRMLS_CC); - dom_namednode_iter(obj, XML_ATTRIBUTE_NODE, intern, NULL, NULL, NULL); - } else { - ZVAL_NULL(*retval); - } - - return SUCCESS; -} - -/* }}} */ - - - -/* {{{ proto ownerDocument dom_document -readonly=yes -URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-node-ownerDoc -Since: -*/ -int dom_node_owner_document_read(dom_object *obj, zval **retval TSRMLS_DC) -{ - xmlNode *nodep; - xmlDocPtr docp; - int ret; - - nodep = dom_object_get_node(obj); - - if (nodep->type == XML_DOCUMENT_NODE || nodep->type == XML_HTML_DOCUMENT_NODE) { - ALLOC_ZVAL(*retval); - ZVAL_NULL(*retval); - return SUCCESS; - } - - docp = nodep->doc; - if (!docp) { - return FAILURE; - } - - ALLOC_ZVAL(*retval); - - if (NULL == (*retval = php_dom_create_object((xmlNodePtr) docp, &ret, NULL, *retval, obj TSRMLS_CC))) { - php_error(E_WARNING, "Cannot create required DOM object"); - return FAILURE; - } - return SUCCESS; -} - -/* }}} */ - - - -/* {{{ proto namespaceUri string -readonly=yes -URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-NodeNSname -Since: DOM Level 2 -*/ -int dom_node_namespace_uri_read(dom_object *obj, zval **retval TSRMLS_DC) -{ - xmlNode *nodep; - char *str = NULL; - - nodep = dom_object_get_node(obj); - - switch (nodep->type) { - case XML_ELEMENT_NODE: - case XML_ATTRIBUTE_NODE: - case XML_NAMESPACE_DECL: - if (nodep->ns != NULL) { - str = (char *) nodep->ns->href; - } - break; - default: - str = NULL; - break; - } - - ALLOC_ZVAL(*retval); - - if(str != NULL) { - ZVAL_STRING(*retval, str, 1); - } else { - ZVAL_NULL(*retval); - } - - return SUCCESS; -} - -/* }}} */ - - - -/* {{{ proto prefix string -readonly=no -URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-NodeNSPrefix -Since: DOM Level 2 -*/ -int dom_node_prefix_read(dom_object *obj, zval **retval TSRMLS_DC) -{ - xmlNode *nodep; - xmlNsPtr ns; - char *str = NULL; - - nodep = dom_object_get_node(obj); - - switch (nodep->type) { - case XML_ELEMENT_NODE: - case XML_ATTRIBUTE_NODE: - case XML_NAMESPACE_DECL: - ns = nodep->ns; - if (ns != NULL && ns->prefix) { - str = (char *) ns->prefix; - } - break; - default: - str = NULL; - break; - } - - ALLOC_ZVAL(*retval); - - if (str == NULL) { - ZVAL_EMPTY_STRING(*retval); - } else { - ZVAL_STRING(*retval, str, 1); - } - return SUCCESS; - -} - -int dom_node_prefix_write(dom_object *obj, zval *newval TSRMLS_DC) -{ - xmlNode *nodep; - xmlDocPtr doc; - xmlNsPtr ns, curns = NULL; - char *strURI; - char *prefix; - - nodep = dom_object_get_node(obj); - - switch (nodep->type) { - case XML_ELEMENT_NODE: - case XML_ATTRIBUTE_NODE: - prefix = Z_STRVAL_P(newval); - if (nodep->ns != NULL && !xmlStrEqual(nodep->ns->prefix, (xmlChar *)prefix)) { - strURI = (char *) nodep->ns->href; - if (strURI == NULL || - (!strcmp (prefix, "xml") && strcmp(strURI, XML_XML_NAMESPACE)) || - (nodep->type == XML_ATTRIBUTE_NODE && !strcmp (prefix, "xmlns") && - strcmp (strURI, DOM_XMLNS_NAMESPACE)) || - (nodep->type == XML_ATTRIBUTE_NODE && !strcmp (nodep->name, "xmlns"))) { - - php_dom_throw_error(NAMESPACE_ERR, dom_get_strict_error(obj->document) TSRMLS_CC); - return FAILURE; - } - ns = xmlNewNs(NULL, nodep->ns->href, (xmlChar *)prefix); - if (nodep->doc != NULL) { - doc = nodep->doc; - if (doc->oldNs == NULL) { - doc->oldNs = (xmlNsPtr) xmlMalloc(sizeof(xmlNs)); - memset(doc->oldNs, 0, sizeof(xmlNs)); - doc->oldNs->type = XML_LOCAL_NAMESPACE; - doc->oldNs->href = xmlStrdup(XML_XML_NAMESPACE); - doc->oldNs->prefix = xmlStrdup((const xmlChar *)"xml"); - } - - curns = doc->oldNs; - while (curns->next != NULL) { - curns = curns->next; - } - curns->next = ns; - } - - nodep->ns = curns; - } - break; - default: - break; - } - - return SUCCESS; -} - -/* }}} */ - - - -/* {{{ proto localName string -readonly=yes -URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-NodeNSLocalN -Since: DOM Level 2 -*/ -int dom_node_local_name_read(dom_object *obj, zval **retval TSRMLS_DC) -{ - xmlNode *nodep; - - nodep = dom_object_get_node(obj); - - ALLOC_ZVAL(*retval); - - if (nodep->type == XML_ELEMENT_NODE || nodep->type == XML_ATTRIBUTE_NODE || nodep->type == XML_NAMESPACE_DECL) { - ZVAL_STRING(*retval, (char *) (nodep->name), 1); - } else { - ZVAL_NULL(*retval); - } - - return SUCCESS; -} - -/* }}} */ - - - -/* {{{ proto baseURI string -readonly=yes -URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#Node3-baseURI -Since: DOM Level 3 -*/ -int dom_node_base_uri_read(dom_object *obj, zval **retval TSRMLS_DC) -{ - xmlNode *nodep; - xmlChar *baseuri; - - nodep = dom_object_get_node(obj); - - ALLOC_ZVAL(*retval); - - baseuri = xmlNodeGetBase(nodep->doc, nodep); - if (baseuri) { - ZVAL_STRING(*retval, (char *) (baseuri), 1); - xmlFree(baseuri); - } else { - ZVAL_NULL(*retval); - } - - return SUCCESS; -} - -/* }}} */ - - - -/* {{{ proto textContent string -readonly=no -URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#Node3-textContent -Since: DOM Level 3 -*/ -int dom_node_text_content_read(dom_object *obj, zval **retval TSRMLS_DC) -{ - xmlNode *nodep; - char *str = NULL; - - nodep = dom_object_get_node(obj); - - str = xmlNodeGetContent(nodep); - - ALLOC_ZVAL(*retval); - - if(str != NULL) { - ZVAL_STRING(*retval, str, 1); - } else { - ZVAL_EMPTY_STRING(*retval); - } - xmlFree(str); - - return SUCCESS; -} - -int dom_node_text_content_write(dom_object *obj, zval *newval TSRMLS_DC) -{ - return SUCCESS; -} - -/* }}} */ - - - - -/* {{{ proto domnode dom_node_insert_before(node newChild, node refChild); -URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-952280727 -Since: -*/ -PHP_FUNCTION(dom_node_insert_before) -{ - zval *id, *node, *ref, *rv = NULL; - xmlNodePtr child, new_child, parentp, refp; - dom_object *intern, *childobj, *refpobj; - int ret, stricterror; - - DOM_GET_THIS_OBJ(parentp, id, xmlNodePtr, intern); - - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "oo!", &node, &ref) == FAILURE) { - return; - } - - DOM_GET_OBJ(child, node, xmlNodePtr, childobj); - - new_child = NULL; - - stricterror = dom_get_strict_error(intern->document); - - if (dom_node_is_read_only(parentp) == SUCCESS || - (child->parent != NULL && dom_node_is_read_only(child->parent) == SUCCESS)) { - php_dom_throw_error(NO_MODIFICATION_ALLOWED_ERR, stricterror TSRMLS_CC); - RETURN_FALSE; - } - - if (dom_hierarchy(parentp, child) == FAILURE) { - php_dom_throw_error(HIERARCHY_REQUEST_ERR, stricterror TSRMLS_CC); - RETURN_FALSE; - } - - if (child->doc != parentp->doc && child->doc != NULL) { - php_dom_throw_error(WRONG_DOCUMENT_ERR, stricterror TSRMLS_CC); - RETURN_FALSE; - } - - if (child->doc == NULL && parentp->doc != NULL) { - childobj->document = intern->document; - php_libxml_increment_doc_ref((php_libxml_node_object *)childobj, NULL TSRMLS_CC); - } - - if (ref != NULL) { - DOM_GET_OBJ(refp, ref, xmlNodePtr, refpobj); - if (refp->parent != parentp) { - php_dom_throw_error(NOT_FOUND_ERR, stricterror TSRMLS_CC); - RETURN_FALSE; - } - - if (child->parent != NULL) { - xmlUnlinkNode(child); - } - - if (child->type == XML_TEXT_NODE) { - if (refp->type == XML_TEXT_NODE) { - xmlChar *tmp; - - tmp = xmlStrdup(child->content); - tmp = xmlStrcat(tmp, refp->content); - xmlNodeSetContent(refp, tmp); - xmlFree(tmp); - php_libxml_node_free_resource(child TSRMLS_CC); - DOM_RET_OBJ(rv, refp, &ret, intern); - return; - } - if ((refp->prev != NULL) && (refp->prev->type == XML_TEXT_NODE) - && (refp->name == refp->prev->name)) { - xmlNodeAddContent(refp->prev, child->content); - php_libxml_node_free_resource(child TSRMLS_CC); - DOM_RET_OBJ(rv, refp->prev, &ret, intern); - return; - } - } else if (child->type == XML_ATTRIBUTE_NODE) { - xmlAttrPtr lastattr; - - if (child->ns == NULL) - lastattr = xmlHasProp(refp->parent, child->name); - else - lastattr = xmlHasNsProp(refp->parent, child->name, child->ns->href); - if (lastattr != NULL) { - if (lastattr != (xmlAttrPtr) child) { - xmlUnlinkNode((xmlNodePtr) lastattr); - php_libxml_node_free_resource((xmlNodePtr) lastattr TSRMLS_CC); - } else { - DOM_RET_OBJ(rv, child, &ret, intern); - return; - } - } - - } - new_child = xmlAddPrevSibling(refp, child); - } else { - if (child->parent == parentp){ - xmlUnlinkNode(child); - } - if (child->type == XML_TEXT_NODE) { - if ((parentp->type == XML_TEXT_NODE) && - (parentp->content != NULL) && - (parentp != child)) { - xmlNodeAddContent(parentp, child->content); - php_libxml_node_free_resource(child TSRMLS_CC); - DOM_RET_OBJ(rv, parentp, &ret, intern); - return; - } - if ((parentp->last != NULL) && (parentp->last->type == XML_TEXT_NODE) && - (parentp->last->name == child->name) && - (parentp->last != child)) { - xmlNodeAddContent(parentp->last, child->content); - php_libxml_node_free_resource(child TSRMLS_CC); - DOM_RET_OBJ(rv, parentp->last, &ret, intern); - return; - } - } else if (child->type == XML_ATTRIBUTE_NODE) { - xmlAttrPtr lastattr; - - if (child->ns == NULL) - lastattr = xmlHasProp(parentp, child->name); - else - lastattr = xmlHasNsProp(parentp, child->name, child->ns->href); - if (lastattr != NULL) { - if (lastattr != (xmlAttrPtr) child) { - xmlUnlinkNode((xmlNodePtr) lastattr); - php_libxml_node_free_resource((xmlNodePtr) lastattr TSRMLS_CC); - } else { - DOM_RET_OBJ(rv, child, &ret, intern); - return; - } - } - } else if (child->type == XML_DOCUMENT_FRAG_NODE) { - new_child = xmlAddChildList(parentp, child->children); - if (new_child != NULL) { - child->children = NULL; - } - DOM_RET_OBJ(rv, new_child, &ret, intern); - return; - } - new_child = xmlAddChild(parentp, child); - } - - if (NULL == new_child) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Couldn't add newnode as the previous sibling of refnode"); - RETURN_FALSE; - } - - dom_reconcile_ns(parentp->doc, new_child); - - DOM_RET_OBJ(rv, new_child, &ret, intern); - -} -/* }}} end dom_node_insert_before */ - - -/* {{{ proto domnode dom_node_replace_child(node newChild, node oldChild); -URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-785887307 -Since: -*/ -PHP_FUNCTION(dom_node_replace_child) -{ - zval *id, *newnode, *oldnode; - xmlNodePtr children, newchild, oldchild, nodep; - dom_object *intern, *newchildobj, *oldchildobj; - int foundoldchild = 0, stricterror; - - int ret; - - DOM_GET_THIS_OBJ(nodep, id, xmlNodePtr, intern); - - if (dom_node_children_valid(nodep) == FAILURE) { - RETURN_FALSE; - } - - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "oo", &newnode, &oldnode) == FAILURE) { - return; - } - - DOM_GET_OBJ(newchild, newnode, xmlNodePtr, newchildobj); - DOM_GET_OBJ(oldchild, oldnode, xmlNodePtr, oldchildobj); - - children = nodep->children; - if (!children) { - RETURN_FALSE; - } - - stricterror = dom_get_strict_error(intern->document); - - if (dom_node_is_read_only(nodep) == SUCCESS || - (newchild->parent != NULL && dom_node_is_read_only(newchild->parent) == SUCCESS)) { - php_dom_throw_error(NO_MODIFICATION_ALLOWED_ERR, stricterror TSRMLS_CC); - RETURN_FALSE; - } - - if (newchild->doc != nodep->doc && newchild->doc != NULL) { - php_dom_throw_error(WRONG_DOCUMENT_ERR, stricterror TSRMLS_CC); - RETURN_FALSE; - } - - if (dom_hierarchy(nodep, newchild) == FAILURE) { - php_dom_throw_error(HIERARCHY_REQUEST_ERR, stricterror TSRMLS_CC); - RETURN_FALSE; - } - - /* check for the old child and wether the new child is already a child */ - while (children) { - if (children == oldchild) { - foundoldchild = 1; - break; - } - children = children->next; - } - - if (foundoldchild) { - zval *rv = NULL; - if (oldchild != newchild) { - xmlNodePtr node; - if (newchild->doc == NULL && nodep->doc != NULL) { - xmlSetTreeDoc(newchild, nodep->doc); - newchildobj->document = intern->document; - php_libxml_increment_doc_ref((php_libxml_node_object *)newchildobj, NULL TSRMLS_CC); - } - node = xmlReplaceNode(oldchild, newchild); - dom_reconcile_ns(nodep->doc, newchild); - } - DOM_RET_OBJ(rv, oldchild, &ret, intern); - return; - } else { - php_dom_throw_error(NOT_FOUND_ERR, dom_get_strict_error(intern->document) TSRMLS_CC); - RETURN_FALSE; - } - -} -/* }}} end dom_node_replace_child */ - - -/* {{{ proto domnode dom_node_remove_child(node oldChild); -URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-1734834066 -Since: -*/ -PHP_FUNCTION(dom_node_remove_child) -{ - zval *id, *node; - xmlNodePtr children, child, nodep; - dom_object *intern, *childobj; - int ret, stricterror; - - DOM_GET_THIS_OBJ(nodep, id, xmlNodePtr, intern); - - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o", &node) == FAILURE) { - return; - } - - if (dom_node_children_valid(nodep) == FAILURE) { - RETURN_FALSE; - } - - DOM_GET_OBJ(child, node, xmlNodePtr, childobj); - - stricterror = dom_get_strict_error(intern->document); - - if (dom_node_is_read_only(nodep) == SUCCESS || - (child->parent != NULL && dom_node_is_read_only(child->parent) == SUCCESS)) { - php_dom_throw_error(NO_MODIFICATION_ALLOWED_ERR, stricterror TSRMLS_CC); - RETURN_FALSE; - } - - children = nodep->children; - if (!children) { - php_dom_throw_error(NOT_FOUND_ERR, stricterror TSRMLS_CC); - RETURN_FALSE; - } - - while (children) { - if (children == child) { - zval *rv = NULL; - xmlUnlinkNode(child); - DOM_RET_OBJ(rv, child, &ret, intern); - return; - } - children = children->next; - } - - php_dom_throw_error(NOT_FOUND_ERR, stricterror TSRMLS_CC); - RETURN_FALSE -} -/* }}} end dom_node_remove_child */ - - -/* {{{ proto domnode dom_node_append_child(node newChild); -URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-184E7107 -Since: -*/ -PHP_FUNCTION(dom_node_append_child) -{ - zval *id, *node, *rv = NULL; - xmlNodePtr child, nodep, new_child = NULL; - dom_object *intern, *childobj; - int ret, stricterror; - - DOM_GET_THIS_OBJ(nodep, id, xmlNodePtr, intern); - - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o", &node) == FAILURE) { - return; - } - - if (dom_node_children_valid(nodep) == FAILURE) { - RETURN_FALSE; - } - - DOM_GET_OBJ(child, node, xmlNodePtr, childobj); - - stricterror = dom_get_strict_error(intern->document); - - if (dom_node_is_read_only(nodep) == SUCCESS || - (child->parent != NULL && dom_node_is_read_only(child->parent) == SUCCESS)) { - php_dom_throw_error(NO_MODIFICATION_ALLOWED_ERR, stricterror TSRMLS_CC); - RETURN_FALSE; - } - - if (dom_hierarchy(nodep, child) == FAILURE) { - php_dom_throw_error(HIERARCHY_REQUEST_ERR, stricterror TSRMLS_CC); - RETURN_FALSE; - } - - if (!(child->doc == NULL || child->doc == nodep->doc)) { - php_dom_throw_error(WRONG_DOCUMENT_ERR, stricterror TSRMLS_CC); - RETURN_FALSE; - } - - if (child->doc == NULL && nodep->doc != NULL) { - childobj->document = intern->document; - php_libxml_increment_doc_ref((php_libxml_node_object *)childobj, NULL TSRMLS_CC); - } - - if (child->parent != NULL){ - xmlUnlinkNode(child); - } - - if (child->type == XML_TEXT_NODE) { - if ((nodep->type == XML_TEXT_NODE) && - (nodep->content != NULL)) { - xmlNodeAddContent(nodep, child->content); - php_libxml_node_free_resource(child TSRMLS_CC); - DOM_RET_OBJ(rv, nodep, &ret, intern); - return; - } - if ((nodep->last != NULL) && (nodep->last->type == XML_TEXT_NODE) && - (nodep->last->name == child->name)) { - xmlNodeAddContent(nodep->last, child->content); - php_libxml_node_free_resource(child TSRMLS_CC); - DOM_RET_OBJ(rv, nodep->last, &ret, intern); - return; - } - } else if (child->type == XML_ATTRIBUTE_NODE) { - xmlAttrPtr lastattr; - - if (child->ns == NULL) - lastattr = xmlHasProp(nodep, child->name); - else - lastattr = xmlHasNsProp(nodep, child->name, child->ns->href); - if (lastattr != NULL) { - if (lastattr != (xmlAttrPtr) child) { - xmlUnlinkNode((xmlNodePtr) lastattr); - php_libxml_node_free_resource((xmlNodePtr) lastattr TSRMLS_CC); - } - } - } else if (child->type == XML_DOCUMENT_FRAG_NODE) { - new_child = xmlAddChildList(nodep, child->children); - if (new_child != NULL) { - child->children = NULL; - } - DOM_RET_OBJ(rv, new_child, &ret, intern); - return; - } - - new_child = xmlAddChild(nodep, child); - - if (new_child == NULL) { - php_error(E_WARNING, "Couldn't append node"); - RETURN_FALSE; - } - - dom_reconcile_ns(nodep->doc, new_child); - - DOM_RET_OBJ(rv, new_child, &ret, intern); -} -/* }}} end dom_node_append_child */ - - -/* {{{ proto boolean dom_node_has_child_nodes(); -URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-810594187 -Since: -*/ -PHP_FUNCTION(dom_node_has_child_nodes) -{ - zval *id; - xmlNode *nodep; - dom_object *intern; - - DOM_GET_THIS_OBJ(nodep, id, xmlNodePtr, intern); - - DOM_NO_ARGS(); - - if (dom_node_children_valid(nodep) == FAILURE) { - RETURN_FALSE; - } - - if (nodep->children) { - RETURN_TRUE; - } else { - RETURN_FALSE; - } -} -/* }}} end dom_node_has_child_nodes */ - - -/* {{{ proto domnode dom_node_clone_node(boolean deep); -URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-3A0ED0A4 -Since: -*/ -PHP_FUNCTION(dom_node_clone_node) -{ - zval *rv = NULL; - zval *id; - xmlNode *n, *node; - int ret; - dom_object *intern; - long recursive = 0; - - DOM_GET_THIS_OBJ(n, id, xmlNodePtr, intern); - - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", &recursive) == FAILURE) { - return; - } - - node = xmlDocCopyNode(n, n->doc, recursive); - - /* When deep is false Element nodes still require the attributes - Following taken from libxml as xmlDocCopyNode doesnt do this */ - if (node && n->type == XML_ELEMENT_NODE && recursive == 0) { - if (n->nsDef != NULL) { - node->nsDef = xmlCopyNamespaceList(n->nsDef); - } - if (n->ns != NULL) { - xmlNsPtr ns; - ns = xmlSearchNs(n->doc, node, n->ns->prefix); - if (ns == NULL) { - ns = xmlSearchNs(n->doc, n, n->ns->prefix); - if (ns != NULL) { - xmlNodePtr root = node; - - while (root->parent != NULL) { - root = root->parent; - } - node->ns = xmlNewNs(root, ns->href, ns->prefix); - } - } else { - node->ns = ns; - } - } - if (n->properties != NULL) { - node->properties = xmlCopyPropList(node, n->properties); - } - } - - if (!node) { - RETURN_FALSE; - } - - DOM_RET_OBJ(rv, node, &ret, intern); -} -/* }}} end dom_node_clone_node */ - - - -/* {{{ proto dom_void dom_node_normalize(); -URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-normalize -Since: -*/ -PHP_FUNCTION(dom_node_normalize) -{ - zval *id; - xmlNode *nodep; - dom_object *intern; - - DOM_GET_THIS_OBJ(nodep, id, xmlNodePtr, intern); - - DOM_NO_ARGS(); - - dom_normalize(nodep TSRMLS_CC); - -} -/* }}} end dom_node_normalize */ - - -/* {{{ proto boolean dom_node_is_supported(string feature, string version); -URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-Level-2-Core-Node-supports -Since: DOM Level 2 -*/ -PHP_FUNCTION(dom_node_is_supported) -{ - int feature_len, version_len; - char *feature, *version; - - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss", &feature, &feature_len, &version, &version_len) == FAILURE) { - return; - } - - if (dom_has_feature(feature, version)) { - RETURN_TRUE; - } else { - RETURN_FALSE; - } -} -/* }}} end dom_node_is_supported */ - - -/* {{{ proto boolean dom_node_has_attributes(); -URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-NodeHasAttrs -Since: DOM Level 2 -*/ -PHP_FUNCTION(dom_node_has_attributes) -{ - zval *id; - xmlNode *nodep; - dom_object *intern; - - DOM_GET_THIS_OBJ(nodep, id, xmlNodePtr, intern); - - DOM_NO_ARGS(); - - if (nodep->type != XML_ELEMENT_NODE) - RETURN_FALSE; - - if (nodep->properties) { - RETURN_TRUE; - } else { - RETURN_FALSE; - } -} -/* }}} end dom_node_has_attributes */ - - -/* {{{ proto unsigned short dom_node_compare_document_position(node other); -URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#Node3-compareDocumentPosition -Since: DOM Level 3 -*/ -PHP_FUNCTION(dom_node_compare_document_position) -{ - DOM_NOT_IMPLEMENTED(); -} -/* }}} end dom_node_compare_document_position */ - - -/* {{{ proto boolean dom_node_is_same_node(node other); -URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#Node3-isSameNode -Since: DOM Level 3 -*/ -PHP_FUNCTION(dom_node_is_same_node) -{ - zval *id, *node; - xmlNodePtr nodeotherp, nodep; - dom_object *intern, *nodeotherobj; - - DOM_GET_THIS_OBJ(nodep, id, xmlNodePtr, intern); - - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o", &node) == FAILURE) { - return; - } - - DOM_GET_OBJ(nodeotherp, node, xmlNodePtr, nodeotherobj); - - if (nodep == nodeotherp) { - RETURN_TRUE; - } else { - RETURN_FALSE; - } -} -/* }}} end dom_node_is_same_node */ - - -/* {{{ proto domstring dom_node_lookup_prefix(string namespaceURI); -URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#Node3-lookupNamespacePrefix -Since: DOM Level 3 -*/ -PHP_FUNCTION(dom_node_lookup_prefix) -{ - zval *id; - xmlNodePtr nodep, lookupp = NULL; - dom_object *intern; - xmlNsPtr nsptr; - int uri_len = 0; - char *uri; - - DOM_GET_THIS_OBJ(nodep, id, xmlNodePtr, intern); - - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &uri, &uri_len) == FAILURE) { - return; - } - - if (uri_len > 0) { - switch (nodep->type) { - case XML_ELEMENT_NODE: - lookupp = nodep; - break; - case XML_DOCUMENT_NODE: - case XML_HTML_DOCUMENT_NODE: - lookupp = xmlDocGetRootElement((xmlDocPtr) nodep); - break; - case XML_ENTITY_NODE : - case XML_NOTATION_NODE: - case XML_DOCUMENT_FRAG_NODE: - case XML_DOCUMENT_TYPE_NODE: - case XML_DTD_NODE: - RETURN_NULL(); - break; - default: - lookupp = nodep->parent; - } - - if (lookupp != NULL && (nsptr = xmlSearchNsByHref(lookupp->doc, lookupp, uri))) { - if (nsptr->prefix != NULL) { - RETURN_STRING((char *) nsptr->prefix, 1); - } - } - } - - RETURN_NULL(); -} -/* }}} end dom_node_lookup_prefix */ - - -/* {{{ proto boolean dom_node_is_default_namespace(string namespaceURI); -URL: http://www.w3.org/TR/DOM-Level-3-Core/core.html#Node3-isDefaultNamespace -Since: DOM Level 3 -*/ -PHP_FUNCTION(dom_node_is_default_namespace) -{ - zval *id; - xmlNodePtr nodep; - dom_object *intern; - xmlNsPtr nsptr; - int uri_len = 0; - char *uri; - - DOM_GET_THIS_OBJ(nodep, id, xmlNodePtr, intern); - - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &uri, &uri_len) == FAILURE) { - return; - } - - if (uri_len > 0) { - nsptr = xmlSearchNs(nodep->doc, nodep, NULL); - if (nsptr && xmlStrEqual(nsptr->href, uri)) { - RETURN_TRUE; - } - } - - RETURN_FALSE; -} -/* }}} end dom_node_is_default_namespace */ - - -/* {{{ proto domstring dom_node_lookup_namespace_uri(string prefix); -URL: http://www.w3.org/TR/DOM-Level-3-Core/core.html#Node3-lookupNamespaceURI -Since: DOM Level 3 -*/ -PHP_FUNCTION(dom_node_lookup_namespace_uri) -{ - zval *id; - xmlNodePtr nodep; - dom_object *intern; - xmlNsPtr nsptr; - int prefix_len = 0; - char *prefix; - - DOM_GET_THIS_OBJ(nodep, id, xmlNodePtr, intern); - - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &prefix, &prefix_len) == FAILURE) { - return; - } - - if (prefix_len > 0) { - nsptr = xmlSearchNs(nodep->doc, nodep, prefix); - if (nsptr && nsptr->href != NULL) { - RETURN_STRING((char *) nsptr->href, 1); - } - } - - RETURN_NULL(); -} -/* }}} end dom_node_lookup_namespace_uri */ - - -/* {{{ proto boolean dom_node_is_equal_node(node arg); -URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#Node3-isEqualNode -Since: DOM Level 3 -*/ -PHP_FUNCTION(dom_node_is_equal_node) -{ - DOM_NOT_IMPLEMENTED(); -} -/* }}} end dom_node_is_equal_node */ - - -/* {{{ proto domnode dom_node_get_feature(string feature, string version); -URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#Node3-getFeature -Since: DOM Level 3 -*/ -PHP_FUNCTION(dom_node_get_feature) -{ - DOM_NOT_IMPLEMENTED(); -} -/* }}} end dom_node_get_feature */ - - -/* {{{ proto domuserdata dom_node_set_user_data(string key, domuserdata data, userdatahandler handler); -URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#Node3-setUserData -Since: DOM Level 3 -*/ -PHP_FUNCTION(dom_node_set_user_data) -{ - DOM_NOT_IMPLEMENTED(); -} -/* }}} end dom_node_set_user_data */ - - -/* {{{ proto domuserdata dom_node_get_user_data(string key); -URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#Node3-getUserData -Since: DOM Level 3 -*/ -PHP_FUNCTION(dom_node_get_user_data) -{ - DOM_NOT_IMPLEMENTED(); -} -/* }}} end dom_node_get_user_data */ -#endif diff --git a/ext/dom/nodelist.c b/ext/dom/nodelist.c deleted file mode 100644 index 2208322804..0000000000 --- a/ext/dom/nodelist.c +++ /dev/null @@ -1,167 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP Version 5 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2004 The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 3.0 of the PHP license, | - | that is bundled with this package in the file LICENSE, and is | - | available through the world-wide-web at the following url: | - | http://www.php.net/license/3_0.txt. | - | If you did not receive a copy of the PHP license and are unable to | - | obtain it through the world-wide-web, please send a note to | - | license@php.net so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - | Authors: Christian Stocker <chregu@php.net> | - | Rob Richards <rrichards@php.net> | - +----------------------------------------------------------------------+ -*/ - -/* $Id$ */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "php.h" -#if HAVE_LIBXML && HAVE_DOM -#include "php_dom.h" - - -/* -* class domnodelist -* -* URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#ID-536297177 -* Since: -*/ - -zend_function_entry php_dom_nodelist_class_functions[] = { - PHP_FALIAS(item, dom_nodelist_item, NULL) - {NULL, NULL, NULL} -}; - -/* {{{ attribute protos, not implemented yet */ - -/* {{{ proto length unsigned long -readonly=yes -URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#ID-203510337 -Since: -*/ -int dom_nodelist_length_read(dom_object *obj, zval **retval TSRMLS_DC) -{ - dom_nnodemap_object *objmap; - xmlNodePtr nodep, curnode; - int count = 0; - HashTable *nodeht; - - objmap = (dom_nnodemap_object *)obj->ptr; - if (objmap->ht) { - count = xmlHashSize(objmap->ht); - } else { - if (objmap->nodetype == DOM_NODESET) { - nodeht = HASH_OF(objmap->baseobjptr); - count = zend_hash_num_elements(nodeht); - } else { - nodep = dom_object_get_node(objmap->baseobj); - if (nodep) { - if (objmap->nodetype == XML_ATTRIBUTE_NODE || objmap->nodetype == XML_ELEMENT_NODE) { - curnode = nodep->children; - if (curnode) { - count++; - while (curnode->next != NULL) { - count++; - curnode = curnode->next; - } - } - } else { - if (nodep->type == XML_DOCUMENT_NODE || nodep->type == XML_HTML_DOCUMENT_NODE) { - nodep = xmlDocGetRootElement((xmlDoc *) nodep); - } else { - nodep = nodep->children; - } - curnode = dom_get_elements_by_tag_name_ns_raw(nodep, objmap->ns, objmap->local, &count, -1); - } - } - } - } - - MAKE_STD_ZVAL(*retval); - ZVAL_LONG(*retval, count); - return SUCCESS; -} - -/* }}} */ - - -/* {{{ proto domnode dom_nodelist_item(unsigned long index); -URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#ID-844377136 -Since: -*/ -PHP_FUNCTION(dom_nodelist_item) -{ - zval *id, *rv = NULL; - int index, ret; - dom_object *intern; - xmlNodePtr itemnode = NULL; - - dom_nnodemap_object *objmap; - xmlNodePtr nodep, curnode; - int count = 0; - HashTable *nodeht; - pval **entry; - - if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Ol", &id, dom_nodelist_class_entry, &index) == FAILURE) { - return; - } - - if (index >= 0) { - intern = (dom_object *)zend_object_store_get_object(id TSRMLS_CC); - - objmap = (dom_nnodemap_object *)intern->ptr; - if (objmap->ht) { - if (objmap->nodetype == XML_ENTITY_NODE) { - itemnode = php_dom_libxml_hash_iter(objmap->ht, index); - } else { - itemnode = php_dom_libxml_notation_iter(objmap->ht, index); - } - } else { - if (objmap->nodetype == DOM_NODESET) { - nodeht = HASH_OF(objmap->baseobjptr); - if (zend_hash_index_find(nodeht, index, (void **) &entry)==SUCCESS) { - *return_value = **entry; - zval_copy_ctor(return_value); - return; - } - } else { - nodep = dom_object_get_node(objmap->baseobj); - if (nodep) { - if (objmap->nodetype == XML_ATTRIBUTE_NODE || objmap->nodetype == XML_ELEMENT_NODE) { - curnode = nodep->children; - while (count < index && curnode != NULL) { - count++; - curnode = curnode->next; - } - itemnode = curnode; - } else { - if (nodep->type == XML_DOCUMENT_NODE || nodep->type == XML_HTML_DOCUMENT_NODE) { - nodep = xmlDocGetRootElement((xmlDoc *) nodep); - } else { - nodep = nodep->children; - } - itemnode = dom_get_elements_by_tag_name_ns_raw(nodep, objmap->ns, objmap->local, &count, index); - } - } - } - } - } else { - RETURN_NULL(); - } - - if (itemnode) { - DOM_RET_OBJ(rv, itemnode, &ret, objmap->baseobj); - } else { - RETVAL_NULL(); - } -} -/* }}} end dom_nodelist_item */ -#endif diff --git a/ext/dom/notation.c b/ext/dom/notation.c deleted file mode 100644 index 01e8f6db95..0000000000 --- a/ext/dom/notation.c +++ /dev/null @@ -1,90 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP Version 5 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2004 The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 3.0 of the PHP license, | - | that is bundled with this package in the file LICENSE, and is | - | available through the world-wide-web at the following url: | - | http://www.php.net/license/3_0.txt. | - | If you did not receive a copy of the PHP license and are unable to | - | obtain it through the world-wide-web, please send a note to | - | license@php.net so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - | Authors: Christian Stocker <chregu@php.net> | - | Rob Richards <rrichards@php.net> | - +----------------------------------------------------------------------+ -*/ - -/* $Id$ */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "php.h" -#if HAVE_LIBXML && HAVE_DOM -#include "php_dom.h" - - -/* -* class domnotation extends domnode -* -* URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#ID-5431D1B9 -* Since: -*/ - -zend_function_entry php_dom_notation_class_functions[] = { - {NULL, NULL, NULL} -}; - -/* {{{ attribute protos, not implemented yet */ - -/* {{{ proto public_id string -readonly=yes -URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#ID-54F2B4D0 -Since: -*/ -int dom_notation_public_id_read(dom_object *obj, zval **retval TSRMLS_DC) -{ - xmlNotationPtr nodep; - - nodep = (xmlNotationPtr) dom_object_get_node(obj); - ALLOC_ZVAL(*retval); - if (nodep->PublicID) { - ZVAL_STRING(*retval, (char *) (nodep->PublicID), 1); - } else { - ZVAL_EMPTY_STRING(*retval); - } - - return SUCCESS; -} - -/* }}} */ - - - -/* {{{ proto system_id string -readonly=yes -URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#ID-E8AAB1D0 -Since: -*/ -int dom_notation_system_id_read(dom_object *obj, zval **retval TSRMLS_DC) -{ - xmlNotationPtr nodep; - - nodep = (xmlNotationPtr) dom_object_get_node(obj); - ALLOC_ZVAL(*retval); - if (nodep->SystemID) { - ZVAL_STRING(*retval, (char *) (nodep->PublicID), 1); - } else { - ZVAL_EMPTY_STRING(*retval); - } - - return SUCCESS; -} - -/* }}} */ - -#endif diff --git a/ext/dom/php_dom.c b/ext/dom/php_dom.c deleted file mode 100644 index 770a89696f..0000000000 --- a/ext/dom/php_dom.c +++ /dev/null @@ -1,1259 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP Version 5 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2004 The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 3.0 of the PHP license, | - | that is bundled with this package in the file LICENSE, and is | - | available through the world-wide-web at the following url: | - | http://www.php.net/license/3_0.txt. | - | If you did not receive a copy of the PHP license and are unable to | - | obtain it through the world-wide-web, please send a note to | - | license@php.net so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - | Authors: Christian Stocker <chregu@php.net> | - | Rob Richards <rrichards@php.net> | - | Marcus Borger <helly@php.net> | - +----------------------------------------------------------------------+ -*/ - -/* $Id$ */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "php.h" -#if HAVE_LIBXML && HAVE_DOM -#include "ext/standard/php_rand.h" -#include "php_dom.h" -#include "dom_properties.h" - -#include "ext/standard/info.h" -#define PHP_XPATH 1 -#define PHP_XPTR 2 - -zend_object_handlers dom_object_handlers; - -static HashTable classes; - -static HashTable dom_domstringlist_prop_handlers; -static HashTable dom_namelist_prop_handlers; -static HashTable dom_domimplementationlist_prop_handlers; -static HashTable dom_document_prop_handlers; -static HashTable dom_node_prop_handlers; -static HashTable dom_nodelist_prop_handlers; -static HashTable dom_namednodemap_prop_handlers; -static HashTable dom_characterdata_prop_handlers; -static HashTable dom_attr_prop_handlers; -static HashTable dom_element_prop_handlers; -static HashTable dom_text_prop_handlers; -static HashTable dom_typeinfo_prop_handlers; -static HashTable dom_domerror_prop_handlers; -static HashTable dom_domlocator_prop_handlers; -static HashTable dom_documenttype_prop_handlers; -static HashTable dom_notation_prop_handlers; -static HashTable dom_entity_prop_handlers; -static HashTable dom_processinginstruction_prop_handlers; -static HashTable dom_namespace_node_prop_handlers; -#if defined(LIBXML_XPATH_ENABLED) -static HashTable dom_xpath_prop_handlers; -#endif - -typedef int (*dom_read_t)(dom_object *obj, zval **retval TSRMLS_DC); -typedef int (*dom_write_t)(dom_object *obj, zval *newval TSRMLS_DC); - -typedef struct _dom_prop_handler { - dom_read_t read_func; - dom_write_t write_func; -} dom_prop_handler; - -/* {{{ int dom_node_is_read_only(xmlNodePtr node) */ -int dom_node_is_read_only(xmlNodePtr node) { - switch (node->type) { - case XML_ENTITY_REF_NODE: - case XML_ENTITY_NODE: - case XML_DOCUMENT_TYPE_NODE: - case XML_NOTATION_NODE: - case XML_DTD_NODE: - case XML_ELEMENT_DECL: - case XML_ATTRIBUTE_DECL: - case XML_ENTITY_DECL: - case XML_NAMESPACE_DECL: - return SUCCESS; - break; - default: - if (node->doc == NULL) { - return SUCCESS; - } else { - return FAILURE; - } - } -} -/* }}} end dom_node_is_read_only */ - -/* {{{ int dom_node_children_valid(xmlNodePtr node) */ -int dom_node_children_valid(xmlNodePtr node) { - switch (node->type) { - case XML_DOCUMENT_TYPE_NODE: - case XML_DTD_NODE: - case XML_PI_NODE: - case XML_COMMENT_NODE: - case XML_TEXT_NODE: - case XML_CDATA_SECTION_NODE: - case XML_NOTATION_NODE: - return FAILURE; - break; - default: - return SUCCESS; - } -} -/* }}} end dom_node_children_valid */ - -/* {{{ dom_get_doc_props() */ -dom_doc_propsptr dom_get_doc_props(php_libxml_ref_obj *document) -{ - dom_doc_props *doc_props; - - if (document && document->doc_props) { - return document->doc_props; - } else { - doc_props = emalloc(sizeof(dom_doc_props)); - doc_props->formatoutput = 0; - doc_props->validateonparse = 0; - doc_props->resolveexternals = 0; - doc_props->preservewhitespace = 1; - doc_props->substituteentities = 0; - doc_props->stricterror = 1; - if (document) { - document->doc_props = doc_props; - } - return doc_props; - } -} -/* }}} */ - -/* {{{ dom_get_strict_error() */ -int dom_get_strict_error(php_libxml_ref_obj *document) { - int stricterror; - dom_doc_props *doc_props; - - doc_props = dom_get_doc_props(document); - stricterror = doc_props->stricterror; - if (document == NULL) { - efree(doc_props); - } - - return stricterror; -} -/* }}} */ - -/* {{{ xmlNodePtr dom_object_get_node(dom_object *obj) */ -xmlNodePtr dom_object_get_node(dom_object *obj) -{ - if (obj->ptr != NULL) { - return ((php_libxml_node_ptr *)obj->ptr)->node; - } else { - return NULL; - } -} -/* }}} end dom_object_get_node */ - -/* {{{ dom_object *php_dom_object_get_data(xmlNodePtr obj) */ -dom_object *php_dom_object_get_data(xmlNodePtr obj) -{ - if (obj->_private != NULL) { - return (dom_object *) ((php_libxml_node_ptr *) obj->_private)->_private; - } else { - return NULL; - } -} -/* }}} end php_dom_object_get_data */ - -/* {{{ dom_read_na */ -static int dom_read_na(dom_object *obj, zval **retval TSRMLS_DC) -{ - *retval = NULL; - php_error_docref(NULL TSRMLS_CC, E_ERROR, "Cannot read property"); - return FAILURE; -} -/* }}} */ - -/* {{{ dom_write_na */ -static int dom_write_na(dom_object *obj, zval *newval TSRMLS_DC) -{ - php_error_docref(NULL TSRMLS_CC, E_ERROR, "Cannot write property"); - return FAILURE; -} -/* }}} */ - -/* {{{ dom_register_prop_handler */ -static void dom_register_prop_handler(HashTable *prop_handler, char *name, dom_read_t read_func, dom_write_t write_func TSRMLS_DC) -{ - dom_prop_handler hnd; - - hnd.read_func = read_func ? read_func : dom_read_na; - hnd.write_func = write_func ? write_func : dom_write_na; - zend_hash_add(prop_handler, name, strlen(name)+1, &hnd, sizeof(dom_prop_handler), NULL); -} -/* }}} */ - -/* {{{ dom_read_property */ -zval *dom_read_property(zval *object, zval *member, zend_bool silent TSRMLS_DC) -{ - dom_object *obj; - zval tmp_member; - zval *retval; - dom_prop_handler *hnd; - zend_object_handlers *std_hnd; - int ret; - - if (member->type != IS_STRING) { - tmp_member = *member; - zval_copy_ctor(&tmp_member); - convert_to_string(&tmp_member); - member = &tmp_member; - } - - ret = FAILURE; - obj = (dom_object *)zend_objects_get_address(object TSRMLS_CC); - - if (obj->prop_handler != NULL) { - ret = zend_hash_find(obj->prop_handler, Z_STRVAL_P(member), Z_STRLEN_P(member)+1, (void **) &hnd); - } - if (ret == SUCCESS) { - ret = hnd->read_func(obj, &retval TSRMLS_CC); - if (ret == SUCCESS) { - /* ensure we're creating a temporary variable */ - retval->refcount = 0; - } else { - retval = EG(uninitialized_zval_ptr); - } - } else { - std_hnd = zend_get_std_object_handlers(); - retval = std_hnd->read_property(object, member, silent TSRMLS_CC); - } - - if (member == &tmp_member) { - zval_dtor(member); - } - return retval; -} -/* }}} */ - -/* {{{ dom_write_property */ -void dom_write_property(zval *object, zval *member, zval *value TSRMLS_DC) -{ - dom_object *obj; - zval tmp_member; - dom_prop_handler *hnd; - zend_object_handlers *std_hnd; - int ret; - - if (member->type != IS_STRING) { - tmp_member = *member; - zval_copy_ctor(&tmp_member); - convert_to_string(&tmp_member); - member = &tmp_member; - } - - ret = FAILURE; - obj = (dom_object *)zend_objects_get_address(object TSRMLS_CC); - - if (obj->prop_handler != NULL) { - ret = zend_hash_find((HashTable *)obj->prop_handler, Z_STRVAL_P(member), Z_STRLEN_P(member)+1, (void **) &hnd); - } - if (ret == SUCCESS) { - hnd->write_func(obj, value TSRMLS_CC); - } else { - std_hnd = zend_get_std_object_handlers(); - std_hnd->write_property(object, member, value TSRMLS_CC); - } - - if (member == &tmp_member) { - zval_dtor(member); - } -} -/* }}} */ - -/* {{{ proto somNode dom_import_simplexml(sxeobject node) - Get a simplexml_element object from dom to allow for processing */ -PHP_FUNCTION(dom_import_simplexml) -{ -#ifdef HAVE_SIMPLEXML - zval *rv = NULL; - zval *node; - xmlNodePtr nodep; - php_libxml_node_object *nodeobj; - int ret; - - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o", &node) == FAILURE) { - return; - } - - NODE_GET_OBJ(nodep, node, xmlNodePtr, nodeobj); - - if (nodep->type == XML_ELEMENT_NODE || nodep->type == XML_ATTRIBUTE_NODE) { - DOM_RET_OBJ(rv, (xmlNodePtr) nodep, &ret, (dom_object *)nodeobj); - } else { - php_error(E_WARNING, "Invalid Nodetype to import"); - RETURN_NULL(); - } -#else - php_error(E_WARNING, "SimpleXML support is not enabled"); - return; -#endif -} -/* }}} */ - -static zend_function_entry dom_functions[] = { - PHP_FE(dom_import_simplexml, NULL) - {NULL, NULL, NULL} -}; - -zend_module_entry dom_module_entry = { - STANDARD_MODULE_HEADER, - "dom", - dom_functions, - PHP_MINIT(dom), - PHP_MSHUTDOWN(dom), - NULL, - NULL, - PHP_MINFO(dom), - DOM_API_VERSION, /* Extension versionnumber */ - STANDARD_MODULE_PROPERTIES -}; - -#ifdef COMPILE_DL_DOM -ZEND_GET_MODULE(dom) -#endif - -/* {{{ PHP_MINIT_FUNCTION(dom) */ -PHP_MINIT_FUNCTION(dom) -{ - zend_class_entry ce; - - memcpy(&dom_object_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers)); - dom_object_handlers.read_property = dom_read_property; - dom_object_handlers.write_property = dom_write_property; - dom_object_handlers.get_property_ptr_ptr = NULL; - - zend_hash_init(&classes, 0, NULL, NULL, 1); - - INIT_CLASS_ENTRY(ce, "domexception", php_dom_domexception_class_functions); - dom_domexception_class_entry = zend_register_internal_class_ex(&ce, zend_exception_get_default(), NULL TSRMLS_CC); - dom_domexception_class_entry->ce_flags |= ZEND_ACC_FINAL; - dom_domexception_class_entry->constructor->common.fn_flags |= ZEND_ACC_PROTECTED; - zend_declare_property_long(dom_domexception_class_entry, "code", sizeof("code")-1, 0, ZEND_ACC_PUBLIC TSRMLS_CC); - - REGISTER_DOM_CLASS(ce, "domstringlist", NULL, php_dom_domstringlist_class_functions, dom_domstringlist_class_entry); - - zend_hash_init(&dom_domstringlist_prop_handlers, 0, NULL, NULL, 1); - dom_register_prop_handler(&dom_domstringlist_prop_handlers, "length", dom_domstringlist_length_read, NULL TSRMLS_CC); - zend_hash_add(&classes, ce.name, ce.name_length + 1, &dom_domstringlist_prop_handlers, sizeof(dom_domstringlist_prop_handlers), NULL); - - REGISTER_DOM_CLASS(ce, "domnamelist", NULL, php_dom_namelist_class_functions, dom_namelist_class_entry); - - zend_hash_init(&dom_namelist_prop_handlers, 0, NULL, NULL, 1); - dom_register_prop_handler(&dom_namelist_prop_handlers, "length", dom_namelist_length_read, NULL TSRMLS_CC); - zend_hash_add(&classes, ce.name, ce.name_length + 1, &dom_namelist_prop_handlers, sizeof(dom_namelist_prop_handlers), NULL); - - REGISTER_DOM_CLASS(ce, "domimplementationlist", NULL, php_dom_domimplementationlist_class_functions, dom_domimplementationlist_class_entry); - - zend_hash_init(&dom_domimplementationlist_prop_handlers, 0, NULL, NULL, 1); - dom_register_prop_handler(&dom_domimplementationlist_prop_handlers, "length", dom_domimplementationlist_length_read, NULL TSRMLS_CC); - zend_hash_add(&classes, ce.name, ce.name_length + 1, &dom_domimplementationlist_prop_handlers, sizeof(dom_domimplementationlist_prop_handlers), NULL); - - REGISTER_DOM_CLASS(ce, "domimplementationsource", NULL, php_dom_domimplementationsource_class_functions, dom_domimplementationsource_class_entry); - REGISTER_DOM_CLASS(ce, "domimplementation", NULL, php_dom_domimplementation_class_functions, dom_domimplementation_class_entry); - - REGISTER_DOM_CLASS(ce, "domnode", NULL, php_dom_node_class_functions, dom_node_class_entry); - - zend_hash_init(&dom_node_prop_handlers, 0, NULL, NULL, 1); - dom_register_prop_handler(&dom_node_prop_handlers, "nodeName", dom_node_node_name_read, NULL TSRMLS_CC); - dom_register_prop_handler(&dom_node_prop_handlers, "nodeValue", dom_node_node_value_read, dom_node_node_value_write TSRMLS_CC); - dom_register_prop_handler(&dom_node_prop_handlers, "nodeType", dom_node_node_type_read, NULL TSRMLS_CC); - dom_register_prop_handler(&dom_node_prop_handlers, "parentNode", dom_node_parent_node_read, NULL TSRMLS_CC); - dom_register_prop_handler(&dom_node_prop_handlers, "childNodes", dom_node_child_nodes_read, NULL TSRMLS_CC); - dom_register_prop_handler(&dom_node_prop_handlers, "firstChild", dom_node_first_child_read, NULL TSRMLS_CC); - dom_register_prop_handler(&dom_node_prop_handlers, "lastChild", dom_node_last_child_read, NULL TSRMLS_CC); - dom_register_prop_handler(&dom_node_prop_handlers, "previousSibling", dom_node_previous_sibling_read, NULL TSRMLS_CC); - dom_register_prop_handler(&dom_node_prop_handlers, "nextSibling", dom_node_next_sibling_read, NULL TSRMLS_CC); - dom_register_prop_handler(&dom_node_prop_handlers, "attributes", dom_node_attributes_read, NULL TSRMLS_CC); - dom_register_prop_handler(&dom_node_prop_handlers, "ownerDocument", dom_node_owner_document_read, NULL TSRMLS_CC); - dom_register_prop_handler(&dom_node_prop_handlers, "namespaceURI", dom_node_namespace_uri_read, NULL TSRMLS_CC); - dom_register_prop_handler(&dom_node_prop_handlers, "prefix", dom_node_prefix_read, dom_node_prefix_write TSRMLS_CC); - dom_register_prop_handler(&dom_node_prop_handlers, "localName", dom_node_local_name_read, NULL TSRMLS_CC); - dom_register_prop_handler(&dom_node_prop_handlers, "baseURI", dom_node_base_uri_read, NULL TSRMLS_CC); - dom_register_prop_handler(&dom_node_prop_handlers, "textContent", dom_node_text_content_read, dom_node_text_content_write TSRMLS_CC); - zend_hash_add(&classes, ce.name, ce.name_length + 1, &dom_node_prop_handlers, sizeof(dom_node_prop_handlers), NULL); - - REGISTER_DOM_CLASS(ce, "domnamespacenode", NULL, NULL, dom_namespace_node_class_entry); - - zend_hash_init(&dom_namespace_node_prop_handlers, 0, NULL, NULL, 1); - dom_register_prop_handler(&dom_namespace_node_prop_handlers, "nodeName", dom_node_node_name_read, NULL TSRMLS_CC); - dom_register_prop_handler(&dom_namespace_node_prop_handlers, "nodeValue", dom_node_node_value_read, NULL TSRMLS_CC); - dom_register_prop_handler(&dom_namespace_node_prop_handlers, "nodeType", dom_node_node_type_read, NULL TSRMLS_CC); - dom_register_prop_handler(&dom_namespace_node_prop_handlers, "prefix", dom_node_prefix_read, NULL TSRMLS_CC); - dom_register_prop_handler(&dom_namespace_node_prop_handlers, "localName", dom_node_local_name_read, NULL TSRMLS_CC); - dom_register_prop_handler(&dom_namespace_node_prop_handlers, "namespaceURI", dom_node_namespace_uri_read, NULL TSRMLS_CC); - dom_register_prop_handler(&dom_namespace_node_prop_handlers, "ownerDocument", dom_node_owner_document_read, NULL TSRMLS_CC); - dom_register_prop_handler(&dom_namespace_node_prop_handlers, "parentNode", dom_node_parent_node_read, NULL TSRMLS_CC); - zend_hash_add(&classes, ce.name, ce.name_length + 1, &dom_namespace_node_prop_handlers, sizeof(dom_namespace_node_prop_handlers), NULL); - - REGISTER_DOM_CLASS(ce, "domdocumentfragment", dom_node_class_entry, php_dom_documentfragment_class_functions, dom_documentfragment_class_entry); - zend_hash_add(&classes, ce.name, ce.name_length + 1, &dom_node_prop_handlers, sizeof(dom_node_prop_handlers), NULL); - - REGISTER_DOM_CLASS(ce, "domdocument", dom_node_class_entry, php_dom_document_class_functions, dom_document_class_entry); - zend_hash_init(&dom_document_prop_handlers, 0, NULL, NULL, 1); - dom_register_prop_handler(&dom_document_prop_handlers, "doctype", dom_document_doctype_read, NULL TSRMLS_CC); - dom_register_prop_handler(&dom_document_prop_handlers, "implementation", dom_document_implementation_read, NULL TSRMLS_CC); - dom_register_prop_handler(&dom_document_prop_handlers, "documentElement", dom_document_document_element_read, NULL TSRMLS_CC); -/* actualEncoding currently set as read only alias to encoding - dom_register_prop_handler(&dom_document_prop_handlers, "actualEncoding", dom_document_actual_encoding_read, dom_document_actual_encoding_write TSRMLS_CC); */ - dom_register_prop_handler(&dom_document_prop_handlers, "actualEncoding", dom_document_encoding_read, NULL TSRMLS_CC); - dom_register_prop_handler(&dom_document_prop_handlers, "encoding", dom_document_encoding_read, dom_document_encoding_write TSRMLS_CC); - dom_register_prop_handler(&dom_document_prop_handlers, "standalone", dom_document_standalone_read, dom_document_standalone_write TSRMLS_CC); - dom_register_prop_handler(&dom_document_prop_handlers, "version", dom_document_version_read, dom_document_version_write TSRMLS_CC); - dom_register_prop_handler(&dom_document_prop_handlers, "strictErrorChecking", dom_document_strict_error_checking_read, dom_document_strict_error_checking_write TSRMLS_CC); - dom_register_prop_handler(&dom_document_prop_handlers, "documentURI", dom_document_document_uri_read, dom_document_document_uri_write TSRMLS_CC); - dom_register_prop_handler(&dom_document_prop_handlers, "config", dom_document_config_read, NULL TSRMLS_CC); - dom_register_prop_handler(&dom_document_prop_handlers, "formatOutput", dom_document_format_output_read, dom_document_format_output_write TSRMLS_CC); - dom_register_prop_handler(&dom_document_prop_handlers, "validateOnParse", dom_document_validate_on_parse_read, dom_document_validate_on_parse_write TSRMLS_CC); - dom_register_prop_handler(&dom_document_prop_handlers, "resolveExternals", dom_document_resolve_externals_read, dom_document_resolve_externals_write TSRMLS_CC); - dom_register_prop_handler(&dom_document_prop_handlers, "preserveWhiteSpace", dom_document_preserve_whitespace_read, dom_document_preserve_whitespace_write TSRMLS_CC); - dom_register_prop_handler(&dom_document_prop_handlers, "substituteEntities", dom_document_substitue_entities_read, dom_document_substitue_entities_write TSRMLS_CC); - - zend_hash_merge(&dom_document_prop_handlers, &dom_node_prop_handlers, NULL, NULL, sizeof(dom_prop_handler), 0); - zend_hash_add(&classes, ce.name, ce.name_length + 1, &dom_document_prop_handlers, sizeof(dom_document_prop_handlers), NULL); - - INIT_CLASS_ENTRY(ce, "domnodelist", php_dom_nodelist_class_functions); - ce.create_object = dom_nnodemap_objects_new; - dom_nodelist_class_entry = zend_register_internal_class_ex(&ce, NULL, NULL TSRMLS_CC); - dom_nodelist_class_entry->get_iterator = php_dom_get_iterator; - - zend_hash_init(&dom_nodelist_prop_handlers, 0, NULL, NULL, 1); - dom_register_prop_handler(&dom_nodelist_prop_handlers, "length", dom_nodelist_length_read, NULL TSRMLS_CC); - zend_hash_add(&classes, ce.name, ce.name_length + 1, &dom_nodelist_prop_handlers, sizeof(dom_nodelist_prop_handlers), NULL); - - INIT_CLASS_ENTRY(ce, "domnamednodemap", php_dom_namednodemap_class_functions); - ce.create_object = dom_nnodemap_objects_new; - dom_namednodemap_class_entry = zend_register_internal_class_ex(&ce, NULL, NULL TSRMLS_CC); - dom_namednodemap_class_entry->get_iterator = php_dom_get_iterator; - - zend_hash_init(&dom_namednodemap_prop_handlers, 0, NULL, NULL, 1); - dom_register_prop_handler(&dom_namednodemap_prop_handlers, "length", dom_namednodemap_length_read, NULL TSRMLS_CC); - zend_hash_add(&classes, ce.name, ce.name_length + 1, &dom_namednodemap_prop_handlers, sizeof(dom_namednodemap_prop_handlers), NULL); - - REGISTER_DOM_CLASS(ce, "domcharacterdata", dom_node_class_entry, php_dom_characterdata_class_functions, dom_characterdata_class_entry); - - zend_hash_init(&dom_characterdata_prop_handlers, 0, NULL, NULL, 1); - dom_register_prop_handler(&dom_characterdata_prop_handlers, "data", dom_characterdata_data_read, dom_characterdata_data_write TSRMLS_CC); - dom_register_prop_handler(&dom_characterdata_prop_handlers, "length", dom_characterdata_length_read, NULL TSRMLS_CC); - zend_hash_merge(&dom_characterdata_prop_handlers, &dom_node_prop_handlers, NULL, NULL, sizeof(dom_prop_handler), 0); - zend_hash_add(&classes, ce.name, ce.name_length + 1, &dom_characterdata_prop_handlers, sizeof(dom_characterdata_prop_handlers), NULL); - - REGISTER_DOM_CLASS(ce, "domattr", dom_node_class_entry, php_dom_attr_class_functions, dom_attr_class_entry); - - zend_hash_init(&dom_attr_prop_handlers, 0, NULL, NULL, 1); - dom_register_prop_handler(&dom_attr_prop_handlers, "name", dom_attr_name_read, NULL TSRMLS_CC); - dom_register_prop_handler(&dom_attr_prop_handlers, "specified", dom_attr_specified_read, NULL TSRMLS_CC); - dom_register_prop_handler(&dom_attr_prop_handlers, "value", dom_attr_value_read, dom_attr_value_write TSRMLS_CC); - dom_register_prop_handler(&dom_attr_prop_handlers, "ownerElement", dom_attr_owner_element_read, NULL TSRMLS_CC); - dom_register_prop_handler(&dom_attr_prop_handlers, "schemaTypeInfo", dom_attr_schema_type_info_read, NULL TSRMLS_CC); - zend_hash_merge(&dom_attr_prop_handlers, &dom_node_prop_handlers, NULL, NULL, sizeof(dom_prop_handler), 0); - zend_hash_add(&classes, ce.name, ce.name_length + 1, &dom_attr_prop_handlers, sizeof(dom_attr_prop_handlers), NULL); - - REGISTER_DOM_CLASS(ce, "domelement", dom_node_class_entry, php_dom_element_class_functions, dom_element_class_entry); - - zend_hash_init(&dom_element_prop_handlers, 0, NULL, NULL, 1); - dom_register_prop_handler(&dom_element_prop_handlers, "tagName", dom_element_tag_name_read, NULL TSRMLS_CC); - dom_register_prop_handler(&dom_element_prop_handlers, "schemaTypeInfo", dom_element_schema_type_info_read, NULL TSRMLS_CC); - zend_hash_merge(&dom_element_prop_handlers, &dom_node_prop_handlers, NULL, NULL, sizeof(dom_prop_handler), 0); - zend_hash_add(&classes, ce.name, ce.name_length + 1, &dom_element_prop_handlers, sizeof(dom_element_prop_handlers), NULL); - - REGISTER_DOM_CLASS(ce, "domtext", dom_characterdata_class_entry, php_dom_text_class_functions, dom_text_class_entry); - - zend_hash_init(&dom_text_prop_handlers, 0, NULL, NULL, 1); - dom_register_prop_handler(&dom_text_prop_handlers, "wholeText", dom_text_whole_text_read, NULL TSRMLS_CC); - zend_hash_merge(&dom_text_prop_handlers, &dom_characterdata_prop_handlers, NULL, NULL, sizeof(dom_prop_handler), 0); - zend_hash_add(&classes, ce.name, ce.name_length + 1, &dom_text_prop_handlers, sizeof(dom_text_prop_handlers), NULL); - - REGISTER_DOM_CLASS(ce, "domcomment", dom_characterdata_class_entry, php_dom_comment_class_functions, dom_comment_class_entry); - zend_hash_add(&classes, ce.name, ce.name_length + 1, &dom_characterdata_prop_handlers, sizeof(dom_typeinfo_prop_handlers), NULL); - - REGISTER_DOM_CLASS(ce, "domtypeinfo", NULL, php_dom_typeinfo_class_functions, dom_typeinfo_class_entry); - - zend_hash_init(&dom_typeinfo_prop_handlers, 0, NULL, NULL, 1); - dom_register_prop_handler(&dom_typeinfo_prop_handlers, "typeName", dom_typeinfo_type_name_read, NULL TSRMLS_CC); - dom_register_prop_handler(&dom_typeinfo_prop_handlers, "typeNamespace", dom_typeinfo_type_namespace_read, NULL TSRMLS_CC); - zend_hash_add(&classes, ce.name, ce.name_length + 1, &dom_typeinfo_prop_handlers, sizeof(dom_typeinfo_prop_handlers), NULL); - - REGISTER_DOM_CLASS(ce, "domuserdatahandler", NULL, php_dom_userdatahandler_class_functions, dom_userdatahandler_class_entry); - REGISTER_DOM_CLASS(ce, "domdomerror", NULL, php_dom_domerror_class_functions, dom_domerror_class_entry); - - zend_hash_init(&dom_domerror_prop_handlers, 0, NULL, NULL, 1); - dom_register_prop_handler(&dom_domerror_prop_handlers, "severity", dom_domerror_severity_read, NULL TSRMLS_CC); - dom_register_prop_handler(&dom_domerror_prop_handlers, "message", dom_domerror_message_read, NULL TSRMLS_CC); - dom_register_prop_handler(&dom_domerror_prop_handlers, "type", dom_domerror_type_read, NULL TSRMLS_CC); - dom_register_prop_handler(&dom_domerror_prop_handlers, "relatedException", dom_domerror_related_exception_read, NULL TSRMLS_CC); - dom_register_prop_handler(&dom_domerror_prop_handlers, "related_data", dom_domerror_related_data_read, NULL TSRMLS_CC); - dom_register_prop_handler(&dom_domerror_prop_handlers, "location", dom_domerror_location_read, NULL TSRMLS_CC); - zend_hash_add(&classes, ce.name, ce.name_length + 1, &dom_domerror_prop_handlers, sizeof(dom_domerror_prop_handlers), NULL); - - REGISTER_DOM_CLASS(ce, "domerrorhandler", NULL, php_dom_domerrorhandler_class_functions, dom_domerrorhandler_class_entry); - REGISTER_DOM_CLASS(ce, "domlocator", NULL, php_dom_domlocator_class_functions, dom_domlocator_class_entry); - - zend_hash_init(&dom_domlocator_prop_handlers, 0, NULL, NULL, 1); - dom_register_prop_handler(&dom_domlocator_prop_handlers, "lineNumber", dom_domlocator_line_number_read, NULL TSRMLS_CC); - dom_register_prop_handler(&dom_domlocator_prop_handlers, "columnNumber", dom_domlocator_column_number_read, NULL TSRMLS_CC); - dom_register_prop_handler(&dom_domlocator_prop_handlers, "offset", dom_domlocator_offset_read, NULL TSRMLS_CC); - dom_register_prop_handler(&dom_domlocator_prop_handlers, "relatedNode", dom_domlocator_related_node_read, NULL TSRMLS_CC); - dom_register_prop_handler(&dom_domlocator_prop_handlers, "uri", dom_domlocator_uri_read, NULL TSRMLS_CC); - zend_hash_add(&classes, ce.name, ce.name_length + 1, &dom_domlocator_prop_handlers, sizeof(dom_domlocator_prop_handlers), NULL); - - REGISTER_DOM_CLASS(ce, "domconfiguration", NULL, php_dom_domconfiguration_class_functions, dom_domconfiguration_class_entry); - REGISTER_DOM_CLASS(ce, "domcdatasection", dom_text_class_entry, php_dom_cdatasection_class_functions, dom_cdatasection_class_entry); - zend_hash_add(&classes, ce.name, ce.name_length + 1, &dom_text_prop_handlers, sizeof(dom_documenttype_prop_handlers), NULL); - - REGISTER_DOM_CLASS(ce, "domdocumenttype", dom_node_class_entry, php_dom_documenttype_class_functions, dom_documenttype_class_entry); - - zend_hash_init(&dom_documenttype_prop_handlers, 0, NULL, NULL, 1); - dom_register_prop_handler(&dom_documenttype_prop_handlers, "name", dom_documenttype_name_read, NULL TSRMLS_CC); - dom_register_prop_handler(&dom_documenttype_prop_handlers, "entities", dom_documenttype_entities_read, NULL TSRMLS_CC); - dom_register_prop_handler(&dom_documenttype_prop_handlers, "notations", dom_documenttype_notations_read, NULL TSRMLS_CC); - dom_register_prop_handler(&dom_documenttype_prop_handlers, "publicId", dom_documenttype_public_id_read, NULL TSRMLS_CC); - dom_register_prop_handler(&dom_documenttype_prop_handlers, "systemId", dom_documenttype_system_id_read, NULL TSRMLS_CC); - dom_register_prop_handler(&dom_documenttype_prop_handlers, "internalSubset", dom_documenttype_internal_subset_read, NULL TSRMLS_CC); - zend_hash_merge(&dom_documenttype_prop_handlers, &dom_node_prop_handlers, NULL, NULL, sizeof(dom_prop_handler), 0); - zend_hash_add(&classes, ce.name, ce.name_length + 1, &dom_documenttype_prop_handlers, sizeof(dom_documenttype_prop_handlers), NULL); - - REGISTER_DOM_CLASS(ce, "domnotation", NULL, php_dom_notation_class_functions, dom_notation_class_entry); - - zend_hash_init(&dom_notation_prop_handlers, 0, NULL, NULL, 1); - dom_register_prop_handler(&dom_notation_prop_handlers, "publicId", dom_notation_public_id_read, NULL TSRMLS_CC); - dom_register_prop_handler(&dom_notation_prop_handlers, "systemId", dom_notation_system_id_read, NULL TSRMLS_CC); - /* Notation nodes are special */ - dom_register_prop_handler(&dom_notation_prop_handlers, "nodeName", dom_node_node_name_read, NULL TSRMLS_CC); - dom_register_prop_handler(&dom_notation_prop_handlers, "nodeValue", dom_node_node_value_read, dom_node_node_value_write TSRMLS_CC); - dom_register_prop_handler(&dom_notation_prop_handlers, "attributes", dom_node_attributes_read, NULL TSRMLS_CC); - zend_hash_add(&classes, ce.name, ce.name_length + 1, &dom_notation_prop_handlers, sizeof(dom_notation_prop_handlers), NULL); - - REGISTER_DOM_CLASS(ce, "domentity", dom_node_class_entry, php_dom_entity_class_functions, dom_entity_class_entry); - - zend_hash_init(&dom_entity_prop_handlers, 0, NULL, NULL, 1); - dom_register_prop_handler(&dom_entity_prop_handlers, "publicId", dom_entity_public_id_read, NULL TSRMLS_CC); - dom_register_prop_handler(&dom_entity_prop_handlers, "systemId", dom_entity_system_id_read, NULL TSRMLS_CC); - dom_register_prop_handler(&dom_entity_prop_handlers, "notationName", dom_entity_notation_name_read, NULL TSRMLS_CC); - dom_register_prop_handler(&dom_entity_prop_handlers, "actualEncoding", dom_entity_actual_encoding_read, dom_entity_actual_encoding_write TSRMLS_CC); - dom_register_prop_handler(&dom_entity_prop_handlers, "encoding", dom_entity_encoding_read, dom_entity_encoding_write TSRMLS_CC); - dom_register_prop_handler(&dom_entity_prop_handlers, "version", dom_entity_version_read, dom_entity_version_write TSRMLS_CC); - zend_hash_merge(&dom_entity_prop_handlers, &dom_node_prop_handlers, NULL, NULL, sizeof(dom_prop_handler), 0); - - zend_hash_add(&classes, ce.name, ce.name_length + 1, &dom_entity_prop_handlers, sizeof(dom_entity_prop_handlers), NULL); - - REGISTER_DOM_CLASS(ce, "domentityreference", dom_node_class_entry, php_dom_entityreference_class_functions, dom_entityreference_class_entry); - zend_hash_add(&classes, ce.name, ce.name_length + 1, &dom_node_prop_handlers, sizeof(dom_entity_prop_handlers), NULL); - - REGISTER_DOM_CLASS(ce, "domprocessinginstruction", dom_node_class_entry, php_dom_processinginstruction_class_functions, dom_processinginstruction_class_entry); - - zend_hash_init(&dom_processinginstruction_prop_handlers, 0, NULL, NULL, 1); - dom_register_prop_handler(&dom_processinginstruction_prop_handlers, "target", dom_processinginstruction_target_read, NULL TSRMLS_CC); - dom_register_prop_handler(&dom_processinginstruction_prop_handlers, "data", dom_processinginstruction_data_read, dom_processinginstruction_data_write TSRMLS_CC); - zend_hash_merge(&dom_processinginstruction_prop_handlers, &dom_node_prop_handlers, NULL, NULL, sizeof(dom_prop_handler), 0); - zend_hash_add(&classes, ce.name, ce.name_length + 1, &dom_processinginstruction_prop_handlers, sizeof(dom_processinginstruction_prop_handlers), NULL); - - REGISTER_DOM_CLASS(ce, "domstring_extend", NULL, php_dom_string_extend_class_functions, dom_string_extend_class_entry); - -#if defined(LIBXML_XPATH_ENABLED) - INIT_CLASS_ENTRY(ce, "domxpath", php_dom_xpath_class_functions); - ce.create_object = dom_xpath_objects_new; - dom_xpath_class_entry = zend_register_internal_class_ex(&ce, NULL, NULL TSRMLS_CC); - - zend_hash_init(&dom_xpath_prop_handlers, 0, NULL, NULL, 1); - dom_register_prop_handler(&dom_xpath_prop_handlers, "document", dom_xpath_document_read, NULL TSRMLS_CC); - zend_hash_add(&classes, ce.name, ce.name_length + 1, &dom_xpath_prop_handlers, sizeof(dom_xpath_prop_handlers), NULL); -#endif - - REGISTER_LONG_CONSTANT("XML_ELEMENT_NODE", XML_ELEMENT_NODE, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("XML_ATTRIBUTE_NODE", XML_ATTRIBUTE_NODE, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("XML_TEXT_NODE", XML_TEXT_NODE, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("XML_CDATA_SECTION_NODE", XML_CDATA_SECTION_NODE, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("XML_ENTITY_REF_NODE", XML_ENTITY_REF_NODE, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("XML_ENTITY_NODE", XML_ENTITY_NODE, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("XML_PI_NODE", XML_PI_NODE, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("XML_COMMENT_NODE", XML_COMMENT_NODE, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("XML_DOCUMENT_NODE", XML_DOCUMENT_NODE, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("XML_DOCUMENT_TYPE_NODE", XML_DOCUMENT_TYPE_NODE, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("XML_DOCUMENT_FRAG_NODE", XML_DOCUMENT_FRAG_NODE, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("XML_NOTATION_NODE", XML_NOTATION_NODE, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("XML_HTML_DOCUMENT_NODE", XML_HTML_DOCUMENT_NODE, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("XML_DTD_NODE", XML_DTD_NODE, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("XML_ELEMENT_DECL_NODE", XML_ELEMENT_DECL, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("XML_ATTRIBUTE_DECL_NODE", XML_ATTRIBUTE_DECL, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("XML_ENTITY_DECL_NODE", XML_ENTITY_DECL, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("XML_NAMESPACE_DECL_NODE", XML_NAMESPACE_DECL, CONST_CS | CONST_PERSISTENT); -#ifdef XML_GLOBAL_NAMESPACE - REGISTER_LONG_CONSTANT("XML_GLOBAL_NAMESPACE", XML_GLOBAL_NAMESPACE, CONST_CS | CONST_PERSISTENT); -#endif - REGISTER_LONG_CONSTANT("XML_LOCAL_NAMESPACE", XML_LOCAL_NAMESPACE, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("XML_ATTRIBUTE_CDATA", XML_ATTRIBUTE_CDATA, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("XML_ATTRIBUTE_ID", XML_ATTRIBUTE_ID, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("XML_ATTRIBUTE_IDREF", XML_ATTRIBUTE_IDREF, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("XML_ATTRIBUTE_IDREFS", XML_ATTRIBUTE_IDREFS, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("XML_ATTRIBUTE_ENTITY", XML_ATTRIBUTE_ENTITIES, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("XML_ATTRIBUTE_NMTOKEN", XML_ATTRIBUTE_NMTOKEN, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("XML_ATTRIBUTE_NMTOKENS", XML_ATTRIBUTE_NMTOKENS, CONST_CS | CONST_PERSISTENT); - 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 */ - 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); - REGISTER_LONG_CONSTANT("DOM_WRONG_DOCUMENT_ERR", WRONG_DOCUMENT_ERR, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("DOM_INVALID_CHARACTER_ERR", INVALID_CHARACTER_ERR, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("DOM_NO_DATA_ALLOWED_ERR", NO_DATA_ALLOWED_ERR, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("DOM_NO_MODIFICATION_ALLOWED_ERR", NO_MODIFICATION_ALLOWED_ERR, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("DOM_NOT_FOUND_ERR", NOT_FOUND_ERR, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("DOM_NOT_SUPPORTED_ERR", NOT_SUPPORTED_ERR, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("DOM_INUSE_ATTRIBUTE_ERR", INUSE_ATTRIBUTE_ERR, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("DOM_INVALID_STATE_ERR", INVALID_STATE_ERR, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("DOM_SYNTAX_ERR", SYNTAX_ERR, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("DOM_INVALID_MODIFICATION_ERR", INVALID_MODIFICATION_ERR, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("DOM_NAMESPACE_ERR", NAMESPACE_ERR, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("DOM_INVALID_ACCESS_ERR", INVALID_ACCESS_ERR, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("DOM_VALIDATION_ERR", VALIDATION_ERR, CONST_CS | CONST_PERSISTENT); - - return SUCCESS; -} -/* }}} */ - -/* {{{ */ -PHP_MINFO_FUNCTION(dom) -{ - php_info_print_table_start(); - php_info_print_table_row(2, "DOM/XML", "enabled"); - php_info_print_table_row(2, "DOM/XML API Version", DOM_API_VERSION); - php_info_print_table_row(2, "libxml Version", LIBXML_DOTTED_VERSION); -#if defined(LIBXML_HTML_ENABLED) - php_info_print_table_row(2, "HTML Support", "enabled"); -#endif -#if defined(LIBXML_XPATH_ENABLED) - php_info_print_table_row(2, "XPath Support", "enabled"); -#endif -#if defined(LIBXML_XPTR_ENABLED) - php_info_print_table_row(2, "XPointer Support", "enabled"); -#endif -#ifdef LIBXML_SCHEMAS_ENABLED - php_info_print_table_row(2, "Schema Support", "enabled"); - php_info_print_table_row(2, "RelaxNG Support", "enabled"); -#endif - php_info_print_table_end(); -} -/* }}} */ - -PHP_MSHUTDOWN_FUNCTION(dom) -{ - zend_hash_destroy(&dom_domstringlist_prop_handlers); - zend_hash_destroy(&dom_namelist_prop_handlers); - zend_hash_destroy(&dom_domimplementationlist_prop_handlers); - zend_hash_destroy(&dom_document_prop_handlers); - zend_hash_destroy(&dom_node_prop_handlers); - zend_hash_destroy(&dom_namespace_node_prop_handlers); - zend_hash_destroy(&dom_nodelist_prop_handlers); - zend_hash_destroy(&dom_namednodemap_prop_handlers); - zend_hash_destroy(&dom_characterdata_prop_handlers); - zend_hash_destroy(&dom_attr_prop_handlers); - zend_hash_destroy(&dom_element_prop_handlers); - zend_hash_destroy(&dom_text_prop_handlers); - zend_hash_destroy(&dom_typeinfo_prop_handlers); - zend_hash_destroy(&dom_domerror_prop_handlers); - zend_hash_destroy(&dom_domlocator_prop_handlers); - zend_hash_destroy(&dom_documenttype_prop_handlers); - zend_hash_destroy(&dom_notation_prop_handlers); - zend_hash_destroy(&dom_entity_prop_handlers); - zend_hash_destroy(&dom_processinginstruction_prop_handlers); -#if defined(LIBXML_XPATH_ENABLED) - zend_hash_destroy(&dom_xpath_prop_handlers); -#endif - zend_hash_destroy(&classes); - -/* If you want do find memleaks in this module, compile libxml2 with --with-mem-debug and - uncomment the following line, this will tell you the amount of not freed memory - and the total used memory into apaches error_log */ -/* xmlMemoryDump();*/ - - return SUCCESS; -} - -/* {{{ node_list_unlink */ -void node_list_unlink(xmlNodePtr node TSRMLS_DC) -{ - dom_object *wrapper; - - while (node != NULL) { - - wrapper = php_dom_object_get_data(node); - - if (wrapper != NULL ) { - xmlUnlinkNode(node); - } else { - node_list_unlink(node->children TSRMLS_CC); - - switch (node->type) { - case XML_ATTRIBUTE_DECL: - case XML_DTD_NODE: - case XML_DOCUMENT_TYPE_NODE: - case XML_ENTITY_DECL: - case XML_ATTRIBUTE_NODE: - break; - default: - node_list_unlink((xmlNodePtr) node->properties TSRMLS_CC); - } - - } - - node = node->next; - } -} -/* }}} end node_list_unlink */ - -/* {{{ dom_objects_clone */ -void dom_objects_clone(void *object, void **object_clone TSRMLS_DC) -{ - /* TODO */ -} -/* }}} */ - -#if defined(LIBXML_XPATH_ENABLED) -/* {{{ dom_xpath_objects_dtor */ -void dom_xpath_objects_dtor(void *object, zend_object_handle handle TSRMLS_DC) -{ - dom_object *intern = (dom_object *)object; - - zend_hash_destroy(intern->std.properties); - FREE_HASHTABLE(intern->std.properties); - - if (intern->ptr != NULL) { - xmlXPathFreeContext((xmlXPathContextPtr) intern->ptr); - php_libxml_decrement_doc_ref((php_libxml_node_object *) intern TSRMLS_CC); - intern->ptr = NULL; - } - - efree(object); -} -/* }}} */ -#endif - -/* {{{ dom_objects_dtor */ -void dom_objects_dtor(void *object, zend_object_handle handle TSRMLS_DC) -{ - dom_object *intern = (dom_object *)object; - int retcount; - - zend_hash_destroy(intern->std.properties); - FREE_HASHTABLE(intern->std.properties); - - if (intern->ptr != NULL && ((php_libxml_node_ptr *)intern->ptr)->node != NULL) { - if (((xmlNodePtr) ((php_libxml_node_ptr *)intern->ptr)->node)->type != XML_DOCUMENT_NODE && ((xmlNodePtr) ((php_libxml_node_ptr *)intern->ptr)->node)->type != XML_HTML_DOCUMENT_NODE) { - // php_libxml_node_free_resource(dom_object_get_node(intern) TSRMLS_CC); - php_libxml_node_decrement_resource((php_libxml_node_object *) intern TSRMLS_CC); - } else { - php_libxml_decrement_node_ptr((php_libxml_node_object *) intern TSRMLS_CC); - retcount = php_libxml_decrement_doc_ref((php_libxml_node_object *)intern TSRMLS_CC); - } - intern->ptr = NULL; - } - - efree(object); -} -/* }}} */ - -void dom_namednode_iter(dom_object *basenode, int ntype, dom_object *intern, xmlHashTablePtr ht, xmlChar *local, xmlChar *ns) -{ - dom_nnodemap_object *mapptr; - zval *baseobj = NULL; - - mapptr = (dom_nnodemap_object *)intern->ptr; - if (basenode) { - MAKE_STD_ZVAL(baseobj); - baseobj->type = IS_OBJECT; - baseobj->is_ref = 1; - baseobj->value.obj.handle = basenode->handle; - baseobj->value.obj.handlers = &dom_object_handlers; - zval_copy_ctor(baseobj); - } - mapptr->baseobjptr = baseobj; - mapptr->baseobj = basenode; - mapptr->nodetype = ntype; - mapptr->ht = ht; - mapptr->local = local; - mapptr->ns = ns; - -} - -static dom_object* dom_objects_set_class(zend_class_entry *class_type TSRMLS_DC) -{ - zend_class_entry *base_class; - zval *tmp; - dom_object *intern; - - intern = emalloc(sizeof(dom_object)); - intern->std.ce = class_type; - intern->std.in_get = 0; - intern->std.in_set = 0; - intern->ptr = NULL; - intern->prop_handler = NULL; - intern->document = NULL; - - base_class = class_type; - while(base_class->type != ZEND_INTERNAL_CLASS && base_class->parent != NULL) { - base_class = base_class->parent; - } - - zend_hash_find(&classes, base_class->name, base_class->name_length + 1, (void **) &intern->prop_handler); - - ALLOC_HASHTABLE(intern->std.properties); - zend_hash_init(intern->std.properties, 0, NULL, ZVAL_PTR_DTOR, 0); - zend_hash_copy(intern->std.properties, &class_type->default_properties, (copy_ctor_func_t) zval_add_ref, (void *) &tmp, sizeof(zval *)); - - return intern; -} - -/* {{{ dom_objects_new */ -zend_object_value dom_objects_new(zend_class_entry *class_type TSRMLS_DC) -{ - zend_object_value retval; - dom_object *intern; - - intern = dom_objects_set_class(class_type TSRMLS_CC); - - retval.handle = zend_objects_store_put(intern, dom_objects_dtor, dom_objects_clone TSRMLS_CC); - intern->handle = retval.handle; - retval.handlers = &dom_object_handlers; - - return retval; -} -/* }}} */ - -#if defined(LIBXML_XPATH_ENABLED) -/* {{{ zend_object_value dom_xpath_objects_new(zend_class_entry *class_type TSRMLS_DC) */ -zend_object_value dom_xpath_objects_new(zend_class_entry *class_type TSRMLS_DC) -{ - zend_object_value retval; - dom_object *intern; - - intern = dom_objects_set_class(class_type TSRMLS_CC); - - retval.handle = zend_objects_store_put(intern, dom_xpath_objects_dtor, dom_objects_clone TSRMLS_CC); - intern->handle = retval.handle; - retval.handlers = &dom_object_handlers; - - return retval; -} -/* }}} */ -#endif - -void dom_nnodemap_objects_dtor(void *object, zend_object_handle handle TSRMLS_DC) -{ - dom_nnodemap_object *objmap; - zval *baseobj; - dom_object *intern = (dom_object *)object; - - php_libxml_decrement_doc_ref((php_libxml_node_object *)intern TSRMLS_CC); - objmap = (dom_nnodemap_object *)intern->ptr; - if (objmap) { - if (objmap->local) { - xmlFree(objmap->local); - } - if (objmap->ns) { - xmlFree(objmap->ns); - } - if (objmap->baseobjptr) { - baseobj = objmap->baseobjptr; - zval_ptr_dtor((zval **)&baseobj); - } - efree(objmap); - } - - zend_hash_destroy(intern->std.properties); - FREE_HASHTABLE(intern->std.properties); - - efree(object); -} - -zend_object_value dom_nnodemap_objects_new(zend_class_entry *class_type TSRMLS_DC) -{ - zend_object_value retval; - dom_object *intern; - dom_nnodemap_object *objmap; - - intern = dom_objects_set_class(class_type TSRMLS_CC); - intern->ptr = emalloc(sizeof(dom_nnodemap_object)); - objmap = (dom_nnodemap_object *)intern->ptr; - objmap->baseobj = NULL; - objmap->baseobjptr = NULL; - objmap->nodetype = 0; - objmap->ht = NULL; - objmap->local = NULL; - objmap->ns = NULL; - - retval.handle = zend_objects_store_put(intern, dom_nnodemap_objects_dtor, dom_objects_clone TSRMLS_CC); - intern->handle = retval.handle; - retval.handlers = &dom_object_handlers; - - return retval; -} - -void php_dom_create_interator(zval *return_value, int ce_type TSRMLS_DC) -{ - zend_class_entry *ce; - - if (ce_type == DOM_NAMEDNODEMAP) { - ce = dom_namednodemap_class_entry; - } else { - ce = dom_nodelist_class_entry; - } - - object_init_ex(return_value, ce); -} - -/* {{{ php_dom_create_object */ -zval *php_dom_create_object(xmlNodePtr obj, int *found, zval *wrapper_in, zval *return_value, dom_object *domobj TSRMLS_DC) -{ - zval *wrapper; - zend_class_entry *ce; - dom_object *intern; - - *found = 0; - - if (!obj) { - ALLOC_ZVAL(wrapper); - ZVAL_NULL(wrapper); - return wrapper; - } - - if ((intern = (dom_object *) php_dom_object_get_data((void *) obj))) { - return_value->type = IS_OBJECT; - return_value->is_ref = 1; - return_value->value.obj.handle = intern->handle; - return_value->value.obj.handlers = &dom_object_handlers; - zval_copy_ctor(return_value); - *found = 1; - return return_value; - } - - wrapper = return_value; - - switch (obj->type) { - case XML_DOCUMENT_NODE: - case XML_HTML_DOCUMENT_NODE: - { - ce = dom_document_class_entry; - break; - } - case XML_DTD_NODE: - case XML_DOCUMENT_TYPE_NODE: - { - ce = dom_documenttype_class_entry; - break; - } - case XML_ELEMENT_NODE: - { - ce = dom_element_class_entry; - break; - } - case XML_ATTRIBUTE_NODE: - { - ce = dom_attr_class_entry; - break; - } - case XML_TEXT_NODE: - { - ce = dom_text_class_entry; - break; - } - case XML_COMMENT_NODE: - { - ce = dom_comment_class_entry; - break; - } - case XML_PI_NODE: - { - ce = dom_processinginstruction_class_entry; - break; - } - case XML_ENTITY_REF_NODE: - { - ce = dom_entityreference_class_entry; - break; - } - case XML_ENTITY_DECL: - case XML_ELEMENT_DECL: - { - ce = dom_entity_class_entry; - break; - } - case XML_CDATA_SECTION_NODE: - { - ce = dom_cdatasection_class_entry; - break; - } - case XML_DOCUMENT_FRAG_NODE: - { - ce = dom_documentfragment_class_entry; - break; - } - case XML_NOTATION_NODE: - { - ce = dom_notation_class_entry; - break; - } - case XML_NAMESPACE_DECL: - { - ce = dom_namespace_node_class_entry; - break; - } - default: - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unsupported node type: %d\n", Z_TYPE_P(obj)); - ZVAL_NULL(wrapper); - return wrapper; - } - - object_init_ex(wrapper, ce); - - intern = (dom_object *)zend_objects_get_address(wrapper TSRMLS_CC); - if (obj->doc != NULL) { - if (domobj != NULL) { - intern->document = domobj->document; - } - php_libxml_increment_doc_ref((php_libxml_node_object *)intern, obj->doc TSRMLS_CC); - } - - php_libxml_increment_node_ptr((php_libxml_node_object *)intern, obj, (void *)intern TSRMLS_CC); - return (wrapper); -} -/* }}} end php_domobject_new */ - - -void php_dom_create_implementation(zval **retval TSRMLS_DC) { - object_init_ex(*retval, dom_domimplementation_class_entry); -} - -/* {{{ int dom_hierarchy(xmlNodePtr parent, xmlNodePtr child) */ -int dom_hierarchy(xmlNodePtr parent, xmlNodePtr child) -{ - xmlNodePtr nodep; - - if (parent == NULL || child == NULL || child->doc != parent->doc) { - return SUCCESS; - } - - nodep = parent; - - while (nodep) { - if (nodep == child) { - return FAILURE; - } - nodep = nodep->parent; - } - - return SUCCESS; -} -/* }}} end dom_hierarchy */ - -/* {{{ dom_has_feature(char *feature, char *version) */ -int dom_has_feature(char *feature, char *version) -{ - int retval = 0; - - if (!(strcmp (version, "1.0") && strcmp (version,"2.0") && strcmp(version, ""))) { - if ((!strcasecmp(feature, "Core") && strcmp (version, "1.0")) || !strcasecmp(feature, "XML")) - retval = 1; - } - - return retval; -} -/* }}} end dom_has_feature */ - -xmlNode *dom_get_elements_by_tag_name_ns_raw(xmlNodePtr nodep, char *ns, char *local, int *cur, int index) -{ - xmlNodePtr ret = NULL; - - while (nodep != NULL && (*cur <= index || index == -1)) { - if (nodep->type == XML_ELEMENT_NODE) { - if (xmlStrEqual(nodep->name, local) || xmlStrEqual("*", local)) { - if (ns == NULL || (nodep->ns != NULL && (xmlStrEqual(nodep->ns->href, ns) || xmlStrEqual("*", ns)))) { - if (*cur == index) { - ret = nodep; - break; - } - (*cur)++; - } - } - ret = dom_get_elements_by_tag_name_ns_raw(nodep->children, ns, local, cur, index); - if (ret != NULL) { - break; - } - } - nodep = nodep->next; - } - return ret; -} -/* }}} end dom_element_get_elements_by_tag_name_ns_raw */ - - -/* {{{ void dom_normalize (xmlNodePtr nodep TSRMLS_DC) */ -void dom_normalize (xmlNodePtr nodep TSRMLS_DC) -{ - xmlNodePtr child, nextp, newnextp; - xmlAttrPtr attr; - xmlChar *strContent; - - child = nodep->children; - while(child != NULL) { - switch (child->type) { - case XML_TEXT_NODE: - nextp = child->next; - while (nextp != NULL) { - if (nextp->type == XML_TEXT_NODE) { - newnextp = nextp->next; - strContent = xmlNodeGetContent(nextp); - xmlNodeAddContent(child, strContent); - xmlFree(strContent); - xmlUnlinkNode(nextp); - php_libxml_node_free_resource(nextp TSRMLS_CC); - nextp = newnextp; - } else { - break; - } - } - break; - case XML_ELEMENT_NODE: - dom_normalize (child TSRMLS_CC); - attr = child->properties; - while (attr != NULL) { - dom_normalize((xmlNodePtr) attr TSRMLS_CC); - attr = attr->next; - } - break; - case XML_ATTRIBUTE_NODE: - dom_normalize (child TSRMLS_CC); - break; - default: - break; - } - child = child->next; - } -} -/* }}} end dom_normalize */ - - -/* {{{ void dom_set_old_ns(xmlDoc *doc, xmlNs *ns) */ -void dom_set_old_ns(xmlDoc *doc, xmlNs *ns) { - xmlNs *cur; - - if (doc == NULL) - return; - - if (doc->oldNs == NULL) { - doc->oldNs = (xmlNsPtr) xmlMalloc(sizeof(xmlNs)); - if (doc->oldNs == NULL) { - return; - } - memset(doc->oldNs, 0, sizeof(xmlNs)); - doc->oldNs->type = XML_LOCAL_NAMESPACE; - doc->oldNs->href = xmlStrdup(XML_XML_NAMESPACE); - doc->oldNs->prefix = xmlStrdup((const xmlChar *)"xml"); - } - - cur = doc->oldNs; - while (cur->next != NULL) { - cur = cur->next; - } - cur->next = ns; -} -/* }}} end dom_set_old_ns */ - -int dom_check_qname(char *qname, char **localname, char **prefix, int uri_len, int name_len) { - int errorcode = 0; - - if (name_len > 0) { - *localname = xmlSplitQName2(qname, (xmlChar **) prefix); - if (*localname == NULL) { - *localname = xmlStrdup(qname); - if (*prefix == NULL && uri_len == 0) { - return errorcode; - } - } - if (uri_len == 0 || *localname == NULL || (xmlStrchr(*localname, (xmlChar) ':') != NULL)) { - errorcode = NAMESPACE_ERR; - } - } else { - errorcode = NAMESPACE_ERR; - } - - return errorcode; -} - -/* {{{ xmlNsPtr dom_get_ns(xmlNodePtr nodep, char *uri, int *errorcode, char *prefix) */ -xmlNsPtr dom_get_ns(xmlNodePtr nodep, char *uri, int *errorcode, char *prefix) { - xmlNsPtr nsptr = NULL; - - *errorcode = 0; - - if (! (prefix && !strcmp (prefix, "xml") && strcmp(uri, XML_XML_NAMESPACE))) { - nsptr = xmlNewNs(nodep, uri, prefix); - } - - if (nsptr == NULL) { - *errorcode = NAMESPACE_ERR; - } - - return nsptr; - -} -/* }}} end dom_get_ns */ - -/* {{{ xmlNsPtr dom_get_nsdecl(xmlNode *node, xmlChar *localName) */ -xmlNsPtr dom_get_nsdecl(xmlNode *node, xmlChar *localName) { - xmlNsPtr cur; - xmlNs *ret = NULL; - if (node == NULL) - return NULL; - - if (localName == NULL || xmlStrEqual(localName, "")) { - cur = node->nsDef; - while (cur != NULL) { - if (cur->prefix == NULL && cur->href != NULL) { - ret = cur; - break; - } - cur = cur->next; - } - } else { - cur = node->nsDef; - while (cur != NULL) { - if (cur->prefix != NULL && xmlStrEqual(localName, cur->prefix)) { - ret = cur; - break; - } - cur = cur->next; - } - } - return ret; -} -/* }}} end dom_get_nsdecl */ - -#endif /* HAVE_DOM */ - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * End: - * vim600: noet sw=4 ts=4 fdm=marker - * vim<600: noet sw=4 ts=4 - */ diff --git a/ext/dom/php_dom.h b/ext/dom/php_dom.h deleted file mode 100644 index 64ea2c9e64..0000000000 --- a/ext/dom/php_dom.h +++ /dev/null @@ -1,143 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP Version 5 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2004 The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 3.0 of the PHP license, | - | that is bundled with this package in the file LICENSE, and is | - | available through the world-wide-web at the following url: | - | http://www.php.net/license/3_0.txt. | - | If you did not receive a copy of the PHP license and are unable to | - | obtain it through the world-wide-web, please send a note to | - | license@php.net so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - | Authors: Christian Stocker <chregu@php.net> | - | Rob Richards <rrichards@php.net> | - | Marcus Borger <helly@php.net> | - +----------------------------------------------------------------------+ -*/ - -/* $Id$ */ - -#ifndef PHP_DOM_H -#define PHP_DOM_H - -extern zend_module_entry dom_module_entry; -#define phpext_dom_ptr &dom_module_entry - -#ifdef ZTS -#include "TSRM.h" -#endif - -#include <libxml/parser.h> -#include <libxml/parserInternals.h> -#include <libxml/tree.h> -#include <libxml/uri.h> -#include <libxml/xmlerror.h> -#include <libxml/xinclude.h> -#include <libxml/hash.h> -#if defined(LIBXML_HTML_ENABLED) -#include <libxml/HTMLparser.h> -#include <libxml/HTMLtree.h> -#endif -#if defined(LIBXML_XPATH_ENABLED) -#include <libxml/xpath.h> -#include <libxml/xpathInternals.h> -#endif -#if defined(LIBXML_XPTR_ENABLED) -#include <libxml/xpointer.h> -#endif -#ifdef PHP_WIN32 -#ifndef DOM_EXPORTS -#define DOM_EXPORTS -#endif -#endif - -#include "xml_common.h" -#include "ext/libxml/php_libxml.h" -#include "zend_default_classes.h" -#include "dom_ce.h" -/* DOM API_VERSION, please bump it up, if you change anything in the API - therefore it's easier for the script-programmers to check, what's working how - Can be checked with phpversion("dom"); -*/ -#define DOM_API_VERSION "20031129" -/* Define a custom type for iterating using an unused nodetype */ -#define DOM_NODESET XML_XINCLUDE_START - -typedef struct _dom_nnodemap_object { - dom_object *baseobj; - int nodetype; - xmlHashTable *ht; - xmlChar *local; - xmlChar *ns; - zval *baseobjptr; -} dom_nnodemap_object; - -typedef struct { - zend_object_iterator intern; - zval *curobj; -} php_dom_iterator; - -#include "dom_fe.h" - -dom_object *dom_object_get_data(xmlNodePtr obj); -dom_doc_propsptr dom_get_doc_props(php_libxml_ref_obj *document); -zend_object_value dom_objects_new(zend_class_entry *class_type TSRMLS_DC); -zend_object_value dom_nnodemap_objects_new(zend_class_entry *class_type TSRMLS_DC); -#if defined(LIBXML_XPATH_ENABLED) -zend_object_value dom_xpath_objects_new(zend_class_entry *class_type TSRMLS_DC); -#endif -int dom_get_strict_error(php_libxml_ref_obj *document); -void php_dom_throw_error(int error_code, int strict_error TSRMLS_DC); -void node_list_unlink(xmlNodePtr node TSRMLS_DC); -int dom_check_qname(char *qname, char **localname, char **prefix, int uri_len, int name_len); -xmlNsPtr dom_get_ns(xmlNodePtr node, char *uri, int *errorcode, char *prefix); -void dom_set_old_ns(xmlDoc *doc, xmlNs *ns); -xmlNsPtr dom_get_nsdecl(xmlNode *node, xmlChar *localName); -void dom_normalize (xmlNodePtr nodep TSRMLS_DC); -xmlNode *dom_get_elements_by_tag_name_ns_raw(xmlNodePtr nodep, char *ns, char *local, int *cur, int index); -void php_dom_create_implementation(zval **retval TSRMLS_DC); -int dom_hierarchy(xmlNodePtr parent, xmlNodePtr child); -int dom_has_feature(char *feature, char *version); -int dom_node_is_read_only(xmlNodePtr node); -int dom_node_children_valid(xmlNodePtr node); -void php_dom_create_interator(zval *return_value, int ce_type TSRMLS_DC); -void dom_namednode_iter(dom_object *basenode, int ntype, dom_object *intern, xmlHashTablePtr ht, xmlChar *local, xmlChar *ns); -xmlNodePtr create_notation(const xmlChar *name, const xmlChar *ExternalID, const xmlChar *SystemID); -xmlNode *php_dom_libxml_hash_iter(xmlHashTable *ht, int index); -xmlNode *php_dom_libxml_notation_iter(xmlHashTable *ht, int index); -zend_object_iterator *php_dom_get_iterator(zend_class_entry *ce, zval *object TSRMLS_DC); - -#define REGISTER_DOM_CLASS(ce, name, parent_ce, funcs, entry) \ -INIT_CLASS_ENTRY(ce, name, funcs); \ -ce.create_object = dom_objects_new; \ -entry = zend_register_internal_class_ex(&ce, parent_ce, NULL TSRMLS_CC); - -#define DOM_GET_OBJ(__ptr, __id, __prtype, __intern) { \ - __intern = (dom_object *)zend_object_store_get_object(__id TSRMLS_CC); \ - if (__intern->ptr == NULL || !(__ptr = (__prtype)((php_libxml_node_ptr *)__intern->ptr)->node)) { \ - php_error(E_WARNING, "Couldn't fetch %s", __intern->std.ce->name);\ - RETURN_NULL();\ - } \ -} - -#define DOM_NO_ARGS() \ - if (ZEND_NUM_ARGS() != 0) { \ - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Expects exactly 0 parameters, %d given", ZEND_NUM_ARGS()); \ - return; \ - } - -#define DOM_NOT_IMPLEMENTED() \ - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Not yet implemented"); \ - return; - -#define DOM_NODELIST 0 -#define DOM_NAMEDNODEMAP 1 - -PHP_MINIT_FUNCTION(dom); -PHP_MSHUTDOWN_FUNCTION(dom); -PHP_MINFO_FUNCTION(dom); - -#endif /* PHP_DOM_H */ diff --git a/ext/dom/processinginstruction.c b/ext/dom/processinginstruction.c deleted file mode 100644 index 3a57457122..0000000000 --- a/ext/dom/processinginstruction.c +++ /dev/null @@ -1,137 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP Version 5 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2004 The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 3.0 of the PHP license, | - | that is bundled with this package in the file LICENSE, and is | - | available through the world-wide-web at the following url: | - | http://www.php.net/license/3_0.txt. | - | If you did not receive a copy of the PHP license and are unable to | - | obtain it through the world-wide-web, please send a note to | - | license@php.net so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - | Authors: Christian Stocker <chregu@php.net> | - | Rob Richards <rrichards@php.net> | - +----------------------------------------------------------------------+ -*/ - -/* $Id$ */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "php.h" -#if HAVE_LIBXML && HAVE_DOM -#include "php_dom.h" - - -/* -* class domprocessinginstruction extends domnode -* -* URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#ID-1004215813 -* Since: -*/ - -zend_function_entry php_dom_processinginstruction_class_functions[] = { - PHP_FALIAS("domprocessinginstruction", dom_processinginstruction_processinginstruction, NULL) - {NULL, NULL, NULL} -}; - -/* {{{ proto domnode dom_processinginstruction_processinginstruction(string name, [string value]); */ -PHP_FUNCTION(dom_processinginstruction_processinginstruction) -{ - - zval *id; - xmlNodePtr nodep = NULL, oldnode = NULL; - dom_object *intern; - char *name, *value = NULL; - int name_len, value_len; - - 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) { - return; - } - - if (name_len == 0) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "PI name is required"); - RETURN_FALSE; - } - - nodep = xmlNewPI((xmlChar *) name, (xmlChar *) value); - - if (!nodep) - RETURN_FALSE; - - intern = (dom_object *)zend_object_store_get_object(id TSRMLS_CC); - if (intern != NULL) { - oldnode = (xmlNodePtr)intern->ptr; - if (oldnode != NULL) { - php_libxml_node_free_resource(oldnode TSRMLS_CC); - } - php_libxml_increment_node_ptr((php_libxml_node_object *)intern, nodep, (void *)intern TSRMLS_CC); - } -} -/* }}} end dom_processinginstruction_processinginstruction */ - -/* {{{ proto target string -readonly=yes -URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#ID-1478689192 -Since: -*/ -int dom_processinginstruction_target_read(dom_object *obj, zval **retval TSRMLS_DC) -{ - xmlNodePtr nodep; - - nodep = dom_object_get_node(obj); - - ALLOC_ZVAL(*retval); - ZVAL_STRING(*retval, (char *) (nodep->name), 1); - - return SUCCESS; -} - -/* }}} */ - - - -/* {{{ proto data string -readonly=no -URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#ID-837822393 -Since: -*/ -int dom_processinginstruction_data_read(dom_object *obj, zval **retval TSRMLS_DC) -{ - xmlNodePtr nodep; - xmlChar *content; - - nodep = dom_object_get_node(obj); - - ALLOC_ZVAL(*retval); - - - if ((content = xmlNodeGetContent(nodep)) != NULL) { - ZVAL_STRING(*retval, content, 1); - } else { - ZVAL_EMPTY_STRING(*retval); - } - - xmlFree(content); - - return SUCCESS; -} - -int dom_processinginstruction_data_write(dom_object *obj, zval *newval TSRMLS_DC) -{ - xmlNode *nodep; - - nodep = dom_object_get_node(obj); - xmlNodeSetContentLen(nodep, Z_STRVAL_P(newval), Z_STRLEN_P(newval) + 1); - - return SUCCESS; -} - -/* }}} */ - -#endif diff --git a/ext/dom/string_extend.c b/ext/dom/string_extend.c deleted file mode 100644 index 0e827284c4..0000000000 --- a/ext/dom/string_extend.c +++ /dev/null @@ -1,67 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP Version 5 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2004 The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 3.0 of the PHP license, | - | that is bundled with this package in the file LICENSE, and is | - | available through the world-wide-web at the following url: | - | http://www.php.net/license/3_0.txt. | - | If you did not receive a copy of the PHP license and are unable to | - | obtain it through the world-wide-web, please send a note to | - | license@php.net so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - | Authors: Christian Stocker <chregu@php.net> | - | Rob Richards <rrichards@php.net> | - +----------------------------------------------------------------------+ -*/ - -/* $Id$ */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "php.h" -#if HAVE_LIBXML && HAVE_DOM -#include "php_dom.h" - - -/* -* class domstringextend -* -* URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#i18n-methods-StringExtend -* Since: -*/ - -zend_function_entry php_dom_string_extend_class_functions[] = { - PHP_FALIAS(findOffset16, dom_string_extend_find_offset16, NULL) - PHP_FALIAS(findOffset32, dom_string_extend_find_offset32, NULL) - {NULL, NULL, NULL} -}; - -/* {{{ attribute protos, not implemented yet */ - - -/* {{{ proto int dom_string_extend_find_offset16(int offset32); -URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#i18n-methods-StringExtend-findOffset16 -Since: -*/ -PHP_FUNCTION(dom_string_extend_find_offset16) -{ - DOM_NOT_IMPLEMENTED(); -} -/* }}} end dom_string_extend_find_offset16 */ - - -/* {{{ proto int dom_string_extend_find_offset32(int offset16); -URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#i18n-methods-StringExtend-findOffset32 -Since: -*/ -PHP_FUNCTION(dom_string_extend_find_offset32) -{ - DOM_NOT_IMPLEMENTED(); -} -/* }}} end dom_string_extend_find_offset32 */ -#endif diff --git a/ext/dom/tests/book.xml b/ext/dom/tests/book.xml deleted file mode 100644 index 95de0da866..0000000000 --- a/ext/dom/tests/book.xml +++ /dev/null @@ -1,11 +0,0 @@ -<?xml version="1.0" ?> -<books> - <book> - <title>The Grapes of Wrath</title> - <author>John Steinbeck</author> - </book> - <book> - <title>The Pearl</title> - <author>John Steinbeck</author> - </book> -</books> diff --git a/ext/dom/tests/book.xml.gz b/ext/dom/tests/book.xml.gz Binary files differdeleted file mode 100644 index 2c97807a59..0000000000 --- a/ext/dom/tests/book.xml.gz +++ /dev/null diff --git a/ext/dom/tests/dom001.phpt b/ext/dom/tests/dom001.phpt deleted file mode 100644 index a0c78fbb0a..0000000000 --- a/ext/dom/tests/dom001.phpt +++ /dev/null @@ -1,275 +0,0 @@ ---TEST-- -Test 1: Accessing single node ---SKIPIF-- -<?php require_once('skipif.inc'); ?> ---FILE-- -<?php -require_once("dom_test.inc"); - -echo "Test 1: accessing single nodes from php\n"; -$dom = new domDocument; -$dom->loadxml($xmlstr); -if(!$dom) { - echo "Error while parsing the document\n"; - exit; -} - -// children() of of document would result in a memleak -//$children = $dom->children(); -//print_node_list($children); - -echo "--------- root\n"; -$rootnode = $dom->documentElement; -print_node($rootnode); - -echo "--------- children of root\n"; -$children = $rootnode->childNodes; -print_node_list($children); - -// The last node should be identical with the last entry in the children array -echo "--------- last\n"; -$last = $rootnode->lastChild; -print_node($last); - -// The parent of this last node is the root again -echo "--------- parent\n"; -$parent = $last->parentNode; -print_node($parent); - -// The children of this parent are the same children as one above -echo "--------- children of parent\n"; -$children = $parent->childNodes; -print_node_list($children); - -echo "--------- creating a new attribute\n"; -//This is worthless -//$attr = $dom->createAttribute("src", "picture.gif"); -//print_r($attr); - -//$rootnode->set_attributeNode($attr); -$attr = $rootnode->setAttribute("src", "picture.gif"); -$attr = $rootnode->getAttribute("src"); -print_r($attr); -print "\n"; - -echo "--------- Get Attribute Node\n"; -$attr = $rootnode->getAttributeNode("src"); -print_node($attr); - -echo "--------- Remove Attribute Node\n"; -$attr = $rootnode->removeAttribute("src"); -print "Removed " . $attr . " attributes.\n"; - -echo "--------- attributes of rootnode\n"; -$attrs = $rootnode->attributes; -print_node_list($attrs); - -echo "--------- children of an attribute\n"; -$children = $attrs->item(0)->childNodes; -print_node_list($children); - -echo "--------- Add child to root\n"; -$myelement = new domElement("Silly", "Symphony"); -$newchild = $rootnode->appendChild($myelement); -print_node($newchild); -print $dom->saveXML(); -print "\n"; - -echo "--------- Find element by tagname\n"; -echo " Using dom\n"; -$children = $dom->getElementsByTagname("Silly"); -print_node_list($children); - -echo " Using elem\n"; -$children = $rootnode->getElementsByTagName("Silly"); -print_node_list($children); - -echo "--------- Unlink Node\n"; -print_node($children->item(0)); -$rootnode->removeChild($children->item(0)); -print_node_list($rootnode->childNodes); -print $dom->savexml(); - -echo "--------- Find element by id\n"; -print ("Not implemented\n"); - -echo "--------- Check various node_name return values\n"; -print ("Not needed\n"); - -?> ---EXPECT-- -Test 1: accessing single nodes from php ---------- root -Node Name: chapter -Node Type: 1 -Num Children: 4 - ---------- children of root -Node Name: title -Node Type: 1 -Num Children: 1 -Node Content: Title - -Node Name: #text -Node Type: 3 -Num Children: 0 -Node Content: - - -Node Name: para -Node Type: 1 -Num Children: 7 - -Node Name: #text -Node Type: 3 -Num Children: 0 -Node Content: - - ---------- last -Node Name: #text -Node Type: 3 -Num Children: 0 -Node Content: - - ---------- parent -Node Name: chapter -Node Type: 1 -Num Children: 4 - ---------- children of parent -Node Name: title -Node Type: 1 -Num Children: 1 -Node Content: Title - -Node Name: #text -Node Type: 3 -Num Children: 0 -Node Content: - - -Node Name: para -Node Type: 1 -Num Children: 7 - -Node Name: #text -Node Type: 3 -Num Children: 0 -Node Content: - - ---------- creating a new attribute -picture.gif ---------- Get Attribute Node -Node Name: src -Node Type: 2 -Num Children: 1 -Node Content: picture.gif - ---------- Remove Attribute Node -Removed 1 attributes. ---------- attributes of rootnode -Node Name: language -Node Type: 2 -Num Children: 1 -Node Content: en - ---------- children of an attribute -Node Name: #text -Node Type: 3 -Num Children: 0 -Node Content: en - ---------- Add child to root -Node Name: Silly -Node Type: 1 -Num Children: 1 -Node Content: Symphony - -<?xml version="1.0" standalone="yes"?> -<!DOCTYPE chapter SYSTEM "/share/sgml/Norman_Walsh/db3xml10/db3xml10.dtd" [ -<!ENTITY sp "spanish"> -]> -<!-- lsfj --> -<chapter language="en"><title language="en">Title</title> -<para language="ge"> -&sp; -<!-- comment --> -<informaltable language="&sp;kkk"> -<tgroup cols="3"> -<tbody> -<row><entry>a1</entry><entry morerows="1">b1</entry><entry>c1</entry></row> -<row><entry>a2</entry><entry>c2</entry></row> -<row><entry>a3</entry><entry>b3</entry><entry>c3</entry></row> -</tbody> -</tgroup> -</informaltable> -</para> -<Silly>Symphony</Silly></chapter> - ---------- Find element by tagname - Using dom -Node Name: Silly -Node Type: 1 -Num Children: 1 -Node Content: Symphony - - Using elem -Node Name: Silly -Node Type: 1 -Num Children: 1 -Node Content: Symphony - ---------- Unlink Node -Node Name: Silly -Node Type: 1 -Num Children: 1 -Node Content: Symphony - -Node Name: title -Node Type: 1 -Num Children: 1 -Node Content: Title - -Node Name: #text -Node Type: 3 -Num Children: 0 -Node Content: - - -Node Name: para -Node Type: 1 -Num Children: 7 - -Node Name: #text -Node Type: 3 -Num Children: 0 -Node Content: - - -<?xml version="1.0" standalone="yes"?> -<!DOCTYPE chapter SYSTEM "/share/sgml/Norman_Walsh/db3xml10/db3xml10.dtd" [ -<!ENTITY sp "spanish"> -]> -<!-- lsfj --> -<chapter language="en"><title language="en">Title</title> -<para language="ge"> -&sp; -<!-- comment --> -<informaltable language="&sp;kkk"> -<tgroup cols="3"> -<tbody> -<row><entry>a1</entry><entry morerows="1">b1</entry><entry>c1</entry></row> -<row><entry>a2</entry><entry>c2</entry></row> -<row><entry>a3</entry><entry>b3</entry><entry>c3</entry></row> -</tbody> -</tgroup> -</informaltable> -</para> -</chapter> ---------- Find element by id -Not implemented ---------- Check various node_name return values -Not needed diff --git a/ext/dom/tests/dom002.phpt b/ext/dom/tests/dom002.phpt deleted file mode 100644 index 2bc0717d64..0000000000 --- a/ext/dom/tests/dom002.phpt +++ /dev/null @@ -1,57 +0,0 @@ ---TEST-- -Test 2: getElementsByTagName() / getElementsByTagNameNS() ---SKIPIF-- -<?php require_once('skipif.php'); ?> ---FILE-- -<?php -$xml = <<<HERE -<?xml version="1.0" encoding="ISO-8859-1" ?> -<foo xmlns="http://www.example.com/ns/foo" - xmlns:fubar="http://www.example.com/ns/fubar"> - <bar><test1 /></bar> - <bar><test2 /></bar> - <fubar:bar><test3 /></fubar:bar> - <fubar:bar><test4 /></fubar:bar> -</foo> -HERE; - -function dump($elems) { - foreach ($elems as $elem) { - var_dump($elem->nodeName); - dump($elem->childNodes); - } -} - -$dom = new DOMDocument(); -$dom->loadXML($xml); -$doc = $dom->documentElement; -dump($dom->getElementsByTagName('bar')); -dump($doc->getElementsByTagName('bar')); -dump($dom->getElementsByTagNameNS('http://www.example.com/ns/fubar', 'bar')); -dump($doc->getElementsByTagNameNS('http://www.example.com/ns/fubar', 'bar')); -?> ---EXPECT-- -string(3) "bar" -string(5) "test1" -string(3) "bar" -string(5) "test2" -string(9) "fubar:bar" -string(5) "test3" -string(9) "fubar:bar" -string(5) "test4" -string(3) "bar" -string(5) "test1" -string(3) "bar" -string(5) "test2" -string(9) "fubar:bar" -string(5) "test3" -string(9) "fubar:bar" -string(5) "test4" -string(9) "fubar:bar" -string(5) "test3" -string(9) "fubar:bar" -string(5) "test4" -string(9) "fubar:bar" -string(5) "test3" -string(9) "fubar:bar" -string(5) "test4" diff --git a/ext/dom/tests/dom003.phpt b/ext/dom/tests/dom003.phpt deleted file mode 100644 index 40ddb1f775..0000000000 --- a/ext/dom/tests/dom003.phpt +++ /dev/null @@ -1,33 +0,0 @@ ---TEST-- -Test 3: Exception Test ---SKIPIF-- -<?php require_once('skipif.inc'); ?> ---FILE-- -<?php - -$dom = new domdocument; -$dom->load(dirname(__FILE__)."/book.xml"); -$rootNode = $dom->documentElement; -print "--- Catch exception with try/catch\n"; -try { - $rootNode->appendChild($rootNode); -} catch (domexception $e) { - var_dump($e); -} -print "--- Don't catch exception with try/catch\n"; -$rootNode->appendChild($rootNode); - - -?> ---EXPECTF-- ---- Catch exception with try/catch -object(domexception)#%d (6) { - ["code"]=> - int(3) -} ---- Don't catch exception with try/catch - -Fatal error: Uncaught exception 'domexception' with message 'Hierarchy Request Error' in %sdom003.php:%d -Stack trace: -#0 {main} - thrown in %sdom003.php on line %d diff --git a/ext/dom/tests/dom004.phpt b/ext/dom/tests/dom004.phpt deleted file mode 100644 index 7f36eb3692..0000000000 --- a/ext/dom/tests/dom004.phpt +++ /dev/null @@ -1,25 +0,0 @@ ---TEST-- -Test 4: Streams Test ---SKIPIF-- -<?php -require_once('skipif.inc'); -array_search('compress.zlib', stream_get_wrappers()) || die('skip compress.zlib wrapper is not available'); -?> ---FILE-- -<?php -$dom = new domdocument; -$dom->load("compress.zlib://".dirname(__FILE__)."/book.xml.gz"); -print $dom->saveXML(); - ---EXPECT-- -<?xml version="1.0"?> -<books> - <book> - <title>The Grapes of Wrath</title> - <author>John Steinbeck</author> - </book> - <book> - <title>The Pearl</title> - <author>John Steinbeck</author> - </book> -</books> diff --git a/ext/dom/tests/dom005.phpt b/ext/dom/tests/dom005.phpt deleted file mode 100644 index ff8a79a5ff..0000000000 --- a/ext/dom/tests/dom005.phpt +++ /dev/null @@ -1,36 +0,0 @@ ---TEST-- -Test 5: HTML Test ---SKIPIF-- -<?php require_once('skipif.inc'); ?> ---FILE-- -<?php -$dom = new domdocument; -$dom->loadHTMLFile(dirname(__FILE__)."/test.html"); -print "--- save as XML\n"; - -print adjustDoctype($dom->saveXML()); -print "--- save as HTML\n"; - -print adjustDoctype($dom->saveHTML()); - -function adjustDoctype($xml) { - return str_replace("DOCTYPE HTML","DOCTYPE html",$xml); -} - ---EXPECT-- ---- save as XML -<?xml version="1.0" standalone="yes"?> -<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd"> -<html><head><title>Hello world</title></head><body><p> -This is a not well-formed<br/> -html files with undeclared entities -</p></body></html> ---- save as HTML -<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd"> -<html> -<head><title>Hello world</title></head> -<body><p> -This is a not well-formed<br> -html files with undeclared entities -</p></body> -</html> diff --git a/ext/dom/tests/dom006.phpt b/ext/dom/tests/dom006.phpt deleted file mode 100644 index 7f393003d5..0000000000 --- a/ext/dom/tests/dom006.phpt +++ /dev/null @@ -1,46 +0,0 @@ ---TEST-- -Test 6: Extends Test ---SKIPIF-- -<?php require_once('skipif.inc'); ?> ---FILE-- -<?php - -Class books extends domDocument { - function __construct() { - /* We must first call the constructor for the parent to create the document - otherwise this class will not work */ - parent::__construct(); - } - - function addBook($title, $author) { - $titleElement = $this->createElement("title"); - $titleElement->appendChild($this->createTextNode($title)); - $authorElement = $this->createElement("author"); - $authorElement->appendChild($this->createTextNode($author)); - - $bookElement = $this->createElement("book"); - - $bookElement->appendChild($titleElement); - $bookElement->appendChild($authorElement); - $this->documentElement->appendChild($bookElement); - } - -} - -$dom = new books; - -$dom->load(dirname(__FILE__)."/book.xml"); -$dom->addBook("PHP de Luxe", "Richard Samar, Christian Stocker"); -print $dom->saveXML(); ---EXPECT-- -<?xml version="1.0"?> -<books> - <book> - <title>The Grapes of Wrath</title> - <author>John Steinbeck</author> - </book> - <book> - <title>The Pearl</title> - <author>John Steinbeck</author> - </book> -<book><title>PHP de Luxe</title><author>Richard Samar, Christian Stocker</author></book></books> diff --git a/ext/dom/tests/dom_import_simplexml.phpt b/ext/dom/tests/dom_import_simplexml.phpt deleted file mode 100644 index 81744aa260..0000000000 --- a/ext/dom/tests/dom_import_simplexml.phpt +++ /dev/null @@ -1,27 +0,0 @@ ---TEST-- -Interop Test: Import from SimpleXML ---SKIPIF-- -<?php require_once('skipif.inc'); ?> -<?php if (!extension_loaded('simplexml')) die('skip simplexml extension not available');?> ---FILE-- -<?php -$s = simplexml_load_file(dirname(__FILE__)."/book.xml"); -if(!$s) { - echo "Error while loading the document\n"; - exit; -} -$dom = dom_import_simplexml($s); -print $dom->ownerDocument->saveXML(); -?> ---EXPECT-- -<?xml version="1.0"?> -<books> - <book> - <title>The Grapes of Wrath</title> - <author>John Steinbeck</author> - </book> - <book> - <title>The Pearl</title> - <author>John Steinbeck</author> - </book> -</books> diff --git a/ext/dom/tests/dom_test.inc b/ext/dom/tests/dom_test.inc deleted file mode 100644 index 86b426f8f3..0000000000 --- a/ext/dom/tests/dom_test.inc +++ /dev/null @@ -1,47 +0,0 @@ -<?PHP -$xmlstr = "<?xml version='1.0' standalone='yes'?> -<!DOCTYPE chapter SYSTEM '/share/sgml/Norman_Walsh/db3xml10/db3xml10.dtd' -[ <!ENTITY sp \"spanish\"> -]> -<!-- lsfj --> -<chapter language='en'><title language='en'>Title</title> -<para language='ge'> -&sp; -<!-- comment --> -<informaltable language='&sp;kkk'> -<tgroup cols='3'> -<tbody> -<row><entry>a1</entry><entry morerows='1'>b1</entry><entry>c1</entry></row> -<row><entry>a2</entry><entry>c2</entry></row> -<row><entry>a3</entry><entry>b3</entry><entry>c3</entry></row> -</tbody> -</tgroup> -</informaltable> -</para> -</chapter> "; - -function print_node($node) -{ - print "Node Name: " . $node->nodeName; - print "\nNode Type: " . $node->nodeType; - if ($node->nodeType != 3) { - $child_count = $node->childNodes->length; - } else { - $child_count = 0; - } - print "\nNum Children: " . $child_count; - if($child_count <= 1){ - print "\nNode Content: " . $node->nodeValue; - } - print "\n\n"; -} - -function print_node_list($nodelist) -{ - foreach($nodelist as $node) - { - print_node($node); - } -} - -?> diff --git a/ext/dom/tests/dom_xinclude.phpt b/ext/dom/tests/dom_xinclude.phpt deleted file mode 100644 index 859dd54583..0000000000 --- a/ext/dom/tests/dom_xinclude.phpt +++ /dev/null @@ -1,33 +0,0 @@ ---TEST-- -Test: Xinclude and Streams ---SKIPIF-- -<?php -require_once('skipif.inc'); -array_search('compress.zlib', stream_get_wrappers()) || die('skip compress.zlib wrapper is not available'); -?> ---FILE-- -<?php -$dom = new domdocument; -$dom->load(dirname(__FILE__)."/xinclude.xml"); -$dom->xinclude(); -print $dom->saveXML()."\n"; -foreach ($dom->documentElement->childNodes as $node) { - print $node->nodeName."\n"; -} - ---EXPECT-- -<?xml version="1.0"?> -<foo xmlns:xi="http://www.w3.org/2001/XInclude"> - <book xml:base="compress.zlib://ext/dom/tests/book.xml"> - <title>The Grapes of Wrath</title> - <author>John Steinbeck</author> - </book><book xml:base="compress.zlib://ext/dom/tests/book.xml"> - <title>The Pearl</title> - <author>John Steinbeck</author> - </book> - </foo> - -#text -book -book -#text diff --git a/ext/dom/tests/skipif.inc b/ext/dom/tests/skipif.inc deleted file mode 100644 index 08fd695d97..0000000000 --- a/ext/dom/tests/skipif.inc +++ /dev/null @@ -1 +0,0 @@ -<?php if (!extension_loaded('dom')) die('skip dom extension not available');?>
\ No newline at end of file diff --git a/ext/dom/tests/test.html b/ext/dom/tests/test.html deleted file mode 100644 index fe6d0d3dbc..0000000000 --- a/ext/dom/tests/test.html +++ /dev/null @@ -1,9 +0,0 @@ -<html> -<head> -<title>Hello world</title> -</head> -<body> -This is a not well-formed<br> -html files with undeclared entities -</body> -</html> diff --git a/ext/dom/tests/xinclude.xml b/ext/dom/tests/xinclude.xml deleted file mode 100644 index 27efa91aee..0000000000 --- a/ext/dom/tests/xinclude.xml +++ /dev/null @@ -1,4 +0,0 @@ -<?xml version="1.0"?> -<foo xmlns:xi="http://www.w3.org/2001/XInclude"> - <xi:include href="compress.zlib://ext/dom/tests/book.xml#xpointer(/books/book)"/> - </foo> diff --git a/ext/dom/text.c b/ext/dom/text.c deleted file mode 100644 index d315adaff8..0000000000 --- a/ext/dom/text.c +++ /dev/null @@ -1,190 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP Version 5 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2004 The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 3.0 of the PHP license, | - | that is bundled with this package in the file LICENSE, and is | - | available through the world-wide-web at the following url: | - | http://www.php.net/license/3_0.txt. | - | If you did not receive a copy of the PHP license and are unable to | - | obtain it through the world-wide-web, please send a note to | - | license@php.net so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - | Authors: Christian Stocker <chregu@php.net> | - | Rob Richards <rrichards@php.net> | - +----------------------------------------------------------------------+ -*/ - -/* $Id$ */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "php.h" -#if HAVE_LIBXML && HAVE_DOM -#include "php_dom.h" -#include "dom_ce.h" - -/* -* class domtext extends domcharacterdata -* -* URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#ID-1312295772 -* Since: -*/ - -zend_function_entry php_dom_text_class_functions[] = { - PHP_FALIAS(splitText, dom_text_split_text, NULL) - PHP_FALIAS(isWhitespaceInElementContent, dom_text_is_whitespace_in_element_content, NULL) - PHP_FALIAS(replaceWholeText, dom_text_replace_whole_text, NULL) - PHP_FALIAS(domtext, dom_text_text, NULL) - {NULL, NULL, NULL} -}; - -/* {{{ proto domtext_text([string value]); */ -PHP_FUNCTION(dom_text_text) -{ - - zval *id; - xmlNodePtr nodep = NULL, oldnode = NULL; - dom_object *intern; - char *value = NULL; - int value_len; - - if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O|s", &id, dom_text_class_entry, &value, &value_len) == FAILURE) { - return; - } - - nodep = xmlNewText((xmlChar *) value); - - if (!nodep) - RETURN_FALSE; - - intern = (dom_object *)zend_object_store_get_object(id TSRMLS_CC); - if (intern != NULL) { - oldnode = (xmlNodePtr)intern->ptr; - if (oldnode != NULL) { - php_libxml_node_free_resource(oldnode TSRMLS_CC); - } - php_libxml_increment_node_ptr((php_libxml_node_object *)intern, nodep, (void *)intern TSRMLS_CC); - } -} -/* }}} end dom_text_text */ - -/* {{{ proto wholeText string -readonly=yes -URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-Text3-wholeText -Since: DOM Level 3 -*/ -int dom_text_whole_text_read(dom_object *obj, zval **retval TSRMLS_DC) -{ - xmlNodePtr node; - xmlChar *wholetext; - - node = dom_object_get_node(obj); - - ALLOC_ZVAL(*retval); - wholetext = xmlNodeListGetString(node->doc, node, 1); - ZVAL_STRING(*retval, wholetext, 1); - - xmlFree(wholetext); - - return SUCCESS; -} - -/* }}} */ - - -/* {{{ proto domtext dom_text_split_text(unsigned long offset); -URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-38853C1D -Since: -*/ -PHP_FUNCTION(dom_text_split_text) -{ - xmlChar *cur; - xmlChar *first; - xmlChar *second; - xmlNodePtr node; - xmlNodePtr nnode; - long offset; - int ret; - int length; - dom_object *intern; - - DOM_GET_THIS_OBJ(node, getThis(), xmlNodePtr, intern); - - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &offset) == FAILURE) { - return; - } - - if (node->type != XML_TEXT_NODE) { - RETURN_FALSE; - } - - cur = xmlNodeListGetString(node->doc, node, 1); - if (cur == NULL) { - RETURN_FALSE; - } - length = xmlStrlen(cur); - - if (offset > length || offset < 0) { - xmlFree(cur); - RETURN_FALSE; - } - - first = xmlStrndup(cur, offset); - second = xmlStrdup(cur + offset); - - xmlFree(cur); - - xmlNodeSetContentLen(node, first, offset); - nnode = xmlNewDocText(node->doc, second); - - xmlFree(first); - xmlFree(second); - - if (node->parent != NULL) { - nnode->type = XML_ELEMENT_NODE; - xmlAddNextSibling(node, nnode); - nnode->type = XML_TEXT_NODE; - } - - return_value = php_dom_create_object(nnode, &ret, NULL, return_value, intern TSRMLS_CC); -} -/* }}} end dom_text_split_text */ - - -/* {{{ proto boolean dom_text_is_whitespace_in_element_content(); -URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-Text3-isWhitespaceInElementContent -Since: DOM Level 3 -*/ -PHP_FUNCTION(dom_text_is_whitespace_in_element_content) -{ - xmlNodePtr node; - dom_object *intern; - - DOM_GET_THIS_OBJ(node, getThis(), xmlNodePtr, intern); - - DOM_NO_ARGS(); - - if (xmlIsBlankNode(node)) { - RETURN_TRUE; - } else { - RETURN_FALSE; - } -} -/* }}} end dom_text_is_whitespace_in_element_content */ - - -/* {{{ proto domtext dom_text_replace_whole_text(string content); -URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-Text3-replaceWholeText -Since: DOM Level 3 -*/ -PHP_FUNCTION(dom_text_replace_whole_text) -{ - DOM_NOT_IMPLEMENTED(); -} -/* }}} end dom_text_replace_whole_text */ -#endif diff --git a/ext/dom/typeinfo.c b/ext/dom/typeinfo.c deleted file mode 100644 index da50ce6366..0000000000 --- a/ext/dom/typeinfo.c +++ /dev/null @@ -1,74 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP Version 5 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2004 The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 3.0 of the PHP license, | - | that is bundled with this package in the file LICENSE, and is | - | available through the world-wide-web at the following url: | - | http://www.php.net/license/3_0.txt. | - | If you did not receive a copy of the PHP license and are unable to | - | obtain it through the world-wide-web, please send a note to | - | license@php.net so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - | Authors: Christian Stocker <chregu@php.net> | - | Rob Richards <rrichards@php.net> | - +----------------------------------------------------------------------+ -*/ - -/* $Id$ */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "php.h" -#if HAVE_LIBXML && HAVE_DOM -#include "php_dom.h" - - -/* -* class domtypeinfo -* -* URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#TypeInfo -* Since: DOM Level 3 -*/ - -zend_function_entry php_dom_typeinfo_class_functions[] = { - {NULL, NULL, NULL} -}; - -/* {{{ attribute protos, not implemented yet */ - -/* {{{ proto type_name string -readonly=yes -URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#TypeInfo-typeName -Since: -*/ -int dom_typeinfo_type_name_read(dom_object *obj, zval **retval TSRMLS_DC) -{ - ALLOC_ZVAL(*retval); - ZVAL_NULL(*retval); - return SUCCESS; -} - -/* }}} */ - - - -/* {{{ proto type_namespace string -readonly=yes -URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#TypeInfo-typeNamespace -Since: -*/ -int dom_typeinfo_type_namespace_read(dom_object *obj, zval **retval TSRMLS_DC) -{ - ALLOC_ZVAL(*retval); - ZVAL_NULL(*retval); - return SUCCESS; -} - -/* }}} */ - -#endif diff --git a/ext/dom/userdatahandler.c b/ext/dom/userdatahandler.c deleted file mode 100644 index 7ed1cee203..0000000000 --- a/ext/dom/userdatahandler.c +++ /dev/null @@ -1,55 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP Version 5 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2004 The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 3.0 of the PHP license, | - | that is bundled with this package in the file LICENSE, and is | - | available through the world-wide-web at the following url: | - | http://www.php.net/license/3_0.txt. | - | If you did not receive a copy of the PHP license and are unable to | - | obtain it through the world-wide-web, please send a note to | - | license@php.net so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - | Authors: Christian Stocker <chregu@php.net> | - | Rob Richards <rrichards@php.net> | - +----------------------------------------------------------------------+ -*/ - -/* $Id$ */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "php.h" -#if HAVE_LIBXML && HAVE_DOM -#include "php_dom.h" - - -/* -* class domuserdatahandler -* -* URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#UserDataHandler -* Since: DOM Level 3 -*/ - -zend_function_entry php_dom_userdatahandler_class_functions[] = { - PHP_FALIAS(handle, dom_userdatahandler_handle, NULL) - {NULL, NULL, NULL} -}; - -/* {{{ attribute protos, not implemented yet */ - - -/* {{{ proto dom_void dom_userdatahandler_handle(unsigned short operation, string key, domobject data, node src, node dst); -URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#ID-handleUserDataEvent -Since: -*/ -PHP_FUNCTION(dom_userdatahandler_handle) -{ - DOM_NOT_IMPLEMENTED(); -} -/* }}} end dom_userdatahandler_handle */ -#endif diff --git a/ext/dom/xml_common.h b/ext/dom/xml_common.h deleted file mode 100644 index 987cf86195..0000000000 --- a/ext/dom/xml_common.h +++ /dev/null @@ -1,101 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP Version 5 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2004 The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 3.0 of the PHP license, | - | that is bundled with this package in the file LICENSE, and is | - | available through the world-wide-web at the following url: | - | http://www.php.net/license/3_0.txt. | - | If you did not receive a copy of the PHP license and are unable to | - | obtain it through the world-wide-web, please send a note to | - | license@php.net so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - | Authors: Christian Stocker <chregu@php.net> | - | Rob Richards <rrichards@php.net> | - +----------------------------------------------------------------------+ -*/ - -/* $Id$ */ - -#ifndef PHP_XML_COMMON_H -#define PHP_XML_COMMON_H - -#include "ext/libxml/php_libxml.h" - -typedef struct _dom_doc_props { - int formatoutput; - int validateonparse; - int resolveexternals; - int preservewhitespace; - int substituteentities; - int stricterror; -} dom_doc_props; - -typedef dom_doc_props *dom_doc_propsptr; - -typedef struct _dom_object { - zend_object std; - void *ptr; - php_libxml_ref_obj *document; - HashTable *prop_handler; - zend_object_handle handle; -} dom_object; - -#ifdef PHP_WIN32 -#ifdef PHPAPI -#undef PHPAPI -#endif -#ifdef DOM_EXPORTS -#define PHPAPI __declspec(dllexport) -#else -#define PHPAPI __declspec(dllimport) -#endif /* DOM_EXPORTS */ -#endif /* PHP_WIN32 */ - -#define PHP_DOM_EXPORT(__type) PHPAPI __type - -PHP_DOM_EXPORT(zend_class_entry *) dom_node_class_entry; -PHP_DOM_EXPORT(dom_object *) php_dom_object_get_data(xmlNodePtr obj); -PHP_DOM_EXPORT(zval *) php_dom_create_object(xmlNodePtr obj, int *found, zval *in, zval* return_value, dom_object *domobj TSRMLS_DC); -PHP_DOM_EXPORT(xmlNodePtr) dom_object_get_node(dom_object *obj); - -#define DOM_XMLNS_NAMESPACE \ - (const xmlChar *) "http://www.w3.org/2000/xmlns/" - -#define NODE_GET_OBJ(__ptr, __id, __prtype, __intern) { \ - __intern = (php_libxml_node_object *)zend_object_store_get_object(__id TSRMLS_CC); \ - if (__intern->node == NULL || !(__ptr = (__prtype)__intern->node->node)) { \ - php_error(E_WARNING, "Couldn't fetch %s", __intern->std.ce->name);\ - RETURN_NULL();\ - } \ -} - -#define DOC_GET_OBJ(__ptr, __id, __prtype, __intern) { \ - __intern = (php_libxml_node_object *)zend_object_store_get_object(__id TSRMLS_CC); \ - if (__intern->document != NULL) { \ - if (!(__ptr = (__prtype)__intern->document->ptr)) { \ - php_error(E_WARNING, "Couldn't fetch %s", __intern->std.ce->name);\ - RETURN_NULL();\ - } \ - } \ -} - -#define DOM_RET_OBJ(zval, obj, ret, domobject) \ - if (NULL == (zval = php_dom_create_object(obj, ret, zval, return_value, domobject TSRMLS_CC))) { \ - php_error(E_WARNING, "Cannot create required DOM object"); \ - RETURN_FALSE; \ - } - -#define DOM_GET_THIS(zval) \ - if (NULL == (zval = getThis())) { \ - php_error(E_WARNING, "Underlying object missing"); \ - RETURN_FALSE; \ - } - -#define DOM_GET_THIS_OBJ(__ptr, __id, __prtype, __intern) \ - DOM_GET_THIS(__id); \ - DOM_GET_OBJ(__ptr, __id, __prtype, __intern); - -#endif diff --git a/ext/dom/xpath.c b/ext/dom/xpath.c deleted file mode 100644 index 4b693bb465..0000000000 --- a/ext/dom/xpath.c +++ /dev/null @@ -1,267 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP Version 5 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2004 The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 3.0 of the PHP license, | - | that is bundled with this package in the file LICENSE, and is | - | available through the world-wide-web at the following url: | - | http://www.php.net/license/3_0.txt. | - | If you did not receive a copy of the PHP license and are unable to | - | obtain it through the world-wide-web, please send a note to | - | license@php.net so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - | Authors: Christian Stocker <chregu@php.net> | - | Rob Richards <rrichards@php.net> | - +----------------------------------------------------------------------+ -*/ - -/* $Id$ */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "php.h" -#if HAVE_LIBXML && HAVE_DOM -#include "php_dom.h" - - -/* -* class domxpath -*/ - -#if defined(LIBXML_XPATH_ENABLED) - -zend_function_entry php_dom_xpath_class_functions[] = { - PHP_FALIAS(domxpath, dom_xpath_xpath, NULL) - PHP_FALIAS(register_namespace, dom_xpath_register_ns, NULL) - PHP_FALIAS(query, dom_xpath_query, NULL) - {NULL, NULL, NULL} -}; - -/* {{{ proto domxpath dom_xpath_xpath(domDocument doc); */ -PHP_FUNCTION(dom_xpath_xpath) -{ - zval *id, *doc; - xmlDocPtr docp = NULL; - dom_object *docobj, *intern; - xmlXPathContextPtr ctx, oldctx; - - if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Oo", &id, dom_xpath_class_entry, &doc) == FAILURE) { - return; - } - - DOM_GET_OBJ(docp, doc, xmlDocPtr, docobj); - - ctx = xmlXPathNewContext(docp); - if (ctx == NULL) { - RETURN_FALSE; - } - - intern = (dom_object *)zend_object_store_get_object(id TSRMLS_CC); - if (intern != NULL) { - oldctx = (xmlXPathContextPtr)intern->ptr; - if (oldctx != NULL) { - php_libxml_decrement_doc_ref((php_libxml_node_object *)intern TSRMLS_CC); - xmlXPathFreeContext(oldctx); - } - intern->ptr = ctx; - intern->document = docobj->document; - php_libxml_increment_doc_ref((php_libxml_node_object *)intern, docp TSRMLS_CC); - } -} -/* }}} end dom_xpath_xpath */ - -/* {{{ proto domdocument document document */ -int dom_xpath_document_read(dom_object *obj, zval **retval TSRMLS_DC) -{ - xmlDoc *docp = NULL; - xmlXPathContextPtr ctx; - int ret; - - ctx = (xmlXPathContextPtr) obj->ptr; - - if (ctx) { - docp = (xmlDocPtr) ctx->doc; - } else { - printf("NONE"); - } - - ALLOC_ZVAL(*retval); - if (NULL == (*retval = php_dom_create_object((xmlNodePtr) docp, &ret, NULL, *retval, obj TSRMLS_CC))) { - php_error(E_WARNING, "Cannot create required DOM object"); - return FAILURE; - } - return SUCCESS; -} - -/* {{{ proto boolean dom_xpath_register_ns(string prefix, string uri); */ -PHP_FUNCTION(dom_xpath_register_ns) -{ - zval *id; - xmlXPathContextPtr ctxp; - int prefix_len, ns_uri_len; - dom_object *intern; - unsigned char *prefix, *ns_uri; - - DOM_GET_THIS(id); - - intern = (dom_object *)zend_object_store_get_object(id TSRMLS_CC); - - ctxp = (xmlXPathContextPtr) intern->ptr; - if (ctxp == NULL) { - php_error(E_WARNING, "Invalid XPath Context"); - RETURN_FALSE; - } - - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss", &prefix, &prefix_len, &ns_uri, &ns_uri_len) == FAILURE) { - RETURN_FALSE; - } - - if (xmlXPathRegisterNs(ctxp, prefix, ns_uri) != 0) { - RETURN_FALSE - } - RETURN_TRUE; -} - -static void dom_xpath_iter(zval *baseobj, dom_object *intern) -{ - dom_nnodemap_object *mapptr; - - mapptr = (dom_nnodemap_object *)intern->ptr; - mapptr->baseobjptr = baseobj; - mapptr->nodetype = DOM_NODESET; - -} - -/* {{{ proto domnodelist dom_xpath_query(string expr [,domNode context]); */ -PHP_FUNCTION(dom_xpath_query) -{ - zval *id, *retval, *context = NULL; - xmlXPathContextPtr ctxp; - xmlNodePtr nodep = NULL; - xmlXPathObjectPtr xpathobjp; - int expr_len, ret, nsnbr = 0; - dom_object *intern, *nodeobj; - char *expr; - xmlDoc *docp = NULL; - xmlNsPtr *ns; - - DOM_GET_THIS(id); - - intern = (dom_object *)zend_object_store_get_object(id TSRMLS_CC); - - ctxp = (xmlXPathContextPtr) intern->ptr; - if (ctxp == NULL) { - php_error(E_WARNING, "Invalid XPath Context"); - RETURN_FALSE; - } - - docp = (xmlDocPtr) ctxp->doc; - if (docp == NULL) { - php_error(E_WARNING, "Invalid XPath Document Pointer"); - RETURN_FALSE; - } - - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|o", &expr, &expr_len, &context) == FAILURE) { - RETURN_FALSE; - } - - if (context != NULL) { - DOM_GET_OBJ(nodep, context, xmlNodePtr, nodeobj); - } - - if (!nodep) { - nodep = xmlDocGetRootElement(docp); - } - - if (nodep && docp != nodep->doc) { - php_error(E_WARNING, "Node From Wrong Document"); - RETURN_FALSE; - } - - ctxp->node = nodep; - - /* Register namespaces in the node */ - ns = xmlGetNsList(docp, nodep); - - if (ns != NULL) { - while (ns[nsnbr] != NULL) - nsnbr++; - } - - - ctxp->namespaces = ns; - ctxp->nsNr = nsnbr; - - xpathobjp = xmlXPathEvalExpression(expr, ctxp); - ctxp->node = NULL; - - if (ns != NULL) { - xmlFree(ns); - ctxp->namespaces = NULL; - ctxp->nsNr = 0; - } - - if (! xpathobjp) { - RETURN_FALSE; - } - - - if (xpathobjp->type == XPATH_NODESET) { - int i; - xmlNodeSetPtr nodesetp; - - if (NULL == (nodesetp = xpathobjp->nodesetval)) { - xmlXPathFreeObject (xpathobjp); - RETURN_FALSE; - } - - MAKE_STD_ZVAL(retval); - array_init(retval); - - for (i = 0; i < nodesetp->nodeNr; i++) { - xmlNodePtr node = nodesetp->nodeTab[i]; - zval *child; - - MAKE_STD_ZVAL(child); - - if (node->type == XML_NAMESPACE_DECL) { - xmlNsPtr curns; - xmlNodePtr nsparent; - - nsparent = node->_private; - curns = xmlNewNs(NULL, node->name, NULL); - if (node->children) { - curns->prefix = xmlStrdup((char *) node->children); - } - if (node->children) { - node = xmlNewDocNode(docp, NULL, (char *) node->children, node->name); - } else { - node = xmlNewDocNode(docp, NULL, "xmlns", node->name); - } - node->type = XML_NAMESPACE_DECL; - node->parent = nsparent; - node->ns = curns; - } - child = php_dom_create_object(node, &ret, NULL, child, intern TSRMLS_CC); - add_next_index_zval(retval, child); - } - } else { - retval = NULL; - } - - php_dom_create_interator(return_value, DOM_NODELIST TSRMLS_CC); - intern = (dom_object *)zend_objects_get_address(return_value TSRMLS_CC); - dom_xpath_iter(retval, intern); - - xmlXPathFreeObject(xpathobjp); -} -/* }}} end dom_xpath_query */ - -#endif /* LIBXML_XPATH_ENABLED */ - -/* }}} */ -#endif |