mirror of
https://github.com/php/php-src.git
synced 2024-11-24 18:34:21 +08:00
Inital cut of new dom extension
PHP5 only
This commit is contained in:
parent
bf0e2751bb
commit
1b046ed40e
12
ext/dom/TODO
Normal file
12
ext/dom/TODO
Normal file
@ -0,0 +1,12 @@
|
||||
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)
|
||||
|
||||
|
226
ext/dom/attr.c
Normal file
226
ext/dom/attr.c
Normal file
@ -0,0 +1,226 @@
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| PHP Version 4 |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 1997-2003 The PHP Group |
|
||||
+----------------------------------------------------------------------+
|
||||
| This source file is subject to version 2.02 of the PHP license, |
|
||||
| that is bundled with this package in the file LICENSE, and is |
|
||||
| available at through the world-wide-web at |
|
||||
| http://www.php.net/license/2_02.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"
|
||||
#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;
|
||||
|
||||
id = getThis();
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|s", &name, &name_len, &value, &value_len) == FAILURE) {
|
||||
return;
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
intern = (dom_object *)zend_object_store_get_object(id TSRMLS_CC);
|
||||
if (intern != NULL) {
|
||||
oldnode = (xmlNodePtr)intern->ptr;
|
||||
if (oldnode != NULL) {
|
||||
node_free_resource(oldnode TSRMLS_CC);
|
||||
}
|
||||
php_dom_set_object(id, (xmlNodePtr) nodep 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 = obj->ptr;
|
||||
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 = obj->ptr;
|
||||
|
||||
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 = obj->ptr;
|
||||
|
||||
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)
|
||||
{
|
||||
|
||||
zval *wrapper;
|
||||
xmlNodePtr nodep, nodeparent;
|
||||
int ret;
|
||||
|
||||
nodep = obj->ptr;
|
||||
|
||||
nodeparent = nodep->parent;
|
||||
if (!nodeparent) {
|
||||
return FAILURE;
|
||||
}
|
||||
|
||||
wrapper = dom_object_get_data(nodeparent);
|
||||
if (wrapper == NULL) {
|
||||
ALLOC_ZVAL(*retval);
|
||||
}
|
||||
if (NULL == (*retval = php_dom_create_object(nodeparent, &ret, wrapper, *retval TSRMLS_CC))) {
|
||||
php_error_docref(NULL TSRMLS_CC, 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)
|
||||
{
|
||||
DOM_NOT_IMPLEMENTED();
|
||||
}
|
||||
/* }}} end dom_attr_is_id */
|
73
ext/dom/cdatasection.c
Normal file
73
ext/dom/cdatasection.c
Normal file
@ -0,0 +1,73 @@
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| PHP Version 4 |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 1997-2003 The PHP Group |
|
||||
+----------------------------------------------------------------------+
|
||||
| This source file is subject to version 2.02 of the PHP license, |
|
||||
| that is bundled with this package in the file LICENSE, and is |
|
||||
| available at through the world-wide-web at |
|
||||
| http://www.php.net/license/2_02.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"
|
||||
#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;
|
||||
|
||||
id = getThis();
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &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) {
|
||||
node_free_resource(oldnode TSRMLS_CC);
|
||||
}
|
||||
php_dom_set_object(id, nodep TSRMLS_CC);
|
||||
}
|
||||
}
|
||||
/* }}} end dom_cdatasection_cdatasection */
|
190
ext/dom/characterdata.c
Normal file
190
ext/dom/characterdata.c
Normal file
@ -0,0 +1,190 @@
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| PHP Version 4 |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 1997-2003 The PHP Group |
|
||||
+----------------------------------------------------------------------+
|
||||
| This source file is subject to version 2.02 of the PHP license, |
|
||||
| that is bundled with this package in the file LICENSE, and is |
|
||||
| available at through the world-wide-web at |
|
||||
| http://www.php.net/license/2_02.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"
|
||||
#include "php_dom.h"
|
||||
|
||||
|
||||
/*
|
||||
* class domcharacterdata extends domnode
|
||||
*
|
||||
* URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#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#ID-72AB8359
|
||||
Since:
|
||||
*/
|
||||
int dom_characterdata_data_read(dom_object *obj, zval **retval TSRMLS_DC)
|
||||
{
|
||||
xmlNodePtr nodep;
|
||||
xmlChar *content;
|
||||
|
||||
nodep = obj->ptr;
|
||||
|
||||
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 = obj->ptr;
|
||||
xmlNodeSetContentLen(nodep, Z_STRVAL_P(newval), Z_STRLEN_P(newval) + 1);
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
/* }}} */
|
||||
|
||||
|
||||
long dom_utf16Length (xmlChar *utf8str) {
|
||||
long len = 0L, i;
|
||||
char c;
|
||||
|
||||
for (i = 0L; (c = utf8str[i]) != '\0'; i++)
|
||||
if ((c & 0xf8) == 0xf0)
|
||||
len += 2L;
|
||||
else if ((c & 0xc0) != 0x80)
|
||||
len++;
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
/* {{{ proto length unsigned long
|
||||
readonly=yes
|
||||
URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#ID-7D61178C
|
||||
Since:
|
||||
*/
|
||||
int dom_characterdata_length_read(dom_object *obj, zval **retval TSRMLS_DC)
|
||||
{
|
||||
xmlNodePtr nodep;
|
||||
xmlChar *content;
|
||||
long length;
|
||||
|
||||
nodep = obj->ptr;
|
||||
|
||||
ALLOC_ZVAL(*retval);
|
||||
|
||||
content = xmlNodeGetContent(nodep);
|
||||
length = dom_utf16Length(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#ID-6531BCCF
|
||||
Since:
|
||||
*/
|
||||
PHP_FUNCTION(dom_characterdata_substring_data)
|
||||
{
|
||||
DOM_NOT_IMPLEMENTED();
|
||||
}
|
||||
/* }}} 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#ID-32791A2F
|
||||
Since:
|
||||
*/
|
||||
PHP_FUNCTION(dom_characterdata_append_data)
|
||||
{
|
||||
zval *id;
|
||||
xmlNode *nodep;
|
||||
char *arg;
|
||||
int arg_len;
|
||||
|
||||
|
||||
DOM_GET_THIS_OBJ(nodep, id, xmlNodePtr);
|
||||
|
||||
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#ID-3EDB695F
|
||||
Since:
|
||||
*/
|
||||
PHP_FUNCTION(dom_characterdata_insert_data)
|
||||
{
|
||||
DOM_NOT_IMPLEMENTED();
|
||||
}
|
||||
/* }}} 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#ID-7C603781
|
||||
Since:
|
||||
*/
|
||||
PHP_FUNCTION(dom_characterdata_delete_data)
|
||||
{
|
||||
DOM_NOT_IMPLEMENTED();
|
||||
}
|
||||
/* }}} 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#ID-E5CBA7FB
|
||||
Since:
|
||||
*/
|
||||
PHP_FUNCTION(dom_characterdata_replace_data)
|
||||
{
|
||||
DOM_NOT_IMPLEMENTED();
|
||||
}
|
||||
/* }}} end dom_characterdata_replace_data */
|
72
ext/dom/comment.c
Normal file
72
ext/dom/comment.c
Normal file
@ -0,0 +1,72 @@
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| PHP Version 4 |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 1997-2003 The PHP Group |
|
||||
+----------------------------------------------------------------------+
|
||||
| This source file is subject to version 2.02 of the PHP license, |
|
||||
| that is bundled with this package in the file LICENSE, and is |
|
||||
| available at through the world-wide-web at |
|
||||
| http://www.php.net/license/2_02.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"
|
||||
#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;
|
||||
|
||||
id = getThis();
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s", &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) {
|
||||
node_free_resource(oldnode TSRMLS_CC);
|
||||
}
|
||||
php_dom_set_object(id, nodep TSRMLS_CC);
|
||||
}
|
||||
}
|
||||
/* }}} end dom_comment_comment */
|
81
ext/dom/config.m4
Normal file
81
ext/dom/config.m4
Normal file
@ -0,0 +1,81 @@
|
||||
dnl
|
||||
dnl $Id$
|
||||
dnl
|
||||
|
||||
AC_DEFUN(PHP_DOM_CHECK_VERSION,[
|
||||
old_CPPFLAGS=$CPPFLAGS
|
||||
CPPFLAGS=-I$DOM_DIR/include$DOM_DIR_ADD
|
||||
AC_MSG_CHECKING(for libxml version)
|
||||
AC_EGREP_CPP(yes,[
|
||||
#include <libxml/xmlversion.h>
|
||||
#if LIBXML_VERSION >= 20414
|
||||
yes
|
||||
#endif
|
||||
],[
|
||||
AC_MSG_RESULT(>= 2.4.14)
|
||||
],[
|
||||
AC_MSG_ERROR(libxml version 2.4.14 or greater required.)
|
||||
])
|
||||
CPPFLAGS=$old_CPPFLAGS
|
||||
])
|
||||
|
||||
PHP_ARG_WITH(dom5, for DOM support,
|
||||
[ --with-dom5[=DIR] Include new DOM support (requires libxml >= 2.4.14).
|
||||
DIR is the libxml install directory.])
|
||||
|
||||
if test -z "$PHP_ZLIB_DIR"; then
|
||||
PHP_ARG_WITH(zlib-dir, for the location of libz,
|
||||
[ --with-zlib-dir[=DIR] DOM: Set the path to libz install prefix.], no, no)
|
||||
fi
|
||||
|
||||
if test "$PHP_DOM5" != "no"; then
|
||||
|
||||
DOM_DIR_ADD=""
|
||||
if test -r $PHP_DOM5/include/libxml2/libxml/tree.h; then
|
||||
DOM_DIR=$PHP_DOM5
|
||||
DOM_DIR_ADD="/libxml2"
|
||||
elif test -r $PHP_DOM5/include/libxml/tree.h; then
|
||||
DOM_DIR=$PHP_DOM5
|
||||
else
|
||||
for i in /usr/local /usr; do
|
||||
test -r $i/include/libxml/tree.h && DOM_DIR=$i
|
||||
test -r $i/include/libxml2/libxml/tree.h && DOM_DIR=$i && DOM_DIR_ADD="/libxml2"
|
||||
done
|
||||
fi
|
||||
|
||||
if test -z "$DOM_DIR"; then
|
||||
AC_MSG_RESULT(not found)
|
||||
AC_MSG_ERROR(Please reinstall the libxml >= 2.4.14 distribution)
|
||||
fi
|
||||
|
||||
PHP_DOM_CHECK_VERSION
|
||||
|
||||
if test -f $DOM_DIR/lib/libxml2.a -o -f $DOM_DIR/lib/libxml2.$SHLIB_SUFFIX_NAME ; then
|
||||
DOM_LIBNAME=xml2
|
||||
else
|
||||
DOM_LIBNAME=xml
|
||||
fi
|
||||
|
||||
XML2_CONFIG=$DOM_DIR/bin/xml2-config
|
||||
|
||||
if test -x $XML2_CONFIG; then
|
||||
DOM_LIBS=`$XML2_CONFIG --libs`
|
||||
PHP_EVAL_LIBLINE($DOM_LIBS, DOM_SHARED_LIBADD)
|
||||
else
|
||||
PHP_ADD_LIBRARY_WITH_PATH($DOM_LIBNAME, $DOM_DIR/lib, DOM_SHARED_LIBADD)
|
||||
fi
|
||||
|
||||
PHP_ADD_INCLUDE($DOM_DIR/include$DOM_DIR_ADD)
|
||||
|
||||
if test "$PHP_ZLIB_DIR" = "no"; then
|
||||
AC_MSG_ERROR(DOM requires ZLIB. Use --with-zlib-dir=<DIR>)
|
||||
else
|
||||
PHP_ADD_LIBRARY_WITH_PATH(z, $PHP_ZLIB_DIR/lib, DOM_SHARED_LIBADD)
|
||||
fi
|
||||
|
||||
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 typeinfo.c domerror.c domlocator.c namednodemap.c userdatahandler.c , $ext_shared)
|
||||
PHP_SUBST(DOM_SHARED_LIBADD)
|
||||
fi
|
||||
|
||||
|
1125
ext/dom/document.c
Normal file
1125
ext/dom/document.c
Normal file
File diff suppressed because it is too large
Load Diff
66
ext/dom/documentfragment.c
Normal file
66
ext/dom/documentfragment.c
Normal file
@ -0,0 +1,66 @@
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| PHP Version 4 |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 1997-2003 The PHP Group |
|
||||
+----------------------------------------------------------------------+
|
||||
| This source file is subject to version 2.02 of the PHP license, |
|
||||
| that is bundled with this package in the file LICENSE, and is |
|
||||
| available at through the world-wide-web at |
|
||||
| http://www.php.net/license/2_02.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"
|
||||
#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;
|
||||
|
||||
id = getThis();
|
||||
|
||||
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) {
|
||||
node_free_resource(oldnode TSRMLS_CC);
|
||||
}
|
||||
php_dom_set_object(id, nodep TSRMLS_CC);
|
||||
}
|
||||
}
|
||||
/* }}} end dom_documentfragment_documentfragment */
|
267
ext/dom/documenttype.c
Normal file
267
ext/dom/documenttype.c
Normal file
@ -0,0 +1,267 @@
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| PHP Version 4 |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 1997-2003 The PHP Group |
|
||||
+----------------------------------------------------------------------+
|
||||
| This source file is subject to version 2.02 of the PHP license, |
|
||||
| that is bundled with this package in the file LICENSE, and is |
|
||||
| available at through the world-wide-web at |
|
||||
| http://www.php.net/license/2_02.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"
|
||||
#include "php_dom.h"
|
||||
|
||||
typedef struct _nodeIterator nodeIterator;
|
||||
struct _nodeIterator {
|
||||
int cur;
|
||||
int index;
|
||||
xmlNode *node;
|
||||
};
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* 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 = obj->ptr;
|
||||
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;
|
||||
nodeIterator *iter;
|
||||
xmlNode *nodep = NULL;
|
||||
int ret, htsize, index = 0;
|
||||
|
||||
doctypep = obj->ptr;
|
||||
|
||||
ALLOC_ZVAL(*retval);
|
||||
array_init(*retval);
|
||||
|
||||
entityht = (xmlHashTable *) doctypep->entities;
|
||||
if (entityht) {
|
||||
if ((htsize = xmlHashSize(entityht)) > 0) {
|
||||
iter = emalloc(sizeof(nodeIterator));
|
||||
while (index < htsize) {
|
||||
iter->cur = 0;
|
||||
iter->index = index;
|
||||
iter->node = NULL;
|
||||
xmlHashScan(entityht, itemHashScanner, iter);
|
||||
index++;
|
||||
nodep = iter->node;
|
||||
if (nodep != NULL) {
|
||||
zval *child = NULL;
|
||||
zval *wrapper;
|
||||
wrapper = dom_object_get_data(nodep);
|
||||
if (wrapper == NULL) {
|
||||
MAKE_STD_ZVAL(child);
|
||||
}
|
||||
child = php_dom_create_object(nodep, &ret, wrapper, child TSRMLS_CC);
|
||||
add_assoc_zval(*retval, (char *) nodep->name, child);
|
||||
}
|
||||
}
|
||||
efree(iter);
|
||||
}
|
||||
}
|
||||
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;
|
||||
nodeIterator *iter;
|
||||
xmlNode *nodep = NULL;
|
||||
int ret, htsize, index = 0;
|
||||
|
||||
doctypep = obj->ptr;
|
||||
|
||||
MAKE_STD_ZVAL(*retval);
|
||||
array_init(*retval);
|
||||
|
||||
notationht = (xmlHashTable *) doctypep->notations;
|
||||
if (notationht) {
|
||||
if ((htsize = xmlHashSize(notationht)) > 0) {
|
||||
iter = emalloc(sizeof(nodeIterator));
|
||||
while (index < htsize) {
|
||||
iter->cur = 0;
|
||||
iter->index = index;
|
||||
iter->node = NULL;
|
||||
xmlHashScan(notationht, itemHashScanner, iter);
|
||||
index++;
|
||||
nodep = iter->node;
|
||||
if (nodep != NULL) {
|
||||
zval *child = NULL;
|
||||
zval *wrapper;
|
||||
wrapper = dom_object_get_data(nodep);
|
||||
if (wrapper == NULL) {
|
||||
MAKE_STD_ZVAL(child);
|
||||
}
|
||||
child = php_dom_create_object(nodep, &ret, wrapper, child TSRMLS_CC);
|
||||
add_assoc_zval(*retval, (char *) nodep->name, child);
|
||||
}
|
||||
}
|
||||
efree(iter);
|
||||
}
|
||||
}
|
||||
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 = obj->ptr;
|
||||
|
||||
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 = obj->ptr;
|
||||
|
||||
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 = obj->ptr;
|
||||
|
||||
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;
|
||||
|
||||
}
|
||||
|
||||
/* }}} */
|
||||
|
||||
|
246
ext/dom/dom.dsp
Normal file
246
ext/dom/dom.dsp
Normal file
@ -0,0 +1,246 @@
|
||||
# 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 HAVE_DOMXSLT=1 /D LIBXML_STATIC=1 /D LIBXSLT_STATIC=1 /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 php4ts.lib /nologo /dll /machine:I386
|
||||
# ADD LINK32 wsock32.lib php4ts.lib libxml2_a.lib libxslt_a.lib iconv.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 /machine:I386 /out:"..\..\Release_TS/php_dom.dll" /libpath:"..\..\Release_TS" /libpath:"..\..\Release_TS_Inline" /libpath:"..\..\..\bindlib_w32\Release" /libpath:"..\..\..\php_build\lib\libxslt"
|
||||
# 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 /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_STATIC=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 php4ts.lib /nologo /dll /machine:I386
|
||||
# ADD LINK32 php4ts_debug.lib ws2_32.lib libxml2_a.lib iconv.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" /libpath:"..\..\Debug_TS" /libpath:"..\..\..\bindlib_w32\Release" /libpath:"..\..\..\php_build\lib\libxslt"
|
||||
|
||||
!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
|
||||
# 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
|
54
ext/dom/dom_ce.h
Normal file
54
ext/dom/dom_ce.h
Normal file
@ -0,0 +1,54 @@
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| PHP Version 4 |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 1997-2003 The PHP Group |
|
||||
+----------------------------------------------------------------------+
|
||||
| This source file is subject to version 2.02 of the PHP license, |
|
||||
| that is bundled with this package in the file LICENSE, and is |
|
||||
| available at through the world-wide-web at |
|
||||
| http://www.php.net/license/2_02.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_node_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;
|
||||
|
||||
#endif /* DOM_CE_H */
|
237
ext/dom/dom_fe.h
Normal file
237
ext/dom/dom_fe.h
Normal file
@ -0,0 +1,237 @@
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| PHP Version 4 |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 1997-2003 The PHP Group |
|
||||
+----------------------------------------------------------------------+
|
||||
| This source file is subject to version 2.02 of the PHP license, |
|
||||
| that is bundled with this package in the file LICENSE, and is |
|
||||
| available at through the world-wide-web at |
|
||||
| http://www.php.net/license/2_02.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[];
|
||||
|
||||
/* 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);
|
||||
|
||||
/* 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);
|
||||
|
||||
#endif /* DOM_FE_H */
|
145
ext/dom/dom_properties.h
Normal file
145
ext/dom/dom_properties.h
Normal file
@ -0,0 +1,145 @@
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| PHP Version 4 |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 1997-2003 The PHP Group |
|
||||
+----------------------------------------------------------------------+
|
||||
| This source file is subject to version 2.02 of the PHP license, |
|
||||
| that is bundled with this package in the file LICENSE, and is |
|
||||
| available at through the world-wide-web at |
|
||||
| http://www.php.net/license/2_02.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);
|
||||
|
||||
/* 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);
|
||||
|
||||
#endif /* DOM_PROPERTIERS_H */
|
77
ext/dom/domconfiguration.c
Normal file
77
ext/dom/domconfiguration.c
Normal file
@ -0,0 +1,77 @@
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| PHP Version 4 |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 1997-2003 The PHP Group |
|
||||
+----------------------------------------------------------------------+
|
||||
| This source file is subject to version 2.02 of the PHP license, |
|
||||
| that is bundled with this package in the file LICENSE, and is |
|
||||
| available at through the world-wide-web at |
|
||||
| http://www.php.net/license/2_02.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"
|
||||
#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 */
|
137
ext/dom/domerror.c
Normal file
137
ext/dom/domerror.c
Normal file
@ -0,0 +1,137 @@
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| PHP Version 4 |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 1997-2003 The PHP Group |
|
||||
+----------------------------------------------------------------------+
|
||||
| This source file is subject to version 2.02 of the PHP license, |
|
||||
| that is bundled with this package in the file LICENSE, and is |
|
||||
| available at through the world-wide-web at |
|
||||
| http://www.php.net/license/2_02.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"
|
||||
#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;
|
||||
}
|
||||
|
||||
/* }}} */
|
||||
|
||||
|
53
ext/dom/domerrorhandler.c
Normal file
53
ext/dom/domerrorhandler.c
Normal file
@ -0,0 +1,53 @@
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| PHP Version 4 |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 1997-2003 The PHP Group |
|
||||
+----------------------------------------------------------------------+
|
||||
| This source file is subject to version 2.02 of the PHP license, |
|
||||
| that is bundled with this package in the file LICENSE, and is |
|
||||
| available at through the world-wide-web at |
|
||||
| http://www.php.net/license/2_02.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"
|
||||
#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 */
|
112
ext/dom/domexception.c
Normal file
112
ext/dom/domexception.c
Normal file
@ -0,0 +1,112 @@
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| PHP Version 4 |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 1997-2003 The PHP Group |
|
||||
+----------------------------------------------------------------------+
|
||||
| This source file is subject to version 2.02 of the PHP license, |
|
||||
| that is bundled with this package in the file LICENSE, and is |
|
||||
| available at through the world-wide-web at |
|
||||
| http://www.php.net/license/2_02.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"
|
||||
#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, zval **retval TSRMLS_DC)
|
||||
{
|
||||
zval *dom_exception;
|
||||
char *error_message;
|
||||
|
||||
ALLOC_ZVAL(dom_exception);
|
||||
Z_TYPE_P(dom_exception) = IS_OBJECT;
|
||||
object_init_ex(dom_exception, dom_domexception_class_entry);
|
||||
dom_exception->refcount = 1;
|
||||
dom_exception->is_ref = 1;
|
||||
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";
|
||||
}
|
||||
|
||||
add_property_long(dom_exception, "code", error_code);
|
||||
add_property_stringl(dom_exception, "message", error_message, strlen(error_message), 1);
|
||||
EG(exception) = dom_exception;
|
||||
}
|
||||
/* }}} end php_dom_throw_error */
|
244
ext/dom/domimplementation.c
Normal file
244
ext/dom/domimplementation.c
Normal file
@ -0,0 +1,244 @@
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| PHP Version 4 |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 1997-2003 The PHP Group |
|
||||
+----------------------------------------------------------------------+
|
||||
| This source file is subject to version 2.02 of the PHP license, |
|
||||
| that is bundled with this package in the file LICENSE, and is |
|
||||
| available at through the world-wide-web at |
|
||||
| http://www.php.net/license/2_02.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"
|
||||
#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)
|
||||
{
|
||||
DOM_NOT_IMPLEMENTED();
|
||||
}
|
||||
/* }}} 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, &return_value TSRMLS_CC);
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid Namespace");
|
||||
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);
|
||||
}
|
||||
/* }}} 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, dtd = NULL;
|
||||
xmlNsPtr nsptr = NULL;
|
||||
int ret, uri_len = 0, name_len = 0;
|
||||
char *uri, *name;
|
||||
xmlChar *prefix = NULL, *localname = NULL;
|
||||
xmlURIPtr uristruct;
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|sso", &uri, &uri_len, &name, &name_len, &node) == FAILURE) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (doctype != NULL) {
|
||||
DOM_GET_OBJ(doctype, node, xmlDtdPtr);
|
||||
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, &return_value TSRMLS_CC);
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "DocumentType: Wrong Document");
|
||||
RETURN_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
if (uri_len > 0 || name_len > 0 || doctype != NULL) {
|
||||
if (name_len == 0 && uri_len > 0) {
|
||||
php_dom_throw_error(NAMESPACE_ERR, &return_value TSRMLS_CC);
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid Namespace");
|
||||
}
|
||||
if (name_len > 0) {
|
||||
uristruct = xmlParseURI(name);
|
||||
if (uristruct->opaque != NULL) {
|
||||
prefix = xmlStrdup(uristruct->scheme);
|
||||
localname = xmlStrdup(uristruct->opaque);
|
||||
if (xmlStrchr(localname, (xmlChar) ':') != NULL) {
|
||||
php_dom_throw_error(NAMESPACE_ERR, &return_value TSRMLS_CC);
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid Namespace");
|
||||
xmlFreeURI(uristruct);
|
||||
xmlFree(prefix);
|
||||
xmlFree(localname);
|
||||
RETURN_FALSE;
|
||||
}
|
||||
if (!strcmp (prefix, "xml") && strcmp(uri, XML_XML_NAMESPACE)) {
|
||||
php_dom_throw_error(NAMESPACE_ERR, &return_value TSRMLS_CC);
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid Namespace");
|
||||
xmlFreeURI(uristruct);
|
||||
xmlFree(prefix);
|
||||
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(uristruct);
|
||||
|
||||
if (uri_len > 0) {
|
||||
if (prefix == NULL) {
|
||||
php_dom_throw_error(NAMESPACE_ERR, &return_value TSRMLS_CC);
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid Namespace");
|
||||
xmlFree(localname);
|
||||
RETURN_FALSE;
|
||||
} else {
|
||||
if ((nsptr = xmlNewNs(NULL, uri, prefix)) == NULL) {
|
||||
php_dom_throw_error(NAMESPACE_ERR, &return_value TSRMLS_CC);
|
||||
xmlFree(prefix);
|
||||
xmlFree(localname);
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid Namespace");
|
||||
RETURN_FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (prefix != NULL) {
|
||||
xmlFree(prefix);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* currently letting libxml2 set the version string */
|
||||
docp = xmlNewDoc(NULL);
|
||||
if (!docp) {
|
||||
if (localname != NULL) {
|
||||
xmlFree(localname);
|
||||
}
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
if (doctype != NULL) {
|
||||
dtd = xmlCreateIntSubset (docp, doctype->name,
|
||||
doctype->ExternalID, doctype->SystemID);
|
||||
}
|
||||
|
||||
if (localname != NULL) {
|
||||
nodep = xmlNewDocNode (docp, nsptr, localname, NULL);
|
||||
if (!nodep) {
|
||||
xmlFreeDoc(docp);
|
||||
xmlFree(localname);
|
||||
/* Need some type of error here */
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unexpected Error");
|
||||
RETURN_FALSE;
|
||||
}
|
||||
xmlDocSetRootElement(docp, nodep);
|
||||
xmlFree(localname);
|
||||
}
|
||||
|
||||
DOM_RET_OBJ(rv, (xmlNodePtr) docp, &ret);
|
||||
}
|
||||
/* }}} 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 */
|
69
ext/dom/domimplementationlist.c
Normal file
69
ext/dom/domimplementationlist.c
Normal file
@ -0,0 +1,69 @@
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| PHP Version 4 |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 1997-2003 The PHP Group |
|
||||
+----------------------------------------------------------------------+
|
||||
| This source file is subject to version 2.02 of the PHP license, |
|
||||
| that is bundled with this package in the file LICENSE, and is |
|
||||
| available at through the world-wide-web at |
|
||||
| http://www.php.net/license/2_02.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"
|
||||
#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 */
|
65
ext/dom/domimplementationsource.c
Normal file
65
ext/dom/domimplementationsource.c
Normal file
@ -0,0 +1,65 @@
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| PHP Version 4 |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 1997-2003 The PHP Group |
|
||||
+----------------------------------------------------------------------+
|
||||
| This source file is subject to version 2.02 of the PHP license, |
|
||||
| that is bundled with this package in the file LICENSE, and is |
|
||||
| available at through the world-wide-web at |
|
||||
| http://www.php.net/license/2_02.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"
|
||||
#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 */
|
121
ext/dom/domlocator.c
Normal file
121
ext/dom/domlocator.c
Normal file
@ -0,0 +1,121 @@
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| PHP Version 4 |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 1997-2003 The PHP Group |
|
||||
+----------------------------------------------------------------------+
|
||||
| This source file is subject to version 2.02 of the PHP license, |
|
||||
| that is bundled with this package in the file LICENSE, and is |
|
||||
| available at through the world-wide-web at |
|
||||
| http://www.php.net/license/2_02.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"
|
||||
#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;
|
||||
}
|
||||
|
||||
/* }}} */
|
||||
|
||||
|
69
ext/dom/domstringlist.c
Normal file
69
ext/dom/domstringlist.c
Normal file
@ -0,0 +1,69 @@
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| PHP Version 4 |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 1997-2003 The PHP Group |
|
||||
+----------------------------------------------------------------------+
|
||||
| This source file is subject to version 2.02 of the PHP license, |
|
||||
| that is bundled with this package in the file LICENSE, and is |
|
||||
| available at through the world-wide-web at |
|
||||
| http://www.php.net/license/2_02.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"
|
||||
#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 */
|
779
ext/dom/element.c
Normal file
779
ext/dom/element.c
Normal file
@ -0,0 +1,779 @@
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| PHP Version 4 |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 1997-2003 The PHP Group |
|
||||
+----------------------------------------------------------------------+
|
||||
| This source file is subject to version 2.02 of the PHP license, |
|
||||
| that is bundled with this package in the file LICENSE, and is |
|
||||
| available at through the world-wide-web at |
|
||||
| http://www.php.net/license/2_02.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"
|
||||
#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;
|
||||
|
||||
id = getThis();
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|s", &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) {
|
||||
node_free_resource(oldnode TSRMLS_CC);
|
||||
}
|
||||
php_dom_set_object(id, nodep 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;
|
||||
|
||||
nodep = obj->ptr;
|
||||
ALLOC_ZVAL(*retval);
|
||||
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;
|
||||
int name_len;
|
||||
|
||||
|
||||
DOM_GET_THIS_OBJ(nodep, id, xmlNodePtr);
|
||||
|
||||
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;
|
||||
char *name, *value;
|
||||
|
||||
|
||||
DOM_GET_THIS_OBJ(nodep, id, xmlNodePtr);
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss", &name, &name_len, &value, &value_len) == FAILURE) {
|
||||
return;
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
}
|
||||
/* }}} 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;
|
||||
int name_len;
|
||||
char *name;
|
||||
|
||||
DOM_GET_THIS_OBJ(nodep, id, xmlNodePtr);
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &name, &name_len) == FAILURE) {
|
||||
return;
|
||||
}
|
||||
|
||||
attrp = xmlHasProp(nodep,name);
|
||||
if (attrp == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
/* TODO: DTD defined attributes are handled special */
|
||||
if (dom_object_get_data((xmlNodePtr) attrp) == NULL) {
|
||||
node_list_unlink(attrp->children TSRMLS_CC);
|
||||
xmlUnlinkNode((xmlNodePtr) attrp);
|
||||
xmlFreeProp(attrp);
|
||||
} else {
|
||||
dom_add_to_list((xmlNodePtr) attrp, attrp->doc TSRMLS_CC);
|
||||
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;
|
||||
char *name;
|
||||
|
||||
DOM_GET_THIS_OBJ(nodep, id, xmlNodePtr);
|
||||
|
||||
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);
|
||||
}
|
||||
/* }}} 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, *oldzval, *rv = NULL;
|
||||
xmlNode *nodep;
|
||||
xmlAttr *attrp, *existattrp = NULL;
|
||||
int ret;
|
||||
|
||||
DOM_GET_THIS_OBJ(nodep, id, xmlNodePtr);
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o", &node) == FAILURE) {
|
||||
return;
|
||||
}
|
||||
|
||||
DOM_GET_OBJ(attrp, node, xmlAttrPtr);
|
||||
|
||||
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 ((oldzval = dom_object_get_data((xmlNodePtr) existattrp)) == NULL) {
|
||||
dom_add_to_list((xmlNodePtr) existattrp, existattrp->doc TSRMLS_CC);
|
||||
xmlUnlinkNode((xmlNodePtr) existattrp);
|
||||
} else {
|
||||
if (oldzval == node) {
|
||||
RETURN_NULL();
|
||||
}
|
||||
dom_add_to_list((xmlNodePtr) existattrp, existattrp->doc TSRMLS_CC);
|
||||
xmlUnlinkNode((xmlNodePtr) existattrp);
|
||||
}
|
||||
}
|
||||
|
||||
xmlAddChild(nodep, (xmlNodePtr) attrp);
|
||||
dom_del_from_list((xmlNodePtr) attrp, attrp->doc TSRMLS_CC);
|
||||
|
||||
/* Returns old property if removed otherwise NULL */
|
||||
if (existattrp != NULL) {
|
||||
DOM_RET_OBJ(rv, (xmlNodePtr) existattrp, &ret);
|
||||
} 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;
|
||||
xmlNode *nodep;
|
||||
xmlAttr *attrp;
|
||||
int name_len;
|
||||
char *name;
|
||||
|
||||
DOM_GET_THIS_OBJ(nodep, id, xmlNodePtr);
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &name, &name_len) == FAILURE) {
|
||||
return;
|
||||
}
|
||||
|
||||
attrp = xmlHasProp(nodep,name);
|
||||
if (attrp == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
/* Check for registered nodes within attributes tree when attribute is not referenced
|
||||
Unlink dependant nodes and free attribute if not registered */
|
||||
if (dom_object_get_data((xmlNodePtr) attrp) == NULL) {
|
||||
node_list_unlink(attrp->children TSRMLS_CC);
|
||||
xmlUnlinkNode((xmlNodePtr) attrp);
|
||||
xmlFreeProp(attrp);
|
||||
} else {
|
||||
dom_add_to_list((xmlNodePtr) attrp, attrp->doc TSRMLS_CC);
|
||||
xmlUnlinkNode((xmlNodePtr) attrp);
|
||||
}
|
||||
|
||||
RETURN_TRUE;
|
||||
|
||||
}
|
||||
/* }}} 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;
|
||||
xmlXPathContextPtr ctxp;
|
||||
xmlNodePtr nodep;
|
||||
xmlDocPtr docp;
|
||||
xmlXPathObjectPtr xpathobjp;
|
||||
int name_len, ret;
|
||||
char *str,*name;
|
||||
|
||||
DOM_GET_THIS_OBJ(nodep, id, xmlNodePtr);
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &name, &name_len) == FAILURE) {
|
||||
return;
|
||||
}
|
||||
|
||||
docp = nodep->doc;
|
||||
|
||||
ctxp = xmlXPathNewContext(docp);
|
||||
|
||||
ctxp->node = nodep;
|
||||
str = (char*) emalloc((name_len+3) * sizeof(char)) ;
|
||||
sprintf(str ,"//%s",name);
|
||||
|
||||
xpathobjp = xmlXPathEval(str, ctxp);
|
||||
efree(str);
|
||||
|
||||
if (!xpathobjp) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
if (xpathobjp->type == XPATH_NODESET) {
|
||||
int i;
|
||||
xmlNodeSetPtr nodesetp;
|
||||
|
||||
if (NULL == (nodesetp = xpathobjp->nodesetval)) {
|
||||
xmlXPathFreeObject (xpathobjp);
|
||||
xmlXPathFreeContext(ctxp);
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
array_init(return_value);
|
||||
|
||||
for (i = 0; i < nodesetp->nodeNr; i++) {
|
||||
xmlNodePtr node = nodesetp->nodeTab[i];
|
||||
zval *child = NULL;
|
||||
zval *wrapper;
|
||||
wrapper = dom_object_get_data(node);
|
||||
if (wrapper == NULL) {
|
||||
MAKE_STD_ZVAL(child);
|
||||
}
|
||||
|
||||
child = php_dom_create_object(node, &ret, wrapper, child TSRMLS_CC);
|
||||
add_next_index_zval(return_value, child);
|
||||
}
|
||||
}
|
||||
|
||||
xmlXPathFreeObject(xpathobjp);
|
||||
xmlXPathFreeContext(ctxp);
|
||||
}
|
||||
/* }}} 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;
|
||||
int uri_len = 0, name_len = 0;
|
||||
char *uri, *name, *strattr;
|
||||
|
||||
DOM_GET_THIS_OBJ(elemp, id, xmlNodePtr);
|
||||
|
||||
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, *rv = NULL;
|
||||
xmlNodePtr elemp, nodep = NULL;
|
||||
xmlNsPtr nsptr;
|
||||
int ret, uri_len = 0, name_len = 0;
|
||||
char *uri, *name;
|
||||
xmlChar *localname = NULL;
|
||||
int errorcode = 0;
|
||||
|
||||
DOM_GET_THIS_OBJ(elemp, id, xmlNodePtr);
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss", &uri, &uri_len, &name, &name_len) == FAILURE) {
|
||||
return;
|
||||
}
|
||||
nsptr = xmlSearchNsByHref (elemp->doc, elemp, uri);
|
||||
if (nsptr == NULL) {
|
||||
nsptr = dom_get_ns(uri, name, uri_len, name_len, &errorcode, (char **) &localname);
|
||||
if (nsptr != NULL) {
|
||||
dom_set_old_ns(elemp->doc, nsptr);
|
||||
}
|
||||
}
|
||||
if (errorcode == 0) {
|
||||
if (nsptr != NULL) {
|
||||
nodep = (xmlNodePtr) xmlSetNsProp(elemp, nsptr, localname, NULL);
|
||||
} else {
|
||||
nodep = (xmlNodePtr) xmlSetProp(elemp, name, NULL);
|
||||
}
|
||||
}
|
||||
if (localname != NULL) {
|
||||
xmlFree(localname);
|
||||
}
|
||||
|
||||
if (errorcode != 0) {
|
||||
php_dom_throw_error(errorcode, &return_value TSRMLS_CC);
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid Namespace");
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
if (nodep == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
DOM_RET_OBJ(rv, nodep, &ret);
|
||||
}
|
||||
/* }}} 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;
|
||||
int name_len, uri_len;
|
||||
char *name, *uri;
|
||||
|
||||
DOM_GET_THIS_OBJ(nodep, id, xmlNodePtr);
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss", &uri, &uri_len, &name, &name_len) == FAILURE) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (xmlStrEqual(uri, DOM_XMLNS_NAMESPACE)) {
|
||||
DOM_NOT_IMPLEMENTED();
|
||||
} else {
|
||||
attrp = xmlHasNsProp(nodep, name, uri);
|
||||
if (attrp == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
if (dom_object_get_data((xmlNodePtr) attrp) == NULL) {
|
||||
node_list_unlink(attrp->children TSRMLS_CC);
|
||||
xmlUnlinkNode((xmlNodePtr) attrp);
|
||||
xmlFreeProp(attrp);
|
||||
} else {
|
||||
dom_add_to_list((xmlNodePtr) attrp, attrp->doc TSRMLS_CC);
|
||||
xmlUnlinkNode((xmlNodePtr) attrp);
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_TRUE;
|
||||
}
|
||||
/* }}} 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;
|
||||
xmlNodePtr elemp;
|
||||
xmlNs *nsp;
|
||||
int uri_len, name_len;
|
||||
char *uri, *name, *value;
|
||||
|
||||
DOM_GET_THIS_OBJ(elemp, id, xmlNodePtr);
|
||||
|
||||
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) {
|
||||
RETVAL_STRING(value, 1);
|
||||
xmlFree(value);
|
||||
} else {
|
||||
if (xmlStrEqual(name, DOM_XMLNS_NAMESPACE)) {
|
||||
nsp = dom_get_nsdecl(elemp, name);
|
||||
if (nsp != NULL) {
|
||||
RETVAL_STRING((char *) nsp->href, 1);
|
||||
} else {
|
||||
RETVAL_EMPTY_STRING();
|
||||
}
|
||||
} else {
|
||||
RETVAL_EMPTY_STRING();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
/* }}} 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, *oldzval, *rv = NULL;
|
||||
xmlNode *nodep;
|
||||
xmlNs *nsp;
|
||||
xmlAttr *attrp, *existattrp = NULL;
|
||||
int ret;
|
||||
|
||||
DOM_GET_THIS_OBJ(nodep, id, xmlNodePtr);
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o", &node) == FAILURE) {
|
||||
return;
|
||||
}
|
||||
|
||||
DOM_GET_OBJ(attrp, node, xmlAttrPtr);
|
||||
|
||||
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 ((oldzval = dom_object_get_data((xmlNodePtr) existattrp)) == NULL) {
|
||||
dom_add_to_list((xmlNodePtr) existattrp, existattrp->doc TSRMLS_CC);
|
||||
xmlUnlinkNode((xmlNodePtr) existattrp);
|
||||
} else {
|
||||
if (oldzval == node) {
|
||||
RETURN_NULL();
|
||||
}
|
||||
dom_add_to_list((xmlNodePtr) existattrp, existattrp->doc TSRMLS_CC);
|
||||
xmlUnlinkNode((xmlNodePtr) existattrp);
|
||||
}
|
||||
}
|
||||
|
||||
xmlAddChild(nodep, (xmlNodePtr) attrp);
|
||||
if (existattrp == NULL) {
|
||||
xmlReconciliateNs(nodep->doc, nodep);
|
||||
}
|
||||
|
||||
dom_del_from_list((xmlNodePtr) attrp, attrp->doc TSRMLS_CC);
|
||||
|
||||
/* Returns old property if removed otherwise NULL */
|
||||
if (existattrp != NULL) {
|
||||
DOM_RET_OBJ(rv, (xmlNodePtr) existattrp, &ret);
|
||||
} 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;
|
||||
char *uri, *name;
|
||||
|
||||
DOM_GET_THIS_OBJ(elemp, id, xmlNodePtr);
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss", &uri, &uri_len, &name, &name_len) == FAILURE) {
|
||||
return;
|
||||
}
|
||||
|
||||
array_init(return_value);
|
||||
|
||||
dom_get_elements_by_tag_name_ns_raw(elemp->children, uri, name, &return_value TSRMLS_CC);
|
||||
}
|
||||
/* }}} 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;
|
||||
char *name, *value;
|
||||
int name_len;
|
||||
|
||||
DOM_GET_THIS_OBJ(nodep, id, xmlNodePtr);
|
||||
|
||||
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;
|
||||
int uri_len, name_len;
|
||||
char *uri, *name, *value;
|
||||
|
||||
DOM_GET_THIS_OBJ(elemp, id, xmlNodePtr);
|
||||
|
||||
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 */
|
180
ext/dom/entity.c
Normal file
180
ext/dom/entity.c
Normal file
@ -0,0 +1,180 @@
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| PHP Version 4 |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 1997-2003 The PHP Group |
|
||||
+----------------------------------------------------------------------+
|
||||
| This source file is subject to version 2.02 of the PHP license, |
|
||||
| that is bundled with this package in the file LICENSE, and is |
|
||||
| available at through the world-wide-web at |
|
||||
| http://www.php.net/license/2_02.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"
|
||||
#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 = obj->ptr;
|
||||
|
||||
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 = obj->ptr;
|
||||
|
||||
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 = obj->ptr;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
/* }}} */
|
||||
|
||||
|
78
ext/dom/entityreference.c
Normal file
78
ext/dom/entityreference.c
Normal file
@ -0,0 +1,78 @@
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| PHP Version 4 |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 1997-2003 The PHP Group |
|
||||
+----------------------------------------------------------------------+
|
||||
| This source file is subject to version 2.02 of the PHP license, |
|
||||
| that is bundled with this package in the file LICENSE, and is |
|
||||
| available at through the world-wide-web at |
|
||||
| http://www.php.net/license/2_02.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"
|
||||
#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;
|
||||
|
||||
id = getThis();
|
||||
|
||||
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, "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) {
|
||||
node_free_resource(oldnode TSRMLS_CC);
|
||||
}
|
||||
php_dom_set_object(id, node TSRMLS_CC);
|
||||
}
|
||||
}
|
||||
|
||||
/* }}} end dom_entityreference_entityreference */
|
141
ext/dom/namednodemap.c
Normal file
141
ext/dom/namednodemap.c
Normal file
@ -0,0 +1,141 @@
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| PHP Version 4 |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 1997-2003 The PHP Group |
|
||||
+----------------------------------------------------------------------+
|
||||
| This source file is subject to version 2.02 of the PHP license, |
|
||||
| that is bundled with this package in the file LICENSE, and is |
|
||||
| available at through the world-wide-web at |
|
||||
| http://www.php.net/license/2_02.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"
|
||||
#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)
|
||||
{
|
||||
ALLOC_ZVAL(*retval);
|
||||
ZVAL_STRING(*retval, "TEST", 1);
|
||||
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)
|
||||
{
|
||||
DOM_NOT_IMPLEMENTED();
|
||||
}
|
||||
/* }}} 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)
|
||||
{
|
||||
DOM_NOT_IMPLEMENTED();
|
||||
}
|
||||
/* }}} 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)
|
||||
{
|
||||
DOM_NOT_IMPLEMENTED();
|
||||
}
|
||||
/* }}} 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 */
|
81
ext/dom/namelist.c
Normal file
81
ext/dom/namelist.c
Normal file
@ -0,0 +1,81 @@
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| PHP Version 4 |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 1997-2003 The PHP Group |
|
||||
+----------------------------------------------------------------------+
|
||||
| This source file is subject to version 2.02 of the PHP license, |
|
||||
| that is bundled with this package in the file LICENSE, and is |
|
||||
| available at through the world-wide-web at |
|
||||
| http://www.php.net/license/2_02.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"
|
||||
#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 */
|
1274
ext/dom/node.c
Normal file
1274
ext/dom/node.c
Normal file
File diff suppressed because it is too large
Load Diff
69
ext/dom/nodelist.c
Normal file
69
ext/dom/nodelist.c
Normal file
@ -0,0 +1,69 @@
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| PHP Version 4 |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 1997-2003 The PHP Group |
|
||||
+----------------------------------------------------------------------+
|
||||
| This source file is subject to version 2.02 of the PHP license, |
|
||||
| that is bundled with this package in the file LICENSE, and is |
|
||||
| available at through the world-wide-web at |
|
||||
| http://www.php.net/license/2_02.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"
|
||||
#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)
|
||||
{
|
||||
ALLOC_ZVAL(*retval);
|
||||
ZVAL_STRING(*retval, "TEST", 1);
|
||||
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)
|
||||
{
|
||||
DOM_NOT_IMPLEMENTED();
|
||||
}
|
||||
/* }}} end dom_nodelist_item */
|
89
ext/dom/notation.c
Normal file
89
ext/dom/notation.c
Normal file
@ -0,0 +1,89 @@
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| PHP Version 4 |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 1997-2003 The PHP Group |
|
||||
+----------------------------------------------------------------------+
|
||||
| This source file is subject to version 2.02 of the PHP license, |
|
||||
| that is bundled with this package in the file LICENSE, and is |
|
||||
| available at through the world-wide-web at |
|
||||
| http://www.php.net/license/2_02.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"
|
||||
#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 = obj->ptr;
|
||||
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 = obj->ptr;
|
||||
ALLOC_ZVAL(*retval);
|
||||
if (nodep->SystemID) {
|
||||
ZVAL_STRING(*retval, (char *) (nodep->PublicID), 1);
|
||||
} else {
|
||||
ZVAL_EMPTY_STRING(*retval);
|
||||
}
|
||||
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
/* }}} */
|
||||
|
||||
|
1144
ext/dom/php_dom.c
Normal file
1144
ext/dom/php_dom.c
Normal file
File diff suppressed because it is too large
Load Diff
89
ext/dom/php_dom.h
Normal file
89
ext/dom/php_dom.h
Normal file
@ -0,0 +1,89 @@
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| PHP Version 4 |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 1997-2003 The PHP Group |
|
||||
+----------------------------------------------------------------------+
|
||||
| This source file is subject to version 2.02 of the PHP license, |
|
||||
| that is bundled with this package in the file LICENSE, and is |
|
||||
| available at through the world-wide-web at |
|
||||
| http://www.php.net/license/2_02.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
|
||||
|
||||
#if HAVE_DOM
|
||||
#include <libxml/parser.h>
|
||||
#include <libxml/parserInternals.h>
|
||||
#include <libxml/tree.h>
|
||||
#include <libxml/uri.h>
|
||||
#include <libxml/xmlerror.h>
|
||||
#include <libxml/xinclude.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
|
||||
|
||||
#include "xml_common.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 "20030413"
|
||||
|
||||
extern zend_module_entry dom_module_entry;
|
||||
|
||||
#define dom_module_ptr &dom_module_entry
|
||||
|
||||
#include "dom_fe.h"
|
||||
|
||||
void php_dom_set_object(zval *wrapper, void *obj TSRMLS_DC);
|
||||
zval *dom_object_get_data(xmlNodePtr obj);
|
||||
void php_dom_throw_error(int error_code, zval **retval TSRMLS_DC);
|
||||
void node_free_resource(xmlNodePtr node TSRMLS_DC);
|
||||
void node_list_unlink(xmlNodePtr node TSRMLS_DC);
|
||||
void dom_del_from_list(xmlNodePtr nodep, xmlDocPtr docp TSRMLS_DC);
|
||||
void dom_add_to_list(xmlNodePtr nodep, xmlDocPtr docp TSRMLS_DC);
|
||||
xmlNsPtr dom_get_ns(char *uri, char *qName, int uri_len, int qName_len, int *errorcode, char **localname);
|
||||
void dom_set_old_ns(xmlDoc *doc, xmlNs *ns);
|
||||
xmlNsPtr dom_get_nsdecl(xmlNode *node, xmlChar *localName);
|
||||
void dom_normalize (xmlNodePtr nodep TSRMLS_DC);
|
||||
void dom_get_elements_by_tag_name_ns_raw(xmlNodePtr nodep, char *ns, char *local, zval **retval TSRMLS_DC);
|
||||
void php_dom_create_implementation(zval **retval TSRMLS_DC);
|
||||
int dom_hierarchy(xmlNodePtr parent, xmlNodePtr child);
|
||||
|
||||
#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; \
|
||||
}
|
||||
|
||||
PHP_MINIT_FUNCTION(dom);
|
||||
PHP_MSHUTDOWN_FUNCTION(dom);
|
||||
PHP_MINFO_FUNCTION(dom);
|
||||
#else
|
||||
#define dom_module_ptr NULL
|
||||
|
||||
#endif /* HAVE_DOM */
|
||||
#define phpext_dom_ptr dom_module_ptr
|
||||
|
||||
#endif /* _PHP_DIR_H */
|
138
ext/dom/processinginstruction.c
Normal file
138
ext/dom/processinginstruction.c
Normal file
@ -0,0 +1,138 @@
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| PHP Version 4 |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 1997-2003 The PHP Group |
|
||||
+----------------------------------------------------------------------+
|
||||
| This source file is subject to version 2.02 of the PHP license, |
|
||||
| that is bundled with this package in the file LICENSE, and is |
|
||||
| available at through the world-wide-web at |
|
||||
| http://www.php.net/license/2_02.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"
|
||||
#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;
|
||||
|
||||
id = getThis();
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|s", &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) {
|
||||
node_free_resource(oldnode TSRMLS_CC);
|
||||
}
|
||||
php_dom_set_object(id, nodep 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 = obj->ptr;
|
||||
|
||||
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 = obj->ptr;
|
||||
|
||||
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 = obj->ptr;
|
||||
xmlNodeSetContentLen(nodep, Z_STRVAL_P(newval), Z_STRLEN_P(newval) + 1);
|
||||
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
/* }}} */
|
||||
|
||||
|
65
ext/dom/string_extend.c
Normal file
65
ext/dom/string_extend.c
Normal file
@ -0,0 +1,65 @@
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| PHP Version 4 |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 1997-2003 The PHP Group |
|
||||
+----------------------------------------------------------------------+
|
||||
| This source file is subject to version 2.02 of the PHP license, |
|
||||
| that is bundled with this package in the file LICENSE, and is |
|
||||
| available at through the world-wide-web at |
|
||||
| http://www.php.net/license/2_02.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"
|
||||
#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 */
|
275
ext/dom/tests/dom001.phpt
Normal file
275
ext/dom/tests/dom001.phpt
Normal file
@ -0,0 +1,275 @@
|
||||
--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 = current($attrs)->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[0]);
|
||||
$rootnode->removeChild($children[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
|
43
ext/dom/tests/dom_test.inc
Normal file
43
ext/dom/tests/dom_test.inc
Normal file
@ -0,0 +1,43 @@
|
||||
<?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 = count($node->childNodes);
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
1
ext/dom/tests/skipif.inc
Normal file
1
ext/dom/tests/skipif.inc
Normal file
@ -0,0 +1 @@
|
||||
<?php if (!extension_loaded('dom')) die('skip dom extension not available');?>
|
124
ext/dom/text.c
Normal file
124
ext/dom/text.c
Normal file
@ -0,0 +1,124 @@
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| PHP Version 4 |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 1997-2003 The PHP Group |
|
||||
+----------------------------------------------------------------------+
|
||||
| This source file is subject to version 2.02 of the PHP license, |
|
||||
| that is bundled with this package in the file LICENSE, and is |
|
||||
| available at through the world-wide-web at |
|
||||
| http://www.php.net/license/2_02.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"
|
||||
#include "php_dom.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;
|
||||
|
||||
id = getThis();
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s", &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) {
|
||||
node_free_resource(oldnode TSRMLS_CC);
|
||||
}
|
||||
php_dom_set_object(id, nodep 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#Text3-wholeText
|
||||
Since: DOM Level 3
|
||||
*/
|
||||
int dom_text_whole_text_read(dom_object *obj, zval **retval TSRMLS_DC)
|
||||
{
|
||||
ALLOC_ZVAL(*retval);
|
||||
ZVAL_NULL(*retval);
|
||||
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#ID-38853C1D
|
||||
Since:
|
||||
*/
|
||||
PHP_FUNCTION(dom_text_split_text)
|
||||
{
|
||||
DOM_NOT_IMPLEMENTED();
|
||||
}
|
||||
/* }}} 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#Text3-isWhitespaceInElementContent
|
||||
Since: DOM Level 3
|
||||
*/
|
||||
PHP_FUNCTION(dom_text_is_whitespace_in_element_content)
|
||||
{
|
||||
DOM_NOT_IMPLEMENTED();
|
||||
}
|
||||
/* }}} 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#Text3-replaceWholeText
|
||||
Since: DOM Level 3
|
||||
*/
|
||||
PHP_FUNCTION(dom_text_replace_whole_text)
|
||||
{
|
||||
DOM_NOT_IMPLEMENTED();
|
||||
}
|
||||
/* }}} end dom_text_replace_whole_text */
|
73
ext/dom/typeinfo.c
Normal file
73
ext/dom/typeinfo.c
Normal file
@ -0,0 +1,73 @@
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| PHP Version 4 |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 1997-2003 The PHP Group |
|
||||
+----------------------------------------------------------------------+
|
||||
| This source file is subject to version 2.02 of the PHP license, |
|
||||
| that is bundled with this package in the file LICENSE, and is |
|
||||
| available at through the world-wide-web at |
|
||||
| http://www.php.net/license/2_02.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"
|
||||
#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;
|
||||
}
|
||||
|
||||
/* }}} */
|
||||
|
||||
|
53
ext/dom/userdatahandler.c
Normal file
53
ext/dom/userdatahandler.c
Normal file
@ -0,0 +1,53 @@
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| PHP Version 4 |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 1997-2003 The PHP Group |
|
||||
+----------------------------------------------------------------------+
|
||||
| This source file is subject to version 2.02 of the PHP license, |
|
||||
| that is bundled with this package in the file LICENSE, and is |
|
||||
| available at through the world-wide-web at |
|
||||
| http://www.php.net/license/2_02.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"
|
||||
#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 */
|
82
ext/dom/xml_common.h
Normal file
82
ext/dom/xml_common.h
Normal file
@ -0,0 +1,82 @@
|
||||
#ifndef PHP_XML_COMMON_H
|
||||
#define PHP_XML_COMMON_H
|
||||
|
||||
typedef struct _node_list_pointer {
|
||||
xmlNodePtr nodep;
|
||||
void *next;
|
||||
} node_list_pointer;
|
||||
|
||||
typedef struct _dom_object {
|
||||
zend_object std;
|
||||
void *ptr;
|
||||
HashTable *prop_handler;
|
||||
node_list_pointer *node_list;
|
||||
} 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 */
|
||||
|
||||
#ifdef ZTS
|
||||
#include "TSRM.h"
|
||||
#endif
|
||||
|
||||
#define PHP_DOM_EXPORT(__type) PHPAPI __type
|
||||
|
||||
PHP_DOM_EXPORT(zval *) php_dom_create_object(xmlNodePtr obj, int *found, zval* in, zval* return_value TSRMLS_DC);
|
||||
PHP_DOM_EXPORT(void) dom_objects_clone(void *object, void **object_clone TSRMLS_DC);
|
||||
void dom_objects_dtor(void *object, zend_object_handle handle TSRMLS_DC);
|
||||
PHP_DOM_EXPORT(zval *) dom_read_property(zval *object, zval *member TSRMLS_DC);
|
||||
PHP_DOM_EXPORT(void) dom_write_property(zval *object, zval *member, zval *value TSRMLS_DC);
|
||||
zend_object_value dom_objects_new(zend_class_entry *class_type TSRMLS_DC);
|
||||
void dom_unregister_node(xmlNodePtr nodep TSRMLS_DC);
|
||||
zend_object_handlers dom_object_handlers;
|
||||
|
||||
#define DOM_XMLNS_NAMESPACE \
|
||||
(const xmlChar *) "http://www.w3.org/2000/xmlns/"
|
||||
|
||||
#define DOM_NOT_IMPLEMENTED() \
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Not yet implemented"); \
|
||||
return;
|
||||
|
||||
#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);
|
||||
/* entry = zend_register_internal_ns_class(&ce, parent_ce, ns, NULL TSRMLS_CC); */
|
||||
|
||||
#define DOM_GET_OBJ(__ptr, __id, __prtype) { \
|
||||
dom_object *intern = (dom_object *)zend_object_store_get_object(__id TSRMLS_CC); \
|
||||
if (!(__ptr = (__prtype)intern->ptr)) { \
|
||||
php_error(E_WARNING, "Couldn't fetch %s", intern->std.ce->name);\
|
||||
RETURN_NULL();\
|
||||
} \
|
||||
}
|
||||
|
||||
#define DOM_DOMOBJ_NEW(zval, obj, ret) \
|
||||
if (NULL == (zval = php_dom_create_object(obj, ret, zval, return_value TSRMLS_CC))) { \
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Cannot create required DOM object"); \
|
||||
RETURN_FALSE; \
|
||||
}
|
||||
|
||||
#define DOM_RET_OBJ(zval, obj, ret) \
|
||||
DOM_DOMOBJ_NEW(zval, obj, ret);
|
||||
|
||||
#define DOM_GET_THIS(zval) \
|
||||
if (NULL == (zval = getThis())) { \
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Underlying object missing"); \
|
||||
RETURN_FALSE; \
|
||||
}
|
||||
|
||||
#define DOM_GET_THIS_OBJ(__ptr, __id, __prtype) \
|
||||
DOM_GET_THIS(__id); \
|
||||
DOM_GET_OBJ(__ptr, __id, __prtype);
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user