diff options
author | SVN Migration <svn@php.net> | 2004-01-25 12:03:25 +0000 |
---|---|---|
committer | SVN Migration <svn@php.net> | 2004-01-25 12:03:25 +0000 |
commit | 22476b36ce621bdd115493bab84cbe706e422a7c (patch) | |
tree | 1124d1c5af68860a78c2252bb0dac63c9f18156e /ext/simplexml | |
parent | eb7aca4ea896b09cb9afc2466a46f4720acc4a4e (diff) | |
download | php-git-php_ibase_before_split.tar.gz |
This commit was manufactured by cvs2svn to create tagphp_ibase_before_split
'php_ibase_before_split'.
Diffstat (limited to 'ext/simplexml')
58 files changed, 0 insertions, 3721 deletions
diff --git a/ext/simplexml/CREDITS b/ext/simplexml/CREDITS deleted file mode 100644 index eaa36f3245..0000000000 --- a/ext/simplexml/CREDITS +++ /dev/null @@ -1,2 +0,0 @@ -simplexml -Sterling Hughes, Marcus Boerger, Rob Richards diff --git a/ext/simplexml/README b/ext/simplexml/README deleted file mode 100755 index bb9240d103..0000000000 --- a/ext/simplexml/README +++ /dev/null @@ -1,34 +0,0 @@ -SimpleXML is meant to be an easy way to access XML data. - -SimpleXML objects follow four basic rules: - -1) properties denote element iterators -2) numeric indices denote elements -3) non numeric indices denote attributes -4) string conversion allows to access TEXT data - -When iterating properties then the extension always iterates over -all nodes with that element name. Thus method children() must be -called to iterate over subnodes. But also doing the following: -foreach ($obj->node_name as $elem) { - // do something with $elem -} -always results in iteration of 'node_name' elements. So no further -check is needed to distinguish the number of nodes of that type. - -When an elements TEXT data is being accessed through a property -then the result does not include the TEXT data of subelements. - -Known issues -============ - -Due to engine problems it is currently not possible to access -a subelement by index 0: $object->property[0]. - -TODO -==== - -At the moment property access to multiple elements of the same -name returns an array of SimpleXML objects. This should be an -object of a new type instead so that all kinds of linkage, -assignment and deleting would work. diff --git a/ext/simplexml/config.m4 b/ext/simplexml/config.m4 deleted file mode 100644 index 9fa9c455ed..0000000000 --- a/ext/simplexml/config.m4 +++ /dev/null @@ -1,21 +0,0 @@ -dnl $Id$ -dnl config.m4 for extension simplexml - -PHP_ARG_ENABLE(simplexml, whether to enable simplexml support, -[ --disable-simplexml Disable simplexml support], yes) - -if test -z "$PHP_LIBXML_DIR"; then - PHP_ARG_WITH(libxml-dir, libxml2 install dir, - [ --with-libxml-dir=DIR SimpleXML: libxml2 install prefix], no, no) -fi - -if test "$PHP_SIMPLEXML" != "no" && test "$PHP_LIBXML" != "no"; then - - PHP_SETUP_LIBXML(SIMPLEXML_SHARED_LIBADD, [ - AC_DEFINE(HAVE_SIMPLEXML,1,[ ]) - PHP_NEW_EXTENSION(simplexml, simplexml.c, $ext_shared) - PHP_SUBST(SIMPLEXML_SHARED_LIBADD) - ], [ - AC_MSG_ERROR([xml2-config not found. Please check your libxml2 installation.]) - ]) -fi diff --git a/ext/simplexml/config.w32 b/ext/simplexml/config.w32 deleted file mode 100644 index 26a87f1c14..0000000000 --- a/ext/simplexml/config.w32 +++ /dev/null @@ -1,16 +0,0 @@ -// $Id$ -// vim:ft=javascript - -ARG_WITH("simplexml", "Simple XML support", "yes"); - -if (PHP_SIMPLEXML == "yes" && PHP_LIBXML == "yes") { - EXTENSION("simplexml", "simplexml.c"); - AC_DEFINE("HAVE_SIMPLEXML", 1, "Simple XML support"); - if (!PHP_SIMPLEXML_SHARED) { - ADD_FLAG("CFLAGS_SIMPLEXML", "/D LIBXML_STATIC"); - } - ADD_EXTENSION_DEP('simplexml', 'libxml'); - ADD_EXTENSION_DEP('simplexml', 'spl', true); -} - - diff --git a/ext/simplexml/examples/book.php b/ext/simplexml/examples/book.php deleted file mode 100644 index 0416df861b..0000000000 --- a/ext/simplexml/examples/book.php +++ /dev/null @@ -1,8 +0,0 @@ -<?php -$books = simplexml_load_file('book.xml'); -//var_dump($books); -$books = $books->book; -foreach ($books as $book) { - echo "{$book->title} was written by {$book->author}\n"; -} -?> diff --git a/ext/simplexml/examples/book.xml b/ext/simplexml/examples/book.xml deleted file mode 100644 index ea40508e01..0000000000 --- a/ext/simplexml/examples/book.xml +++ /dev/null @@ -1,10 +0,0 @@ -<books> - <book> - <title>The Grapes of Wrath</title> - <author>John Steinbeck</author> - </book> - <book> - <title>The Pearl</title> - <author>John Steinbeck</author> - </book> -</books> diff --git a/ext/simplexml/examples/interop.php b/ext/simplexml/examples/interop.php deleted file mode 100644 index 9e38ec1110..0000000000 --- a/ext/simplexml/examples/interop.php +++ /dev/null @@ -1,27 +0,0 @@ -<?php -$dom = new domDocument; -$dom->load("book.xml"); -if(!$dom) { - echo "Error while parsing the document\n"; - exit; -} -print "As SimpleXML\n"; - -$s = simplexml_import_dom($dom); -$books = $s->book; -foreach ($books as $book) { - echo "{$book->title} was written by {$book->author}\n"; -} - -print "As DOM \n"; - -$dom = dom_import_simplexml($s); -$books = $dom->getElementsByTagName("book"); -foreach ($books as $book) { - $title = $book->getElementsByTagName("title"); - $author = $book->getElementsByTagName("author"); - echo $title[0]->firstChild->data . " was written by ". $author[0]->firstChild->data . "\n"; -} - - -?> diff --git a/ext/simplexml/examples/security.php b/ext/simplexml/examples/security.php deleted file mode 100644 index 17897b3fd7..0000000000 --- a/ext/simplexml/examples/security.php +++ /dev/null @@ -1,6 +0,0 @@ -<?php -$s = simplexml_load_file('security.xml'); -echo $s->id; -$s->id = 20; -$s->asXML('security.new.xml'); -?> diff --git a/ext/simplexml/examples/security.xml b/ext/simplexml/examples/security.xml deleted file mode 100644 index d954a02335..0000000000 --- a/ext/simplexml/examples/security.xml +++ /dev/null @@ -1,4 +0,0 @@ -<?xml version="1.0"?> -<security> - <id>15</id> -</security> diff --git a/ext/simplexml/examples/xpath.php b/ext/simplexml/examples/xpath.php deleted file mode 100644 index 8fcd9878ab..0000000000 --- a/ext/simplexml/examples/xpath.php +++ /dev/null @@ -1,9 +0,0 @@ -<?php -$books = simplexml_load_file('book.xml'); - -$xpath_result = $books->xpath("/books/book/title"); -foreach($xpath_result as $entry ) { - print "$entry \n"; -} - -?> diff --git a/ext/simplexml/php_simplexml.h b/ext/simplexml/php_simplexml.h deleted file mode 100644 index 36ae6ff242..0000000000 --- a/ext/simplexml/php_simplexml.h +++ /dev/null @@ -1,93 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP Version 5 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2004 The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 3.0 of the PHP license, | - | that is bundled with this package in the file LICENSE, and is | - | available through the world-wide-web at the following url: | - | http://www.php.net/license/3_0.txt. | - | If you did not receive a copy of the PHP license and are unable to | - | obtain it through the world-wide-web, please send a note to | - | license@php.net so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - | Author: Sterling Hughes <sterling@php.net> | - +----------------------------------------------------------------------+ -*/ - -/* $Id$ */ - -#ifndef PHP_SIMPLEXML_H -#define PHP_SIMPLEXML_H - -extern zend_module_entry simplexml_module_entry; -#define phpext_simplexml_ptr &simplexml_module_entry - -#ifdef PHP_WIN32 -#define PHP_SIMPLEXML_API __declspec(dllexport) -#else -#define PHP_SIMPLEXML_API -#endif - -#ifdef ZTS -#include "TSRM.h" -#endif - -#include "ext/libxml/php_libxml.h" -#include <libxml/parser.h> -#include <libxml/parserInternals.h> -#include <libxml/tree.h> -#include <libxml/uri.h> -#include <libxml/xmlerror.h> -#include <libxml/xinclude.h> -#include <libxml/xpath.h> -#include <libxml/xpathInternals.h> -#include <libxml/xpointer.h> -#include <libxml/xmlschemas.h> - -PHP_MINIT_FUNCTION(simplexml); -#if HAVE_SPL && !defined(COMPILE_DL_SPL) -PHP_RINIT_FUNCTION(simplexml); -#endif -PHP_MINFO_FUNCTION(simplexml); - -typedef struct { - zend_object zo; - php_libxml_node_ptr *node; - php_libxml_ref_obj *document; - HashTable *properties; - xmlXPathContextPtr xpath; - struct { - int itertype; - char *name; - char *nsprefix; - int type; - zval *data; - } iter; -} php_sxe_object; - -#define SXE_ITER_NONE 0 -#define SXE_ITER_ELEMENT 1 -#define SXE_ITER_CHILD 2 -#define SXE_ITER_ATTRLIST 3 - -#ifdef ZTS -#define SIMPLEXML_G(v) TSRMG(simplexml_globals_id, zend_simplexml_globals *, v) -#else -#define SIMPLEXML_G(v) (simplexml_globals.v) -#endif - -ZEND_API zend_class_entry *sxe_get_element_class_entry(); - -#endif - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * indent-tabs-mode: t - * End: - * vim600: fdm=marker - * vim: noet sw=4 ts=4 - */ diff --git a/ext/simplexml/php_simplexml_exports.h b/ext/simplexml/php_simplexml_exports.h deleted file mode 100755 index 6d6e7b8baf..0000000000 --- a/ext/simplexml/php_simplexml_exports.h +++ /dev/null @@ -1,65 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP Version 5 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2004 The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 3.0 of the PHP license, | - | that is bundled with this package in the file LICENSE, and is | - | available through the world-wide-web at the following url: | - | http://www.php.net/license/3_0.txt. | - | If you did not receive a copy of the PHP license and are unable to | - | obtain it through the world-wide-web, please send a note to | - | license@php.net so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - | Author: Sterling Hughes <sterling@php.net> | - | Marcus Boerger <helly@php.net> | - | Rob Richards <rrichards@php.net> | - +----------------------------------------------------------------------+ -*/ - -/* $Id$ */ - -#ifndef PHP_SIMPLEXML_EXPORTS_H -#define PHP_SIMPLEXML_EXPORTS_H - -#include "php_simplexml.h" - -#define SKIP_TEXT(__p) \ - if ((__p)->type == XML_TEXT_NODE) { \ - goto next_iter; \ - } - -#define GET_NODE(__s, __n) { \ - if ((__s)->node && (__s)->node->node) { \ - __n = (__s)->node->node; \ - } else { \ - __n = NULL; \ - php_error(E_WARNING, "Node no longer exists"); \ - } \ -} - -ZEND_API zend_object_value sxe_object_new(zend_class_entry *ce TSRMLS_DC); -/* {{{ php_sxe_fetch_object() - */ -static inline php_sxe_object * -php_sxe_fetch_object(zval *object TSRMLS_DC) -{ - return (php_sxe_object *) zend_object_store_get_object(object TSRMLS_CC); -} -/* }}} */ - -ZEND_API void php_sxe_reset_iterator(php_sxe_object *sxe TSRMLS_DC); -ZEND_API void php_sxe_move_forward_iterator(php_sxe_object *sxe TSRMLS_DC); - -#endif /* PHP_SIMPLEXML_EXPORTS_H */ - -/** - * Local Variables: - * c-basic-offset: 4 - * tab-width: 4 - * indent-tabs-mode: t - * End: - * vim600: fdm=marker - * vim: noet sw=4 ts=4 - */ diff --git a/ext/simplexml/simplexml.c b/ext/simplexml/simplexml.c deleted file mode 100644 index 6cdac4d9b3..0000000000 --- a/ext/simplexml/simplexml.c +++ /dev/null @@ -1,1593 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP Version 5 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2004 The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 3.0 of the PHP license, | - | that is bundled with this package in the file LICENSE, and is | - | available through the world-wide-web at the following url: | - | http://www.php.net/license/3_0.txt. | - | If you did not receive a copy of the PHP license and are unable to | - | obtain it through the world-wide-web, please send a note to | - | license@php.net so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - | Authors: Sterling Hughes <sterling@php.net> | - | Marcus Boerger <helly@php.net> | - | Rob Richards <rrichards@php.net> | - +----------------------------------------------------------------------+ -*/ - -/* $Id$ */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "php.h" -#if HAVE_LIBXML && HAVE_SIMPLEXML - -#include "php_ini.h" -#include "ext/standard/info.h" -#include "ext/standard/php_string.h" -#include "php_simplexml.h" -#include "php_simplexml_exports.h" -#include "zend_default_classes.h" -#include "zend_interfaces.h" -#if HAVE_SPL && !defined(COMPILE_DL_SPL) -#include "ext/spl/spl_sxe.h" -#endif - -zend_class_entry *sxe_class_entry = NULL; - -ZEND_API zend_class_entry *sxe_get_element_class_entry() -{ - return sxe_class_entry; -} - -#define SXE_ME(func, arg_info, flags) PHP_ME(simplexml_element, func, arg_info, flags) - -#define SXE_METHOD(func) PHP_METHOD(simplexml_element, func) - -static php_sxe_object* php_sxe_object_new(zend_class_entry *ce TSRMLS_DC); -static zend_object_value php_sxe_register_object(php_sxe_object * TSRMLS_DC); - -/* {{{ _node_as_zval() - */ -static void _node_as_zval(php_sxe_object *sxe, xmlNodePtr node, zval *value, int itertype, char *name, char *prefix TSRMLS_DC) -{ - php_sxe_object *subnode; - - subnode = php_sxe_object_new(sxe->zo.ce TSRMLS_CC); - subnode->document = sxe->document; - subnode->document->refcount++; - subnode->iter.type = itertype; - if (name) { - subnode->iter.name = xmlStrdup(name); - } - if (prefix) { - subnode->iter.nsprefix = xmlStrdup(prefix); - } - - php_libxml_increment_node_ptr((php_libxml_node_object *)subnode, node, NULL TSRMLS_CC); - - value->type = IS_OBJECT; - value->value.obj = php_sxe_register_object(subnode TSRMLS_CC); -} -/* }}} */ - -#define APPEND_PREV_ELEMENT(__c, __v) \ - if ((__c) == 1) { \ - array_init(return_value); \ - add_next_index_zval(return_value, __v); \ - } - -#define APPEND_CUR_ELEMENT(__c, __v) \ - if (++(__c) > 1) { \ - add_next_index_zval(return_value, __v); \ - } - -#define GET_NODE(__s, __n) { \ - if ((__s)->node && (__s)->node->node) { \ - __n = (__s)->node->node; \ - } else { \ - __n = NULL; \ - php_error(E_WARNING, "Node no longer exists"); \ - } \ -} - -static xmlNodePtr php_sxe_get_first_node(php_sxe_object *sxe, xmlNodePtr node TSRMLS_DC) { - php_sxe_object *intern; - xmlNodePtr retnode = NULL; - - if (sxe && sxe->iter.type != SXE_ITER_NONE) { - php_sxe_reset_iterator(sxe TSRMLS_CC); - if (sxe->iter.data) { - intern = (php_sxe_object *)zend_object_store_get_object(sxe->iter.data TSRMLS_CC); - GET_NODE(intern, retnode) - } - return retnode; - } else { - return node; - } -} - -/* {{{ match_ns() - */ -static inline int -match_ns(php_sxe_object *sxe, xmlNodePtr node, xmlChar *name) -{ - if (name == NULL && (node->ns == NULL || node->ns->prefix == NULL)) { - return 1; - } - - if (node->ns && !xmlStrcmp(node->ns->href, name)) { - return 1; - } - - return 0; -} -/* }}} */ - -/* {{{ sxe_get_element_node() - */ -static xmlNodePtr sxe_get_element_by_offset(php_sxe_object *sxe, long offset, xmlNodePtr node) { - long nodendx = 0; - - if (sxe->iter.type == SXE_ITER_NONE) { - return NULL; - } - while (node && nodendx <= offset) { - SKIP_TEXT(node) - if (node->type == XML_ELEMENT_NODE && match_ns(sxe, node, sxe->iter.nsprefix)) { - if (sxe->iter.type == SXE_ITER_CHILD || ( - sxe->iter.type == SXE_ITER_ELEMENT && !xmlStrcmp(node->name, sxe->iter.name))) { - if (nodendx == offset) { - break; - } - nodendx++; - } - } -next_iter: - node = node->next; - } - - return node; -} -/* }}} */ - -/* {{{ sxe_prop_dim_read() - */ -static zval * sxe_prop_dim_read(zval *object, zval *member, zend_bool elements, zend_bool attribs, zend_bool silent TSRMLS_DC) -{ - zval *return_value; - php_sxe_object *sxe; - char *name; - xmlNodePtr node; - xmlAttrPtr attr; - zval tmp_zv; - int nodendx = 0; - - sxe = php_sxe_fetch_object(object TSRMLS_CC); - - if (Z_TYPE_P(member) == IS_LONG) { - if (sxe->iter.type != SXE_ITER_ATTRLIST) { - attribs = 0; - elements = 1; - } - } else { - if (Z_TYPE_P(member) != IS_STRING) { - tmp_zv = *member; - zval_copy_ctor(&tmp_zv); - member = &tmp_zv; - convert_to_string(member); - } - } - - MAKE_STD_ZVAL(return_value); - ZVAL_NULL(return_value); - - name = Z_STRVAL_P(member); - - GET_NODE(sxe, node); - - if (sxe->iter.type != SXE_ITER_CHILD && sxe->iter.type != SXE_ITER_ATTRLIST) { - node = php_sxe_get_first_node(sxe, node TSRMLS_CC); - } - - if (node) { - if (attribs) { - if (Z_TYPE_P(member) == IS_LONG && sxe->iter.type != SXE_ITER_ATTRLIST) { - attr = NULL; - } else { - attr = node->properties; - if (Z_TYPE_P(member) == IS_LONG) { - while (attr && nodendx <= Z_LVAL_P(member)) { - if (match_ns(sxe, (xmlNodePtr) attr, sxe->iter.nsprefix)) { - if (nodendx == Z_LVAL_P(member)) { - _node_as_zval(sxe, (xmlNodePtr) attr, return_value, SXE_ITER_NONE, NULL, sxe->iter.nsprefix TSRMLS_CC); - break; - } - nodendx++; - } - attr = attr->next; - } - } else { - while (attr) { - if (!xmlStrcmp(attr->name, name) && match_ns(sxe, (xmlNodePtr) attr, sxe->iter.nsprefix)) { - _node_as_zval(sxe, (xmlNodePtr) attr, return_value, SXE_ITER_NONE, NULL, sxe->iter.nsprefix TSRMLS_CC); - break; - } - attr = attr->next; - } - } - } - } - - if (elements) { - if (!sxe->node) { - php_libxml_increment_node_ptr((php_libxml_node_object *)sxe, node, NULL TSRMLS_CC); - } - if (Z_TYPE_P(member) == IS_LONG) { - if (sxe->iter.type == SXE_ITER_CHILD) { - node = php_sxe_get_first_node(sxe, node TSRMLS_CC); - } - node = sxe_get_element_by_offset(sxe, Z_LVAL_P(member), node); - if (node) { - _node_as_zval(sxe, node, return_value, SXE_ITER_NONE, NULL, sxe->iter.nsprefix TSRMLS_CC); - } - } else { - _node_as_zval(sxe, node, return_value, SXE_ITER_ELEMENT, name, sxe->iter.nsprefix TSRMLS_CC); - } - } - } - - return_value->refcount = 0; - return_value->is_ref = 0; - - if (member == &tmp_zv) { - zval_dtor(&tmp_zv); - } - - return return_value; -} -/* }}} */ - -/* {{{ sxe_property_read() - */ -static zval * sxe_property_read(zval *object, zval *member, zend_bool silent TSRMLS_DC) -{ - return sxe_prop_dim_read(object, member, 1, 0, silent TSRMLS_CC); -} -/* }}} */ - -/* {{{ sxe_dimension_read() - */ -static zval * sxe_dimension_read(zval *object, zval *offset TSRMLS_DC) -{ - return sxe_prop_dim_read(object, offset, 0, 1, 0 TSRMLS_CC); -} -/* }}} */ - -/* {{{ change_node_zval() - */ -static void -change_node_zval(xmlNodePtr node, zval *value) -{ - switch (Z_TYPE_P(value)) { - case IS_LONG: - case IS_BOOL: - case IS_DOUBLE: - case IS_NULL: - convert_to_string(value); - case IS_STRING: - xmlNodeSetContentLen(node, Z_STRVAL_P(value), Z_STRLEN_P(value)); - break; - default: - php_error(E_WARNING, "It is not possible to assign complex types to nodes"); - break; - } -} -/* }}} */ - -/* {{{ sxe_property_write() - */ -static void sxe_prop_dim_write(zval *object, zval *member, zval *value, zend_bool elements, zend_bool attribs TSRMLS_DC) -{ - php_sxe_object *sxe; - char *name; - xmlNodePtr node; - xmlNodePtr newnode = NULL; - xmlNodePtr tempnode; - xmlAttrPtr attr = NULL; - int counter = 0; - int is_attr = 0; - int nodendx = 0; - zval tmp_zv, trim_zv; - - if (!member) { - /* This happens when the user did: $sxe[] = $value - * and could also be E_PARSE, but we use this only during parsing - * and this is during runtime. - */ - php_error_docref(NULL TSRMLS_CC, E_ERROR, "Cannot create unnamed attribute"); - return; - } - - - sxe = php_sxe_fetch_object(object TSRMLS_CC); - - if (Z_TYPE_P(member) == IS_LONG) { - if (sxe->iter.type != SXE_ITER_ATTRLIST) { - attribs = 0; - elements = 1; - } - } else { - if (Z_TYPE_P(member) != IS_STRING) { - trim_zv = *member; - zval_copy_ctor(&trim_zv); - convert_to_string(&trim_zv); - php_trim(Z_STRVAL(trim_zv), Z_STRLEN(trim_zv), NULL, 0, &tmp_zv, 3 TSRMLS_CC); - zval_dtor(&trim_zv); - member = &tmp_zv; - } - - if (!Z_STRLEN_P(member)) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Cannot write or create unnamed %s", attribs ? "attribute" : "element"); - if (member == &tmp_zv) { - zval_dtor(&tmp_zv); - } - return; - } - } - - name = Z_STRVAL_P(member); - - GET_NODE(sxe, node); - - if (sxe->iter.type != SXE_ITER_ATTRLIST) { - node = php_sxe_get_first_node(sxe, node TSRMLS_CC); - } - - if (node) { - if (attribs) { - attr = node->properties; - if (Z_TYPE_P(member) == IS_LONG) { - while (attr && nodendx <= Z_LVAL_P(member)) { - if (match_ns(sxe, (xmlNodePtr) attr, sxe->iter.nsprefix)) { - if (nodendx == Z_LVAL_P(member)) { - is_attr = 1; - ++counter; - break; - } - nodendx++; - } - attr = attr->next; - } - } else { - while (attr) { - if (!xmlStrcmp(attr->name, name) && match_ns(sxe, (xmlNodePtr) attr, sxe->iter.nsprefix)) { - is_attr = 1; - ++counter; - break; - } - attr = attr->next; - } - } - - } - - if (elements) { - if (Z_TYPE_P(member) == IS_LONG) { - newnode = sxe_get_element_by_offset(sxe, Z_LVAL_P(member), node); - if (newnode) { - ++counter; - } - } else { - node = node->children; - while (node) { - SKIP_TEXT(node); - - if (!xmlStrcmp(node->name, name)) { - newnode = node; - ++counter; - } - -next_iter: - node = node->next; - } - } - } - - if (counter == 1) { - if (is_attr) { - newnode = (xmlNodePtr) attr; - } - while ((tempnode = (xmlNodePtr) newnode->children)) { - xmlUnlinkNode(tempnode); - php_libxml_node_free_resource((xmlNodePtr) tempnode TSRMLS_CC); - } - change_node_zval(newnode, value); - } else if (counter > 1) { - php_error(E_WARNING, "Cannot assign to an array of nodes (duplicate subnodes or attr detected)\n"); - } else { - if (attribs) { - switch (Z_TYPE_P(value)) { - case IS_LONG: - case IS_BOOL: - case IS_DOUBLE: - case IS_NULL: - convert_to_string(value); - case IS_STRING: - newnode = (xmlNodePtr)xmlNewProp(node, name, Z_STRVAL_P(value)); - break; - default: - php_error(E_WARNING, "It is not yet possible to assign complex types to attributes"); - } - } - } - } - - if (member == &tmp_zv) { - zval_dtor(&tmp_zv); - } -} -/* }}} */ - -/* {{{ sxe_property_write() - */ -static void sxe_property_write(zval *object, zval *member, zval *value TSRMLS_DC) -{ - sxe_prop_dim_write(object, member, value, 1, 0 TSRMLS_CC); -} -/* }}} */ - -/* {{{ sxe_dimension_write() - */ -static void sxe_dimension_write(zval *object, zval *offset, zval *value TSRMLS_DC) -{ - sxe_prop_dim_write(object, offset, value, 0, 1 TSRMLS_CC); -} -/* }}} */ - -/* {{{ sxe_prop_dim_exists() - */ -static int sxe_prop_dim_exists(zval *object, zval *member, int check_empty, zend_bool elements, zend_bool attribs TSRMLS_DC) -{ - php_sxe_object *sxe; - char *name; - xmlNodePtr node; - xmlAttrPtr attr = NULL; - int exists = 0; - - sxe = php_sxe_fetch_object(object TSRMLS_CC); - - name = Z_STRVAL_P(member); - - GET_NODE(sxe, node); - - if (Z_TYPE_P(member) == IS_LONG) { - if (sxe->iter.type != SXE_ITER_ATTRLIST) { - attribs = 0; - elements = 1; - if (sxe->iter.type == SXE_ITER_CHILD) { - node = php_sxe_get_first_node(sxe, node TSRMLS_CC); - } - } - } - - if (sxe->iter.type != SXE_ITER_CHILD && sxe->iter.type != SXE_ITER_ATTRLIST) { - node = php_sxe_get_first_node(sxe, node TSRMLS_CC); - } - - if (node) { - if (attribs) { - attr = node->properties; - while (attr) { - if (!xmlStrcmp(attr->name, name) && match_ns(sxe, (xmlNodePtr) attr, sxe->iter.nsprefix)) { - exists = 1; - break; - } - - attr = attr->next; - } - } - - if (elements) { - if (Z_TYPE_P(member) == IS_LONG) { - if (sxe->iter.type == SXE_ITER_CHILD) { - node = php_sxe_get_first_node(sxe, node TSRMLS_CC); - } - node = sxe_get_element_by_offset(sxe, Z_LVAL_P(member), node); - } - - if (node) { - exists = 1; - } - } - } - - return exists; -} -/* }}} */ - -/* {{{ sxe_property_exists() - */ -static int sxe_property_exists(zval *object, zval *member, int check_empty TSRMLS_DC) -{ - return sxe_prop_dim_exists(object, member, check_empty, 1, 0 TSRMLS_CC); -} -/* }}} */ - -/* {{{ sxe_property_exists() - */ -static int sxe_dimension_exists(zval *object, zval *member, int check_empty TSRMLS_DC) -{ - return sxe_prop_dim_exists(object, member, check_empty, 0, 1 TSRMLS_CC); -} -/* }}} */ - -/* {{{ sxe_prop_dim_delete() - */ -static void sxe_prop_dim_delete(zval *object, zval *member, zend_bool elements, zend_bool attribs TSRMLS_DC) -{ - php_sxe_object *sxe; - xmlNodePtr node; - xmlNodePtr nnext; - xmlAttrPtr attr; - xmlAttrPtr anext; - zval tmp_zv; - - if (Z_TYPE_P(member) != IS_STRING) { - tmp_zv = *member; - zval_copy_ctor(&tmp_zv); - member = &tmp_zv; - convert_to_string(member); - } - - sxe = php_sxe_fetch_object(object TSRMLS_CC); - - GET_NODE(sxe, node); - node = php_sxe_get_first_node(sxe, node TSRMLS_CC); - - if (node) { - if (attribs) { - attr = node->properties; - while (attr) { - anext = attr->next; - if (!xmlStrcmp(attr->name, Z_STRVAL_P(member)) && match_ns(sxe, (xmlNodePtr) attr, sxe->iter.nsprefix)) { - xmlUnlinkNode((xmlNodePtr) attr); - php_libxml_node_free_resource((xmlNodePtr) attr TSRMLS_CC); - break; - } - attr = anext; - } - } - - if (elements) { - node = node->children; - while (node) { - nnext = node->next; - - SKIP_TEXT(node); - - if (!xmlStrcmp(node->name, Z_STRVAL_P(member))) { - xmlUnlinkNode(node); - php_libxml_node_free_resource(node TSRMLS_CC); - } - -next_iter: - node = nnext; - } - } - } - - if (member == &tmp_zv) { - zval_dtor(&tmp_zv); - } -} -/* }}} */ - -/* {{{ sxe_property_delete() - */ -static void sxe_property_delete(zval *object, zval *member TSRMLS_DC) -{ - sxe_prop_dim_delete(object, member, 1, 0 TSRMLS_CC); -} -/* }}} */ - -/* {{{ sxe_dimension_unset() - */ -static void sxe_dimension_delete(zval *object, zval *offset TSRMLS_DC) -{ - sxe_prop_dim_delete(object, offset, 0, 1 TSRMLS_CC); -} -/* }}} */ - -/* {{{ _get_base_node_value() - */ -static void -_get_base_node_value(php_sxe_object *sxe_ref, xmlNodePtr node, zval **value TSRMLS_DC) -{ - php_sxe_object *subnode; - xmlChar *contents; - - MAKE_STD_ZVAL(*value); - - if (node->children && node->children->type == XML_TEXT_NODE && !xmlIsBlankNode(node->children)) { - contents = xmlNodeListGetString(node->doc, node->children, 1); - if (contents) { - ZVAL_STRING(*value, contents, 1); - xmlFree(contents); - } - } else { - subnode = php_sxe_object_new(sxe_ref->zo.ce TSRMLS_CC); - subnode->document = sxe_ref->document; - subnode->document->refcount++; - php_libxml_increment_node_ptr((php_libxml_node_object *)subnode, node, NULL TSRMLS_CC); - - (*value)->type = IS_OBJECT; - (*value)->value.obj = php_sxe_register_object(subnode TSRMLS_CC); - /*zval_add_ref(value);*/ - } -} -/* }}} */ - -/* {{{ sxe_properties_get() - */ -static HashTable * -sxe_properties_get(zval *object TSRMLS_DC) -{ - zval **data_ptr; - zval *value; - zval *newptr; - HashTable *rv; - php_sxe_object *sxe; - char *name; - xmlNodePtr node; - ulong h; - int namelen; - - sxe = php_sxe_fetch_object(object TSRMLS_CC); - - if (sxe->properties) { - zend_hash_clean(sxe->properties); - rv = sxe->properties; - } else { - ALLOC_HASHTABLE(rv); - zend_hash_init(rv, 0, NULL, ZVAL_PTR_DTOR, 0); - sxe->properties = rv; - } - - GET_NODE(sxe, node); - node = php_sxe_get_first_node(sxe, node TSRMLS_CC); - - if (node) { - node = node->children; - - while (node) { - if (node->children != NULL || node->prev != NULL || node->next != NULL) { - SKIP_TEXT(node); - } else { - if (node->type == XML_TEXT_NODE) { - MAKE_STD_ZVAL(value); - ZVAL_STRING(value, xmlNodeListGetString(node->doc, node, 1), 1); - zend_hash_next_index_insert(rv, &value, sizeof(zval *), NULL); - goto next_iter; - } - } - - name = (char *) node->name; - if (!name) { - goto next_iter; - } else { - namelen = xmlStrlen(node->name) + 1; - } - - _get_base_node_value(sxe, node, &value TSRMLS_CC); - - h = zend_hash_func(name, namelen); - if (zend_hash_quick_find(rv, name, namelen, h, (void **) &data_ptr) == SUCCESS) { - if (Z_TYPE_PP(data_ptr) == IS_ARRAY) { - zend_hash_next_index_insert(Z_ARRVAL_PP(data_ptr), &value, sizeof(zval *), NULL); - } else { - MAKE_STD_ZVAL(newptr); - array_init(newptr); - - zval_add_ref(data_ptr); - zend_hash_next_index_insert(Z_ARRVAL_P(newptr), data_ptr, sizeof(zval *), NULL); - zend_hash_next_index_insert(Z_ARRVAL_P(newptr), &value, sizeof(zval *), NULL); - - zend_hash_quick_update(rv, name, namelen, h, &newptr, sizeof(zval *), NULL); - } - } else { - zend_hash_quick_update(rv, name, namelen, h, &value, sizeof(zval *), NULL); - } - -next_iter: - node = node->next; - } - } - - return rv; -} -/* }}} */ - -/* {{{ sxe_objects_compare() - */ -static int -sxe_objects_compare(zval *object1, zval *object2 TSRMLS_DC) -{ - php_sxe_object *sxe1; - php_sxe_object *sxe2; - - sxe1 = php_sxe_fetch_object(object1 TSRMLS_CC); - sxe2 = php_sxe_fetch_object(object2 TSRMLS_CC); - - if (sxe1->node == NULL) { - if (sxe2->node) { - return 1; - } else if (sxe1->document->ptr == sxe2->document->ptr) { - return 0; - } - } else { - return !(sxe1->node == sxe2->node); - } - return 1; -} -/* }}} */ - -/* {{{ xpath() - */ -SXE_METHOD(xpath) -{ - php_sxe_object *sxe; - zval *value; - char *query; - int query_len; - int i; - int nsnbr = 0; - xmlNsPtr *ns = NULL; - xmlXPathObjectPtr retval; - xmlNodeSetPtr result; - xmlNodePtr nodeptr; - - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &query, &query_len) == FAILURE) { - return; - } - - sxe = php_sxe_fetch_object(getThis() TSRMLS_CC); - if (!sxe->xpath) { - sxe->xpath = xmlXPathNewContext((xmlDocPtr) sxe->document->ptr); - } - if (!sxe->node) { - php_libxml_increment_node_ptr((php_libxml_node_object *)sxe, xmlDocGetRootElement((xmlDocPtr) sxe->document->ptr), NULL TSRMLS_CC); - } - - sxe->xpath->node = sxe->node->node; - - ns = xmlGetNsList((xmlDocPtr) sxe->document->ptr, (xmlNodePtr) sxe->node->node); - if (ns != NULL) { - while (ns[nsnbr] != NULL) { - nsnbr++; - } - } - - sxe->xpath->namespaces = ns; - sxe->xpath->nsNr = nsnbr; - - retval = xmlXPathEval(query, sxe->xpath); - if (ns != NULL) { - xmlFree(ns); - sxe->xpath->namespaces = NULL; - sxe->xpath->nsNr = 0; - } - - if (!retval) { - RETURN_FALSE; - } - - result = retval->nodesetval; - if (!result) { - xmlXPathFreeObject(retval); - RETURN_FALSE; - } - - array_init(return_value); - - for (i = 0; i < result->nodeNr; ++i) { - nodeptr = result->nodeTab[i]; - if (nodeptr->type == XML_TEXT_NODE || nodeptr->type == XML_ELEMENT_NODE || nodeptr->type == XML_ATTRIBUTE_NODE) { - MAKE_STD_ZVAL(value); - /** - * Detect the case where the last selector is text(), simplexml - * always accesses the text() child by default, therefore we assign - * to the parent node. - */ - if (nodeptr->type == XML_TEXT_NODE) { - _node_as_zval(sxe, nodeptr->parent, value, SXE_ITER_NONE, NULL, NULL TSRMLS_CC); - } else { - _node_as_zval(sxe, nodeptr, value, SXE_ITER_NONE, NULL, NULL TSRMLS_CC); - } - - add_next_index_zval(return_value, value); - } - } - - xmlXPathFreeObject(retval); -} -/* }}} */ - -/* {{{ proto asXML([string filename]) - */ -SXE_METHOD(asXML) -{ - php_sxe_object *sxe; - xmlNodePtr node; - xmlOutputBufferPtr outbuf; - xmlChar *strval; - int strval_len; - char *filename; - int filename_len; - - if (ZEND_NUM_ARGS() > 1) { - RETURN_FALSE; - } - - if (ZEND_NUM_ARGS() == 1) { - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &filename, &filename_len) == FAILURE) { - RETURN_FALSE; - } - - sxe = php_sxe_fetch_object(getThis() TSRMLS_CC); - GET_NODE(sxe, node); - - if (node) { - if (XML_DOCUMENT_NODE == node->parent->type) { - xmlSaveFile(filename, (xmlDocPtr) sxe->document->ptr); - } else { - outbuf = xmlOutputBufferCreateFilename(filename, NULL, 0); - - if (outbuf == NULL) { - RETURN_FALSE; - } - - xmlNodeDumpOutput(outbuf, (xmlDocPtr) sxe->document->ptr, node, 0, 1, NULL); - xmlOutputBufferClose(outbuf); - RETURN_TRUE; - } - } else { - RETURN_FALSE; - } - } - - sxe = php_sxe_fetch_object(getThis() TSRMLS_CC); - GET_NODE(sxe, node); - - if (node) { - if (XML_DOCUMENT_NODE == node->parent->type) { - xmlDocDumpMemory((xmlDocPtr) sxe->document->ptr, &strval, &strval_len); - } else { - /* Should we be passing encoding information instead of NULL? */ - outbuf = xmlAllocOutputBuffer(NULL); - - if (outbuf == NULL) { - RETURN_FALSE; - } - - xmlNodeDumpOutput(outbuf, (xmlDocPtr) sxe->document->ptr, node, 0, 1, ((xmlDocPtr) sxe->document->ptr)->encoding); - xmlOutputBufferFlush(outbuf); - strval = xmlStrndup(outbuf->buffer->content, outbuf->buffer->use); - xmlOutputBufferClose(outbuf); - } - - RETVAL_STRINGL(strval, strlen(strval), 1); - xmlFree(strval); - } else { - RETVAL_FALSE; - } -} -/* }}} */ - -/* {{{ simplexml_children() - */ -SXE_METHOD(children) -{ - php_sxe_object *sxe; - char *nsprefix = NULL; - int nsprefix_len; - xmlNodePtr node; - - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s!", &nsprefix, &nsprefix_len) == FAILURE) { - return; - } - - sxe = php_sxe_fetch_object(getThis() TSRMLS_CC); - GET_NODE(sxe, node); - node = php_sxe_get_first_node(sxe, node TSRMLS_CC); - - _node_as_zval(sxe, node, return_value, SXE_ITER_CHILD, NULL, nsprefix TSRMLS_CC); - -} -/* }}} */ - -/* {{{ simplexml_attributes() - */ -SXE_METHOD(attributes) -{ - php_sxe_object *sxe; - char *nsprefix = NULL; - int nsprefix_len; - xmlNodePtr node; - - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s!", &nsprefix, &nsprefix_len) == FAILURE) { - return; - } - - sxe = php_sxe_fetch_object(getThis() TSRMLS_CC); - GET_NODE(sxe, node); - node = php_sxe_get_first_node(sxe, node TSRMLS_CC); - - _node_as_zval(sxe, node, return_value, SXE_ITER_ATTRLIST, NULL, nsprefix TSRMLS_CC); -} -/* }}} */ - -/* {{{ cast_object() - */ -static int -cast_object(zval *object, int type, char *contents TSRMLS_DC) -{ - if (contents) { - ZVAL_STRINGL(object, contents, strlen(contents), 1); - } else { - ZVAL_NULL(object); - } - object->refcount = 1; - object->is_ref = 0; - - switch (type) { - case IS_STRING: - convert_to_string(object); - break; - case IS_BOOL: - convert_to_boolean(object); - break; - case IS_LONG: - convert_to_long(object); - break; - case IS_DOUBLE: - convert_to_double(object); - break; - default: - return FAILURE; - } - return SUCCESS; -} -/* }}} */ - -/* {{{ sxe_object_cast() - */ -static int -sxe_object_cast(zval *readobj, zval *writeobj, int type, int should_free TSRMLS_DC) -{ - php_sxe_object *sxe; - char *contents = NULL; - xmlNodePtr node; - zval free_obj; - int rv; - - sxe = php_sxe_fetch_object(readobj TSRMLS_CC); - - if (should_free) { - free_obj = *writeobj; - } - - if (sxe->iter.type != SXE_ITER_NONE) { - node = php_sxe_get_first_node(sxe, NULL TSRMLS_CC); - if (node) { - contents = xmlNodeListGetString((xmlDocPtr) sxe->document->ptr, node->children, 1); - } - } else { - if (!sxe->node) { - if (sxe->document) { - php_libxml_increment_node_ptr((php_libxml_node_object *)sxe, xmlDocGetRootElement((xmlDocPtr) sxe->document->ptr), NULL TSRMLS_CC); - } - } - - if (sxe->node && sxe->node->node) { - if (sxe->node->node->children) { - contents = xmlNodeListGetString((xmlDocPtr) sxe->document->ptr, sxe->node->node->children, 1); - } - } - } - - rv = cast_object(writeobj, type, contents TSRMLS_CC); - - if (contents) { - xmlFree(contents); - } - if (should_free) { - zval_dtor(&free_obj); - } - return rv; -} -/* }}} */ - -static zend_object_handlers sxe_object_handlers = { - ZEND_OBJECTS_STORE_HANDLERS, - sxe_property_read, - sxe_property_write, - sxe_dimension_read, - sxe_dimension_write, - NULL, - NULL, - NULL, - sxe_property_exists, - sxe_property_delete, - sxe_dimension_exists, - sxe_dimension_delete, - sxe_properties_get, - NULL, /* zend_get_std_object_handlers()->get_method,*/ - NULL, /* zend_get_std_object_handlers()->call_method,*/ - NULL, /* zend_get_std_object_handlers()->get_constructor, */ - NULL, /* zend_get_std_object_handlers()->get_class_entry,*/ - NULL, /* zend_get_std_object_handlers()->get_class_name,*/ - sxe_objects_compare, - sxe_object_cast -}; - -/* {{{ sxe_object_clone() - */ -static void -sxe_object_clone(void *object, void **clone_ptr TSRMLS_DC) -{ - php_sxe_object *sxe = (php_sxe_object *) object; - php_sxe_object *clone; - xmlNodePtr nodep = NULL; - xmlDocPtr docp = NULL; - - clone = php_sxe_object_new(sxe->zo.ce TSRMLS_CC); - clone->document = sxe->document; - if (clone->document) { - clone->document->refcount++; - docp = clone->document->ptr; - } - if (sxe->node) { - nodep = xmlDocCopyNode(sxe->node->node, docp, 1); - } - - php_libxml_increment_node_ptr((php_libxml_node_object *)clone, nodep, NULL TSRMLS_CC); - - *clone_ptr = (void *) clone; -} -/* }}} */ - -/* {{{ sxe_object_dtor() - */ -static void sxe_object_dtor(void *object, zend_object_handle handle TSRMLS_DC) -{ - php_sxe_object *sxe; - - sxe = (php_sxe_object *) object; - - zend_hash_destroy(sxe->zo.properties); - FREE_HASHTABLE(sxe->zo.properties); - - if (sxe->iter.data) { - zval_ptr_dtor(&sxe->iter.data); - } - - if (sxe->iter.name) { - xmlFree(sxe->iter.name); - } - if (sxe->iter.nsprefix) { - xmlFree(sxe->iter.nsprefix); - } - - php_libxml_node_decrement_resource((php_libxml_node_object *)sxe TSRMLS_CC); - - if (sxe->xpath) { - xmlXPathFreeContext(sxe->xpath); - } - - if (sxe->properties) { - zend_hash_destroy(sxe->properties); - FREE_HASHTABLE(sxe->properties); - } - - efree(object); -} -/* }}} */ - -/* {{{ php_sxe_object_new() - */ -static php_sxe_object* php_sxe_object_new(zend_class_entry *ce TSRMLS_DC) -{ - php_sxe_object *intern; - - intern = ecalloc(1, sizeof(php_sxe_object)); - intern->zo.ce = ce; - - intern->iter.type = SXE_ITER_NONE; - intern->iter.nsprefix = NULL; - intern->iter.name = NULL; - - ALLOC_HASHTABLE(intern->zo.properties); - zend_hash_init(intern->zo.properties, 0, NULL, ZVAL_PTR_DTOR, 0); - - return intern; -} -/* }}} */ - -/* {{{ php_sxe_register_object - */ -static zend_object_value -php_sxe_register_object(php_sxe_object *intern TSRMLS_DC) -{ - zend_object_value rv; - - rv.handle = zend_objects_store_put(intern, sxe_object_dtor, sxe_object_clone TSRMLS_CC); - rv.handlers = (zend_object_handlers *) &sxe_object_handlers; - - return rv; -} -/* }}} */ - -/* {{{ sxe_object_new() - */ -ZEND_API zend_object_value -sxe_object_new(zend_class_entry *ce TSRMLS_DC) -{ - php_sxe_object *intern; - - intern = php_sxe_object_new(ce TSRMLS_CC); - return php_sxe_register_object(intern TSRMLS_CC); -} -/* }}} */ - -/* {{{ proto simplemxml_element simplexml_load_file(string filename [, string class_name]) - Load a filename and return a simplexml_element object to allow for processing */ -PHP_FUNCTION(simplexml_load_file) -{ - php_sxe_object *sxe; - char *filename; - int filename_len; - xmlDocPtr docp; - char *classname = ""; - int classname_len = 0; - zend_class_entry *ce= sxe_class_entry; - - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|s", &filename, &filename_len, &classname, &classname_len) == FAILURE) { - return; - } - - docp = xmlParseFile(filename); - if (! docp) { - RETURN_FALSE; - } - - if (classname_len) { - zend_class_entry **pce; - if (zend_lookup_class(classname, classname_len, &pce TSRMLS_CC) == FAILURE) { - php_error_docref(NULL TSRMLS_CC, E_ERROR, "Class %s does not exist", classname); - } - ce = *pce; - } - - sxe = php_sxe_object_new(ce TSRMLS_CC); - php_libxml_increment_doc_ref((php_libxml_node_object *)sxe, docp TSRMLS_CC); - php_libxml_increment_node_ptr((php_libxml_node_object *)sxe, xmlDocGetRootElement(docp), NULL TSRMLS_CC); - - return_value->type = IS_OBJECT; - return_value->value.obj = php_sxe_register_object(sxe TSRMLS_CC); -} -/* }}} */ - -/* {{{ proto simplemxml_element simplexml_load_string(string data [, string class_name]) - Load a string and return a simplexml_element object to allow for processing */ -PHP_FUNCTION(simplexml_load_string) -{ - php_sxe_object *sxe; - char *data; - int data_len; - xmlDocPtr docp; - char *classname = ""; - int classname_len = 0; - zend_class_entry *ce= sxe_class_entry; - - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|s", &data, &data_len, &classname, &classname_len) == FAILURE) { - return; - } - - docp = xmlParseMemory(data, data_len); - if (! docp) { - RETURN_FALSE; - } - - if (classname_len) { - zend_class_entry **pce; - if (zend_lookup_class(classname, classname_len, &pce TSRMLS_CC) == FAILURE) { - php_error_docref(NULL TSRMLS_CC, E_ERROR, "Class %s does not exist", classname); - } - ce = *pce; - } - - sxe = php_sxe_object_new(ce TSRMLS_CC); - php_libxml_increment_doc_ref((php_libxml_node_object *)sxe, docp TSRMLS_CC); - php_libxml_increment_node_ptr((php_libxml_node_object *)sxe, xmlDocGetRootElement(docp), NULL TSRMLS_CC); - - return_value->type = IS_OBJECT; - return_value->value.obj = php_sxe_register_object(sxe TSRMLS_CC); -} -/* }}} */ - -SXE_METHOD(__construct) -{ - php_sxe_object *sxe = php_sxe_fetch_object(getThis() TSRMLS_CC); - char *data; - int data_len; - xmlDocPtr docp; - - php_set_error_handling(EH_THROW, zend_exception_get_default() TSRMLS_CC); - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &data, &data_len) == FAILURE) { - php_std_error_handling(); - return; - } - - php_std_error_handling(); - docp = xmlParseMemory(data, data_len); - if (!docp) { - (php_libxml_node_object *)sxe->document = NULL; - zend_throw_exception(zend_exception_get_default(), "String could not be parsed as XML", 0 TSRMLS_CC); - return; - } - - php_libxml_increment_doc_ref((php_libxml_node_object *)sxe, docp TSRMLS_CC); - php_libxml_increment_node_ptr((php_libxml_node_object *)sxe, xmlDocGetRootElement(docp), NULL TSRMLS_CC); -} - -typedef struct { - zend_object_iterator intern; - php_sxe_object *sxe; -} php_sxe_iterator; - -static void php_sxe_iterator_dtor(zend_object_iterator *iter TSRMLS_DC); -static int php_sxe_iterator_has_more(zend_object_iterator *iter TSRMLS_DC); -static void php_sxe_iterator_current_data(zend_object_iterator *iter, zval ***data TSRMLS_DC); -static int php_sxe_iterator_current_key(zend_object_iterator *iter, char **str_key, uint *str_key_len, ulong *int_key TSRMLS_DC); -static void php_sxe_iterator_move_forward(zend_object_iterator *iter TSRMLS_DC); -static void php_sxe_iterator_rewind(zend_object_iterator *iter TSRMLS_DC); - -zend_object_iterator_funcs php_sxe_iterator_funcs = { - php_sxe_iterator_dtor, - php_sxe_iterator_has_more, - php_sxe_iterator_current_data, - php_sxe_iterator_current_key, - php_sxe_iterator_move_forward, - php_sxe_iterator_rewind, -}; - -ZEND_API void php_sxe_reset_iterator(php_sxe_object *sxe TSRMLS_DC) -{ - xmlNodePtr node; - char *prefix; - - if (sxe->iter.data) { - zval_ptr_dtor(&sxe->iter.data); - sxe->iter.data = NULL; - } - - GET_NODE(sxe, node) - - if (node) { - switch (sxe->iter.type) { - case SXE_ITER_ELEMENT: - case SXE_ITER_CHILD: - case SXE_ITER_NONE: - node = node->children; - break; - case SXE_ITER_ATTRLIST: - node = (xmlNodePtr) node->properties; - } - } - - prefix = sxe->iter.nsprefix; - - while (node) { - SKIP_TEXT(node); - if (sxe->iter.type != SXE_ITER_ATTRLIST && node->type == XML_ELEMENT_NODE) { - if (sxe->iter.type == SXE_ITER_ELEMENT) { - if (!xmlStrcmp(node->name, sxe->iter.name) && match_ns(sxe, node, prefix)) { - break; - } - } else { - if (match_ns(sxe, node, prefix)) { - break; - } - } - } else { - if (node->type == XML_ATTRIBUTE_NODE) { - if (match_ns(sxe, node, sxe->iter.nsprefix)) { - break; - } - } - } -next_iter: - node = node->next; - } - - if (node) { - ALLOC_INIT_ZVAL(sxe->iter.data); - _node_as_zval(sxe, node, sxe->iter.data, SXE_ITER_NONE, NULL, sxe->iter.nsprefix TSRMLS_CC); - } -} - -zend_object_iterator *php_sxe_get_iterator(zend_class_entry *ce, zval *object TSRMLS_DC) -{ - php_sxe_iterator *iterator = emalloc(sizeof(php_sxe_iterator)); - - object->refcount++; - iterator->intern.data = (void*)object; - iterator->intern.funcs = &php_sxe_iterator_funcs; - iterator->sxe = php_sxe_fetch_object(object TSRMLS_CC); - - return (zend_object_iterator*)iterator; -} - -static void php_sxe_iterator_dtor(zend_object_iterator *iter TSRMLS_DC) -{ - php_sxe_iterator *iterator = (php_sxe_iterator *)iter; - - zval_ptr_dtor((zval**)&iterator->intern.data); - - efree(iterator); -} - -static int php_sxe_iterator_has_more(zend_object_iterator *iter TSRMLS_DC) -{ - php_sxe_iterator *iterator = (php_sxe_iterator *)iter; - - return iterator->sxe->iter.data ? SUCCESS : FAILURE; -} - -static void php_sxe_iterator_current_data(zend_object_iterator *iter, zval ***data TSRMLS_DC) -{ - php_sxe_iterator *iterator = (php_sxe_iterator *)iter; - - *data = &iterator->sxe->iter.data; -} - -static int php_sxe_iterator_current_key(zend_object_iterator *iter, char **str_key, uint *str_key_len, ulong *int_key TSRMLS_DC) -{ - zval *curobj; - xmlNodePtr curnode = NULL; - php_sxe_object *intern; - int namelen; - - php_sxe_iterator *iterator = (php_sxe_iterator *)iter; - curobj = iterator->sxe->iter.data; - - intern = (php_sxe_object *)zend_object_store_get_object(curobj TSRMLS_CC); - if (intern != NULL && intern->node != NULL) { - curnode = (xmlNodePtr)((php_libxml_node_ptr *)intern->node)->node; - } - - namelen = xmlStrlen(curnode->name); - *str_key = estrndup(curnode->name, namelen); - *str_key_len = namelen + 1; - return HASH_KEY_IS_STRING; - -} - -ZEND_API void php_sxe_move_forward_iterator(php_sxe_object *sxe TSRMLS_DC) -{ - xmlNodePtr node = NULL; - php_sxe_object *intern; - char *prefix; - - if (sxe->iter.data) { - intern = (php_sxe_object *)zend_object_store_get_object(sxe->iter.data TSRMLS_CC); - GET_NODE(intern, node) - zval_ptr_dtor(&sxe->iter.data); - sxe->iter.data = NULL; - } - - if (node) { - node = node->next; - } - - prefix = sxe->iter.nsprefix; - - while (node) { - SKIP_TEXT(node); - - if (sxe->iter.type != SXE_ITER_ATTRLIST && node->type == XML_ELEMENT_NODE) { - if (sxe->iter.type == SXE_ITER_ELEMENT) { - if (!xmlStrcmp(node->name, sxe->iter.name) && match_ns(sxe, node, prefix)) { - break; - } - } else { - if (match_ns(sxe, node, prefix)) { - break; - } - } - } else { - if (node->type == XML_ATTRIBUTE_NODE) { - if (match_ns(sxe, node, sxe->iter.nsprefix)) { - break; - } - } - } -next_iter: - node = node->next; - } - - if (node) { - ALLOC_INIT_ZVAL(sxe->iter.data); - _node_as_zval(sxe, node, sxe->iter.data, SXE_ITER_NONE, NULL, sxe->iter.nsprefix TSRMLS_CC); - } -} - -static void php_sxe_iterator_move_forward(zend_object_iterator *iter TSRMLS_DC) -{ - php_sxe_iterator *iterator = (php_sxe_iterator *)iter; - php_sxe_move_forward_iterator(iterator->sxe TSRMLS_CC); -} - -static void php_sxe_iterator_rewind(zend_object_iterator *iter TSRMLS_DC) -{ - php_sxe_object *sxe; - - php_sxe_iterator *iterator = (php_sxe_iterator *)iter; - sxe = iterator->sxe; - - php_sxe_reset_iterator(sxe TSRMLS_CC); -} - - -/* {{{ proto simplemxml_element simplexml_import_dom(domNode node [, string class_name]) - Get a simplexml_element object from dom to allow for processing */ -PHP_FUNCTION(simplexml_import_dom) -{ -#ifdef HAVE_DOM - php_sxe_object *sxe; - zval *node; - php_libxml_node_object *object; - xmlNodePtr nodep = NULL; - char *classname = ""; - int classname_len = 0; - zend_class_entry *ce= sxe_class_entry; - - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o|s", &node, &classname, &classname_len) == FAILURE) { - return; - } - - object = (php_libxml_node_object *)zend_object_store_get_object(node TSRMLS_CC); - - if (object->node && object->node->node) { - nodep = object->node->node; - if (nodep->doc == NULL) { - php_error(E_WARNING, "Imported Node must have associated Document"); - RETURN_NULL(); - } - if (nodep->type == XML_DOCUMENT_NODE || nodep->type == XML_HTML_DOCUMENT_NODE) { - nodep = xmlDocGetRootElement((xmlDocPtr) nodep); - } - } - - if (nodep && nodep->type == XML_ELEMENT_NODE) { - if (classname_len) { - zend_class_entry **pce; - if (zend_lookup_class(classname, classname_len, &pce TSRMLS_CC) == FAILURE) { - php_error_docref(NULL TSRMLS_CC, E_ERROR, "Class %s does not exist", classname); - } - ce = *pce; - } - - sxe = php_sxe_object_new(ce TSRMLS_CC); - sxe->document = object->document; - php_libxml_increment_doc_ref((php_libxml_node_object *)sxe, nodep->doc TSRMLS_CC); - php_libxml_increment_node_ptr((php_libxml_node_object *)sxe, nodep, NULL TSRMLS_CC); - - return_value->type = IS_OBJECT; - return_value->value.obj = php_sxe_register_object(sxe TSRMLS_CC); - } else { - php_error(E_WARNING, "Invalid Nodetype to import"); - RETVAL_NULL(); - } -#else - php_error(E_WARNING, "DOM support is not enabled"); - return; -#endif -} -/* }}} */ - -function_entry simplexml_functions[] = { - PHP_FE(simplexml_load_file, NULL) - PHP_FE(simplexml_load_string, NULL) - PHP_FE(simplexml_import_dom, NULL) - {NULL, NULL, NULL} -}; - -zend_module_entry simplexml_module_entry = { - STANDARD_MODULE_HEADER, - "simplexml", - simplexml_functions, - PHP_MINIT(simplexml), - NULL, - NULL, - NULL, - PHP_MINFO(simplexml), - "0.1", - STANDARD_MODULE_PROPERTIES -}; - -#ifdef COMPILE_DL_SIMPLEXML -ZEND_GET_MODULE(simplexml) -#endif - -/* the method table */ -/* each method can have its own parameters and visibility */ -static zend_function_entry sxe_functions[] = { - SXE_ME(__construct, NULL, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) /* must be called */ - SXE_ME(asXML, NULL, ZEND_ACC_PUBLIC) - SXE_ME(xpath, NULL, ZEND_ACC_PUBLIC) - SXE_ME(attributes, NULL, ZEND_ACC_PUBLIC) - SXE_ME(children, NULL, ZEND_ACC_PUBLIC) - {NULL, NULL, NULL} -}; - -/* {{{ PHP_MINIT_FUNCTION(simplexml) - */ -PHP_MINIT_FUNCTION(simplexml) -{ - zend_class_entry sxe; - - INIT_CLASS_ENTRY(sxe, "simplexml_element", sxe_functions); - sxe.create_object = sxe_object_new; - sxe_class_entry = zend_register_internal_class(&sxe TSRMLS_CC); - sxe_class_entry->get_iterator = php_sxe_get_iterator; - zend_class_implements(sxe_class_entry TSRMLS_CC, 1, zend_ce_traversable); - sxe_object_handlers.get_method = zend_get_std_object_handlers()->get_method; - sxe_object_handlers.get_constructor = zend_get_std_object_handlers()->get_constructor; - sxe_object_handlers.get_class_entry = zend_get_std_object_handlers()->get_class_entry; - sxe_object_handlers.get_class_name = zend_get_std_object_handlers()->get_class_name; - -#if HAVE_SPL && !defined(COMPILE_DL_SPL) - if (zend_get_module_started("spl") == SUCCESS) { - PHP_MINIT(spl_sxe)(INIT_FUNC_ARGS_PASSTHRU); - } -#endif /* HAVE_SPL */ - - return SUCCESS; -} -/* }}} */ - -/* {{{ PHP_MINFO_FUNCTION(simplexml) - */ -PHP_MINFO_FUNCTION(simplexml) -{ - php_info_print_table_start(); - php_info_print_table_header(2, "Simplexml support", "enabled"); - php_info_print_table_row(2, "Revision", "$Revision$"); - php_info_print_table_row(2, "Schema support", -#ifdef LIBXML_SCHEMAS_ENABLED - "enabled"); -#else - "not available"); -#endif - php_info_print_table_end(); -} -/* }}} */ - -#endif - -/** - * Local Variables: - * c-basic-offset: 4 - * tab-width: 4 - * indent-tabs-mode: t - * End: - * vim600: fdm=marker - * vim: noet sw=4 ts=4 - */ diff --git a/ext/simplexml/simplexml.dsp b/ext/simplexml/simplexml.dsp deleted file mode 100644 index 79df918703..0000000000 --- a/ext/simplexml/simplexml.dsp +++ /dev/null @@ -1,111 +0,0 @@ -# Microsoft Developer Studio Project File - Name="simplexml" - Package Owner=<4>
-# Microsoft Developer Studio Generated Build File, Format Version 6.00
-# ** DO NOT EDIT **
-
-# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
-
-CFG=simplexml - Win32 Debug_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 "simplexml.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 "simplexml.mak" CFG="simplexml - Win32 Debug_TS"
-!MESSAGE
-!MESSAGE Possible choices for configuration are:
-!MESSAGE
-!MESSAGE "simplexml - Win32 Debug_TS" (based on "Win32 (x86) Dynamic-Link Library")
-!MESSAGE "simplexml - Win32 Release_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)" == "simplexml - Win32 Debug_TS"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir "Debug_TS"
-# PROP BASE Intermediate_Dir "Debug_TS"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir "c:\php\5d\extensions"
-# PROP Intermediate_Dir "Debug_TS"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "SIMPLEXML_EXPORTS" /YX /FD /GZ /c
-# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "..\..\..\php5" /I "..\..\..\php5\main" /I "..\..\..\php5\Zend" /I "..\..\..\php5\TSRM" /D ZEND_DEBUG=1 /D ZTS=1 /D "ZEND_WIN32" /D "PHP_WIN32" /D COMPILE_DL_SIMPLEXML=1 /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "SIMPLEXML_EXPORTS" /D "LIBXML_THREAD_ENABLED" /YX /FD /GZ /c
-# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
-# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
-# ADD BASE RSC /l 0x409 /d "_DEBUG"
-# ADD RSC /l 0x409 /d "_DEBUG"
-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 /nologo /dll /debug /machine:I386 /pdbtype:sept
-# ADD LINK32 php5ts_debug.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 /debug /machine:I386 /pdbtype:sept /libpath:"..\..\..\php5\Debug_TS"
-
-!ELSEIF "$(CFG)" == "simplexml - 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 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 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "SIMPLEXML_EXPORTS" /YX /FD /c
-# ADD CPP /nologo /MT /W3 /GX /O2 /I "..\..\..\php5\main" /I "..\..\..\php5\Zend" /I "..\..\..\php5\TSRM" /I "..\..\..\php5\win32" /I "..\..\..\php5" /D ZTS=1 /D ZEND_DEBUG=0 /D "ZEND_WIN32" /D "PHP_WIN32" /D COMPILE_DL_SIMPLEXML=1 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "SIMPLEXML_EXPORTS" /D "LIBXML_THREAD_ENABLED" /YX /FD /c
-# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
-# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
-# ADD BASE RSC /l 0x409 /d "NDEBUG"
-# ADD RSC /l 0x409 /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 /nologo /dll /machine:I386
-# ADD LINK32 php5ts.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 /libpath:"..\..\..\php5\Release_TS" /libpath:"..\..\..\php5\Release_TS_Inline"
-
-!ENDIF
-
-# Begin Target
-
-# Name "simplexml - Win32 Debug_TS"
-# Name "simplexml - Win32 Release_TS"
-# Begin Group "Source Files"
-
-# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
-# Begin Source File
-
-SOURCE=.\simplexml.c
-# End Source File
-# End Group
-# Begin Group "Header Files"
-
-# PROP Default_Filter "h;hpp;hxx;hm;inl"
-# Begin Source File
-
-SOURCE=.\php_simplexml.h
-# End Source File
-# End Group
-# Begin Group "Resource Files"
-
-# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
-# End Group
-# End Target
-# End Project
diff --git a/ext/simplexml/tests/001.phpt b/ext/simplexml/tests/001.phpt deleted file mode 100644 index 123c91d244..0000000000 --- a/ext/simplexml/tests/001.phpt +++ /dev/null @@ -1,43 +0,0 @@ ---TEST-- -SimpleXML: Simple document ---SKIPIF-- -<?php if (!extension_loaded("simplexml")) print "skip"; ?> ---FILE-- -<?php - -$sxe = simplexml_load_file(dirname(__FILE__).'/sxe.xml'); - -print_r($sxe); - -echo "---Done---\n"; - -?> ---EXPECT-- -simplexml_element Object -( - [elem1] => simplexml_element Object - ( - [comment] => simplexml_element Object - ( - ) - - [elem2] => simplexml_element Object - ( - [elem3] => simplexml_element Object - ( - [elem4] => simplexml_element Object - ( - [test] => simplexml_element Object - ( - ) - - ) - - ) - - ) - - ) - -) ----Done--- diff --git a/ext/simplexml/tests/002.phpt b/ext/simplexml/tests/002.phpt deleted file mode 100644 index 009101adb0..0000000000 --- a/ext/simplexml/tests/002.phpt +++ /dev/null @@ -1,62 +0,0 @@ ---TEST-- -SimpleXML and clone ---SKIPIF-- -<?php if (!extension_loaded("simplexml")) print "skip"; ?> ---FILE-- -<?php - -$xml =<<<EOF -<?xml version='1.0'?> -<!DOCTYPE sxe SYSTEM "notfound.dtd"> -<sxe id="elem1"> - <elem1 attr1='first'> - <!-- comment --> - <elem2> - <elem3> - <elem4> - <?test processing instruction ?> - </elem4> - </elem3> - </elem2> - </elem1> -</sxe> -EOF; - -$sxe = simplexml_load_string($xml); - -$copy = $sxe->__clone(); - -print_r($copy); - -echo "---Done---\n"; - -?> ---EXPECT-- -simplexml_element Object -( - [elem1] => simplexml_element Object - ( - [comment] => simplexml_element Object - ( - ) - - [elem2] => simplexml_element Object - ( - [elem3] => simplexml_element Object - ( - [elem4] => simplexml_element Object - ( - [test] => simplexml_element Object - ( - ) - - ) - - ) - - ) - - ) - -) ----Done--- diff --git a/ext/simplexml/tests/003.phpt b/ext/simplexml/tests/003.phpt deleted file mode 100755 index 0924fd044f..0000000000 --- a/ext/simplexml/tests/003.phpt +++ /dev/null @@ -1,69 +0,0 @@ ---TEST-- -SimpleXML and Entities ---SKIPIF-- -<?php if (!extension_loaded("simplexml")) print "skip"; ?> ---FILE-- -<?php - -$xml =<<<EOF -<?xml version='1.0'?> -<!DOCTYPE sxe SYSTEM "notfound.dtd" [ -<!ENTITY included-entity "This is text included from an entity"> -]> -<sxe id="elem1"> - Plain text. - <elem1 attr1='first'> - <!-- comment --> - <elem2> - <elem3> - &included-entity; - <elem4> - <?test processing instruction ?> - </elem4> - </elem3> - </elem2> - </elem1> -</sxe> -EOF; - -$sxe = simplexml_load_string($xml); - -print_r($sxe); - -echo "---Done---\n"; - -?> ---EXPECT-- -simplexml_element Object -( - [elem1] => simplexml_element Object - ( - [comment] => simplexml_element Object - ( - ) - - [elem2] => simplexml_element Object - ( - [elem3] => simplexml_element Object - ( - [included-entity] => simplexml_element Object - ( - [included-entity] => This is text included from an entity - ) - - [elem4] => simplexml_element Object - ( - [test] => simplexml_element Object - ( - ) - - ) - - ) - - ) - - ) - -) ----Done--- diff --git a/ext/simplexml/tests/004.phpt b/ext/simplexml/tests/004.phpt deleted file mode 100755 index b82f66567c..0000000000 --- a/ext/simplexml/tests/004.phpt +++ /dev/null @@ -1,65 +0,0 @@ ---TEST-- -SimpleXML and CDATA ---SKIPIF-- -<?php if (!extension_loaded("simplexml")) print "skip"; ?> ---FILE-- -<?php - -$sxe = simplexml_load_string(<<<EOF -<?xml version='1.0'?> -<!DOCTYPE sxe SYSTEM "notfound.dtd"> -<sxe id="elem1"> - Plain text. - <elem1 attr1='first'> - <!-- comment --> - <elem2> - <![CDATA[CDATA block]]> - <elem3> - <elem4> - <?test processing instruction ?> - </elem4> - </elem3> - </elem2> - </elem1> -</sxe> -EOF -); - -print_r($sxe); - -$elem1 = $sxe->elem1; -$elem2 = $elem1->elem2; -var_dump(trim((string)$elem2)); - -?> -===DONE=== ---EXPECT-- -simplexml_element Object -( - [elem1] => simplexml_element Object - ( - [comment] => simplexml_element Object - ( - ) - - [elem2] => simplexml_element Object - ( - [elem3] => simplexml_element Object - ( - [elem4] => simplexml_element Object - ( - [test] => simplexml_element Object - ( - ) - - ) - - ) - - ) - - ) - -) -string(11) "CDATA block" -===DONE=== diff --git a/ext/simplexml/tests/005.phpt b/ext/simplexml/tests/005.phpt deleted file mode 100755 index 237a5d2616..0000000000 --- a/ext/simplexml/tests/005.phpt +++ /dev/null @@ -1,40 +0,0 @@ ---TEST-- -SimpleXML and text data ---SKIPIF-- -<?php if (!extension_loaded("simplexml")) print "skip"; ?> ---FILE-- -<?php - -$sxe = simplexml_load_string(<<<EOF -<?xml version='1.0'?> -<!DOCTYPE sxe SYSTEM "notfound.dtd"> -<sxe id="elem1"> - Plain text. - <elem1 attr1='first'> - <!-- comment --> - <elem2> - Here we have some text data. - <elem3> - And here some more. - <elem4> - Wow once again. - </elem4> - </elem3> - </elem2> - </elem1> -</sxe> -EOF -); - -var_dump(trim($sxe->elem1->elem2)); -var_dump(trim($sxe->elem1->elem2->elem3)); -var_dump(trim($sxe->elem1->elem2->elem3->elem4)); - -echo "---Done---\n"; - -?> ---EXPECT-- -string(28) "Here we have some text data." -string(19) "And here some more." -string(15) "Wow once again." ----Done--- diff --git a/ext/simplexml/tests/006.phpt b/ext/simplexml/tests/006.phpt deleted file mode 100755 index 9e81f20dd9..0000000000 --- a/ext/simplexml/tests/006.phpt +++ /dev/null @@ -1,80 +0,0 @@ ---TEST-- -SimpleXML and foreach ---SKIPIF-- -<?php if (!extension_loaded("simplexml")) print "skip"; ?> ---FILE-- -<?php - -$sxe = simplexml_load_string(<<<EOF -<?xml version='1.0'?> -<!DOCTYPE sxe SYSTEM "notfound.dtd"> -<sxe id="elem1"> - Plain text. - <elem1 attr1='first'> - Bla bla 1. - <!-- comment --> - <elem2> - Here we have some text data. - <elem3> - And here some more. - <elem4> - Wow once again. - </elem4> - </elem3> - </elem2> - </elem1> - <elem11 attr2='second'> - Bla bla 2. - <elem111> - Foo Bar - </elem111> - </elem11> -</sxe> -EOF -); - -foreach($sxe as $name => $data) { - var_dump($name); - var_dump(trim($data)); -} - -echo "===CLONE===\n"; - -foreach($sxe->__clone() as $name => $data) { - var_dump($name); - var_dump(trim($data)); -} - -echo "===ELEMENT===\n"; - -foreach($sxe->elem11 as $name => $data) { - var_dump($name); - var_dump(trim($data)); -} - -echo "===COMMENT===\n"; - -foreach($sxe->elem1 as $name => $data) { - var_dump($name); - var_dump(trim($data)); -} - -?> -===DONE=== ---EXPECT-- -string(5) "elem1" -string(10) "Bla bla 1." -string(6) "elem11" -string(10) "Bla bla 2." -===CLONE=== -string(5) "elem1" -string(10) "Bla bla 1." -string(6) "elem11" -string(10) "Bla bla 2." -===ELEMENT=== -string(6) "elem11" -string(10) "Bla bla 2." -===COMMENT=== -string(5) "elem1" -string(10) "Bla bla 1." -===DONE=== diff --git a/ext/simplexml/tests/007.phpt b/ext/simplexml/tests/007.phpt deleted file mode 100755 index 5b44b63837..0000000000 --- a/ext/simplexml/tests/007.phpt +++ /dev/null @@ -1,92 +0,0 @@ ---TEST-- -SimpleXML and attributes ---SKIPIF-- -<?php if (!extension_loaded("simplexml")) print "skip"; ?> ---FILE-- -<?php - -$xml =<<<EOF -<?xml version='1.0'?> -<!DOCTYPE sxe SYSTEM "notfound.dtd"> -<sxe id="elem1"> - <elem1 attr1='first'> - <!-- comment --> - <elem2> - <elem3> - <elem4> - <?test processing instruction ?> - </elem4> - </elem3> - </elem2> - </elem1> -</sxe> -EOF; - -$sxe = simplexml_load_string($xml); - -echo "===Property===\n"; -var_dump($sxe->elem1); -echo "===Array===\n"; -var_dump($sxe['id']); -var_dump($sxe->elem1['attr1']); -echo "===Set===\n"; -$sxe['id'] = "Changed1"; -var_dump($sxe['id']); -$sxe->elem1['attr1'] = 12; -var_dump($sxe->elem1['attr1']); -echo "===Unset===\n"; -unset($sxe['id']); -var_dump($sxe['id']); -unset($sxe->elem1['attr1']); -var_dump($sxe->elem1['attr1']); -echo "===Misc.===\n"; -$a = 4; -var_dump($a); -$dummy = $sxe->elem1[$a]; -var_dump($a); -?> -===Done=== ---EXPECTF-- -===Property=== -object(simplexml_element)#%d (2) { - ["comment"]=> - object(simplexml_element)#%d (0) { - } - ["elem2"]=> - object(simplexml_element)#%d (1) { - ["elem3"]=> - object(simplexml_element)#%d (1) { - ["elem4"]=> - object(simplexml_element)#%d (1) { - ["test"]=> - object(simplexml_element)#%d (0) { - } - } - } - } -} -===Array=== -object(simplexml_element)#%d (1) { - [0]=> - string(5) "elem1" -} -object(simplexml_element)#%d (1) { - [0]=> - string(5) "first" -} -===Set=== -object(simplexml_element)#%d (1) { - [0]=> - string(8) "Changed1" -} -object(simplexml_element)#%d (1) { - [0]=> - string(2) "12" -} -===Unset=== -NULL -NULL -===Misc.=== -int(4) -int(4) -===Done=== diff --git a/ext/simplexml/tests/008.phpt b/ext/simplexml/tests/008.phpt deleted file mode 100644 index 68b6f39351..0000000000 --- a/ext/simplexml/tests/008.phpt +++ /dev/null @@ -1,39 +0,0 @@ ---TEST-- -SimpleXML and XPath ---SKIPIF-- -<?php if (!extension_loaded("simplexml")) print "skip"; ?> ---FILE-- -<?php - -$xml =<<<EOF -<?xml version='1.0'?> -<!DOCTYPE sxe SYSTEM "notfound.dtd"> -<sxe id="elem1"> - <elem1 attr1='first'> - <!-- comment --> - <elem2> - <elem3> - <elem4> - <?test processing instruction ?> - </elem4> - </elem3> - </elem2> - </elem1> -</sxe> -EOF; - -$sxe = simplexml_load_string($xml); - -var_dump($sxe->xpath("elem1/elem2/elem3/elem4")); -var_dump($sxe->xpath("***")); -?> ---EXPECTF-- -array(1) { - [0]=> - object(simplexml_element)#%d (1) { - ["test"]=> - object(simplexml_element)#%d (0) { - } - } -} -bool(false) diff --git a/ext/simplexml/tests/009.phpt b/ext/simplexml/tests/009.phpt deleted file mode 100755 index d4543f483e..0000000000 --- a/ext/simplexml/tests/009.phpt +++ /dev/null @@ -1,45 +0,0 @@ ---TEST-- -SimpleXML and foreach ---SKIPIF-- -<?php if (!extension_loaded("simplexml")) print "skip"; ?> ---FILE-- -<?php -$sxe = simplexml_load_string(<<<EOF -<?xml version='1.0'?> -<!DOCTYPE sxe SYSTEM "notfound.dtd"> -<sxe id="elem1"> - Plain text. - <elem1 attr1='first'> - Bla bla 1. - <!-- comment --> - <elem2> - Here we have some text data. - <elem3> - And here some more. - <elem4> - Wow once again. - </elem4> - </elem3> - </elem2> - </elem1> - <elem11 attr2='second'> - Bla bla 2. - </elem11> -</sxe> -EOF -); -foreach($sxe->children() as $name=>$val) { - var_dump($name); - var_dump(get_class($val)); - var_dump(trim((string)$val)); -} -?> -===DONE=== ---EXPECT-- -string(5) "elem1" -string(17) "simplexml_element" -string(10) "Bla bla 1." -string(6) "elem11" -string(17) "simplexml_element" -string(10) "Bla bla 2." -===DONE=== diff --git a/ext/simplexml/tests/010.phpt b/ext/simplexml/tests/010.phpt deleted file mode 100644 index 20e2f89a26..0000000000 --- a/ext/simplexml/tests/010.phpt +++ /dev/null @@ -1,63 +0,0 @@ ---TEST-- -SimpleXML: Simple Inheritance ---SKIPIF-- -<?php if (!extension_loaded("simplexml")) print "skip"; ?> ---FILE-- -<?php - -class simplexml_inherited extends simplexml_element -{ -} - -$xml =<<<EOF -<?xml version='1.0'?> -<!DOCTYPE sxe SYSTEM "notfound.dtd"> -<sxe id="elem1"> - <elem1 attr1='first'> - <!-- comment --> - <elem2> - <elem3> - <elem4> - <?test processing instruction ?> - </elem4> - </elem3> - </elem2> - </elem1> -</sxe> -EOF; - -$sxe = simplexml_load_string($xml, 'simplexml_inherited'); - -print_r($sxe); - -?> -===DONE=== ---EXPECT-- -simplexml_inherited Object -( - [elem1] => simplexml_inherited Object - ( - [comment] => simplexml_inherited Object - ( - ) - - [elem2] => simplexml_inherited Object - ( - [elem3] => simplexml_inherited Object - ( - [elem4] => simplexml_inherited Object - ( - [test] => simplexml_inherited Object - ( - ) - - ) - - ) - - ) - - ) - -) -===DONE=== diff --git a/ext/simplexml/tests/011.phpt b/ext/simplexml/tests/011.phpt deleted file mode 100755 index f48c9f1eec..0000000000 --- a/ext/simplexml/tests/011.phpt +++ /dev/null @@ -1,47 +0,0 @@ ---TEST-- -SimpleXML and echo/print ---SKIPIF-- -<?php - if (!extension_loaded('simplexml')) print 'skip'; -?> ---FILE-- -<?php - -$xml =<<<EOF -<?xml version="1.0" encoding="ISO-8859-1" ?> -<foo> - <bar>bar</bar> - <baz>baz1</baz> - <baz>baz2</baz> -</foo> -EOF; - -$sxe = simplexml_load_string($xml); - -echo "===BAR===\n"; -echo $sxe->bar; -echo "\n"; - -echo "===BAZ===\n"; -echo $sxe->baz; -echo "\n"; - -echo "===BAZ0===\n"; -echo $sxe->baz[0]; -echo "\n"; - -echo "===BAZ1===\n"; -print $sxe->baz[1]; -echo "\n"; -?> -===DONE=== ---EXPECT-- -===BAR=== -bar -===BAZ=== -baz1 -===BAZ0=== -baz1 -===BAZ1=== -baz2 -===DONE=== diff --git a/ext/simplexml/tests/012.phpt b/ext/simplexml/tests/012.phpt deleted file mode 100755 index 79c01107fe..0000000000 --- a/ext/simplexml/tests/012.phpt +++ /dev/null @@ -1,39 +0,0 @@ ---TEST-- -SimpleXML and Attribute creation ---SKIPIF-- -<?php - if (!extension_loaded('simplexml')) print 'skip'; -?> ---FILE-- -<?php - -$xml =<<<EOF -<?xml version="1.0" encoding="ISO-8859-1" ?> -<foo/> -EOF; - -$sxe = simplexml_load_string($xml); - - -$sxe[""] = "warning"; -$sxe["attr"] = "value"; - -echo $sxe->asXML(); - -$sxe["attr"] = "new value"; - -echo $sxe->asXML(); - -$sxe[] = "error"; - -?> -===DONE=== ---EXPECTF-- - -Warning: main(): Cannot write or create unnamed attribute in %s012.php on line %d -<?xml version="1.0" encoding="ISO-8859-1"?> -<foo attr="value"/> -<?xml version="1.0" encoding="ISO-8859-1"?> -<foo attr="new value"/> - -Fatal error: main(): Cannot create unnamed attribute in %s012.php on line %d diff --git a/ext/simplexml/tests/013.phpt b/ext/simplexml/tests/013.phpt deleted file mode 100755 index fbd80b0c44..0000000000 --- a/ext/simplexml/tests/013.phpt +++ /dev/null @@ -1,23 +0,0 @@ ---TEST-- -SimpleXML and Split text content ---SKIPIF-- -<?php - if (!extension_loaded('simplexml')) print 'skip'; -?> ---FILE-- -<?php - -$xml =<<<EOF -<?xml version="1.0" encoding="ISO-8859-1" ?> -<foo>bar<baz/>bar</foo> -EOF; - -$sxe = simplexml_load_string($xml); - -var_dump((string)$sxe); - -?> -===DONE=== ---EXPECT-- -string(6) "barbar" -===DONE=== diff --git a/ext/simplexml/tests/014.phpt b/ext/simplexml/tests/014.phpt deleted file mode 100644 index 4c559d8a15..0000000000 --- a/ext/simplexml/tests/014.phpt +++ /dev/null @@ -1,57 +0,0 @@ ---TEST-- -SimpleXML: adding/removing attributes (direct) ---SKIPIF-- -<?php if (!extension_loaded("simplexml")) print "skip"; ?> ---FILE-- -<?php -$xml =<<<EOF -<people> - <person name="Joe"></person> -</people> -EOF; - -$people = simplexml_load_string($xml); -var_dump($people->person['name']); -var_dump($people->person['age']); -$person = $people->person; -$person['name'] = "XXX"; -var_dump($people->person['name']); -$people->person['age'] = 30; -var_dump($people->person['age']); -echo "---Unset:---\n"; -unset($people->person['age']); -echo "---Unset?---\n"; -var_dump($people->person['age']); -var_dump(isset($people->person['age'])); -$people->person['age'] = 30; -echo "---Unsupported---\n"; -var_dump($people->person['age']); -$people->person['age'] += 5; -var_dump($people->person['age']); -?> -===DONE=== ---EXPECTF-- -object(simplexml_element)#%d (1) { - [0]=> - string(3) "Joe" -} -NULL -object(simplexml_element)#%d (1) { - [0]=> - string(3) "XXX" -} -object(simplexml_element)#%d (1) { - [0]=> - string(2) "30" -} ----Unset:--- ----Unset?--- -NULL -bool(false) ----Unsupported--- -object(simplexml_element)#%d (1) { - [0]=> - string(2) "30" -} - -Fatal error: Unsupported operand types in %s014.php on line %d diff --git a/ext/simplexml/tests/014a.phpt b/ext/simplexml/tests/014a.phpt deleted file mode 100755 index 5f2e15a74f..0000000000 --- a/ext/simplexml/tests/014a.phpt +++ /dev/null @@ -1,56 +0,0 @@ ---TEST-- -SimpleXML: adding/removing attributes (single) ---SKIPIF-- -<?php if (!extension_loaded("simplexml")) print "skip"; ?> ---FILE-- -<?php -$xml =<<<EOF -<people> - <person name="Joe"></person> -</people> -EOF; - -$people = simplexml_load_string($xml); -var_dump($people->person[0]['name']); -var_dump($people->person[0]['age']); -$person = $people->person[0]; -$person['name'] = "XXX"; -var_dump($people->person[0]['name']); -$people->person[0]['age'] = 30; -var_dump($people->person[0]['age']); -echo "---Unset:---\n"; -unset($people->person[0]['age']); -echo "---Unset?---\n"; -var_dump($people->person[0]['age']); -var_dump(isset($people->person[0]['age'])); -echo "---Unsupported---\n"; -var_dump($people->person[0]['age']); -$people->person['age'] += 5; -var_dump($people->person[0]['age']); -?> -===DONE=== ---EXPECTF-- -object(simplexml_element)#%d (1) { - [0]=> - string(3) "Joe" -} -NULL -object(simplexml_element)#%d (1) { - [0]=> - string(3) "XXX" -} -object(simplexml_element)#%d (1) { - [0]=> - string(2) "30" -} ----Unset:--- ----Unset?--- -NULL -bool(false) ----Unsupported--- -object(simplexml_element)#%d (1) { - [0]=> - string(2) "30" -} - -Fatal error: Unsupported operand types in %s014.php on line %d diff --git a/ext/simplexml/tests/014b.phpt b/ext/simplexml/tests/014b.phpt deleted file mode 100755 index 2452a1468c..0000000000 --- a/ext/simplexml/tests/014b.phpt +++ /dev/null @@ -1,56 +0,0 @@ ---TEST-- -SimpleXML: adding/removing attributes (second) ---SKIPIF-- -<?php if (!extension_loaded("simplexml")) print "skip"; ?> ---FILE-- -<?php -$xml =<<<EOF -<people> - <person name="Joe"></person> - <person name="Boe"></person> -</people> -EOF; - -$people = simplexml_load_string($xml); -var_dump($people->person[0]['name']); -var_dump($people->person[1]['age']); -$person = $people->person[1]; -$person['name'] = "XXX"; -var_dump($people->person[1]['name']); -$people->person[1]['age'] = 30; -var_dump($people->person[1]['age']); -echo "---Unset:---\n"; -unset($people->person[1]['age']); -echo "---Unset?---\n"; -var_dump($people->person[1]['age']); -var_dump(isset($people->person[1]['age'])); -echo "---Unsupported---\n"; -$people->person[1]['age'] += 5; -var_dump($people->person[1]['age']); -?> -===DONE=== ---EXPECTF-- -object(simplexml_element)#%d (1) { - [0]=> - string(3) "Joe" -} -NULL -object(simplexml_element)#%d (1) { - [0]=> - string(3) "XXX" -} -object(simplexml_element)#%d (1) { - [0]=> - string(2) "30" -} ----Unset:--- ----Unset?--- -NULL -bool(false) ----Unsupported--- -object(simplexml_element)#%d (1) { - [0]=> - string(2) "30" -} - -Fatal error: Unsupported operand types in %s014.php on line %d diff --git a/ext/simplexml/tests/015.phpt b/ext/simplexml/tests/015.phpt deleted file mode 100644 index 0865b69f61..0000000000 --- a/ext/simplexml/tests/015.phpt +++ /dev/null @@ -1,56 +0,0 @@ ---TEST-- -SimpleXML: accessing singular subnode as array ---SKIPIF-- -<?php if (!extension_loaded("simplexml")) print "skip"; ?> ---FILE-- -<?php -$xml =<<<EOF -<people> - <person name="Joe"></person> -</people> -EOF; - -$xml2 =<<<EOF -<people> - <person name="Joe"></person> - <person name="Boe"></person> -</people> -EOF; - -$people = simplexml_load_string($xml); -var_dump($people->person['name']); -var_dump($people->person[0]['name']); -//$people->person['name'] = "XXX"; -//var_dump($people->person['name']); -//var_dump($people->person[0]['name']); -//$people->person[0]['name'] = "YYY"; -//var_dump($people->person['name']); -//var_dump($people->person[0]['name']); -//unset($people->person[0]['name']); -//var_dump($people->person['name']); -//var_dump($people->person[0]['name']); -//var_dump(isset($people->person['name'])); -//var_dump(isset($people->person[0]['name'])); -$people = simplexml_load_string($xml2); -var_dump($people->person[0]['name']); -var_dump($people->person[1]['name']); -?> -===DONE=== ---EXPECTF-- -object(simplexml_element)#%d (1) { - [0]=> - string(3) "Joe" -} -object(simplexml_element)#%d (1) { - [0]=> - string(3) "Joe" -} -object(simplexml_element)#%d (1) { - [0]=> - string(3) "Joe" -} -object(simplexml_element)#%d (1) { - [0]=> - string(3) "Boe" -} -===DONE=== diff --git a/ext/simplexml/tests/016.phpt b/ext/simplexml/tests/016.phpt deleted file mode 100644 index 65870408ef..0000000000 --- a/ext/simplexml/tests/016.phpt +++ /dev/null @@ -1,57 +0,0 @@ ---TEST-- -SimpleXML: modifying attributes of singular subnode ---SKIPIF-- -<?php if (!extension_loaded("simplexml")) print "skip"; ?> ---FILE-- -<?php -$xml =<<<EOF -<people> - <person name="Joe"></person> -</people> -EOF; - -$people = simplexml_load_string($xml); -var_dump($people->person['name']); -$people->person['name'] = $people->person['name'] . 'Foo'; -var_dump($people->person['name']); -$people->person['name'] .= 'Bar'; -var_dump($people->person['name']); - -echo "---[0]---\n"; - -$people = simplexml_load_string($xml); -var_dump($people->person[0]['name']); -$people->person[0]['name'] = $people->person[0]['name'] . 'Foo'; -var_dump($people->person[0]['name']); -$people->person[0]['name'] .= 'Bar'; -var_dump($people->person[0]['name']); - -?> -===DONE=== ---EXPECTF-- -object(simplexml_element)#%d (1) { - [0]=> - string(3) "Joe" -} -object(simplexml_element)#%d (1) { - [0]=> - string(6) "JoeFoo" -} -object(simplexml_element)#%d (1) { - [0]=> - string(9) "JoeFooBar" -} ----[0]--- -object(simplexml_element)#%d (1) { - [0]=> - string(3) "Joe" -} -object(simplexml_element)#%d (1) { - [0]=> - string(6) "JoeFoo" -} -object(simplexml_element)#%d (1) { - [0]=> - string(9) "JoeFooBar" -} -===Done=== diff --git a/ext/simplexml/tests/017.phpt b/ext/simplexml/tests/017.phpt deleted file mode 100644 index 776b00c785..0000000000 --- a/ext/simplexml/tests/017.phpt +++ /dev/null @@ -1,86 +0,0 @@ ---TEST-- -SimpleXML: iteration through subnodes ---SKIPIF-- -<?php if (!extension_loaded("simplexml")) print "skip"; ?> ---FILE-- -<?php -$xml =<<<EOF -<people> - <person name="Joe"> - <child name="Ann" /> - <child name="Marray" /> - </person> - <person name="Boe"> - <child name="Joe" /> - <child name="Ann" /> - </person> -</people> -EOF; -$xml1 =<<<EOF -<people> - <person name="Joe"> - <child name="Ann" /> - </person> -</people> -EOF; - -function print_xml($xml) { - foreach($xml->children() as $person) { - echo "person: ".$person['name']."\n"; - foreach($person->children() as $child) { - echo " child: ".$child['name']."\n"; - } - } -} - -function print_xml2($xml) { - $persons = 2; - for ($i=0;$i<$persons;$i++) { - echo "person: ".$xml->person[$i]['name']."\n"; - $children = 2; - for ($j=0;$j<$children;$j++) { - echo " child: ".$xml->person[$i]->child[$j]['name']."\n"; - } - } -} - -echo "---11---\n"; -print_xml(simplexml_load_string($xml)); -echo "---12---\n"; -print_xml(simplexml_load_string($xml1)); -echo "---21---\n"; -print_xml2(simplexml_load_string($xml)); -echo "---22---\n"; -print_xml2(simplexml_load_string($xml1)); -?> -===DONE=== ---EXPECTF-- ----11--- -person: Joe - child: Ann - child: Marray -person: Boe - child: Joe - child: Ann ----12--- -person: Joe - child: Ann ----21--- -person: Joe - child: Ann - child: Marray -person: Boe - child: Joe - child: Ann ----22--- -person: Joe - child: Ann - child: -person: - -Notice: Trying to get property of non-object in %s017.php on line %d - child: - -Notice: Trying to get property of non-object in %s017.php on line %d - child: -===DONE=== diff --git a/ext/simplexml/tests/018.phpt b/ext/simplexml/tests/018.phpt deleted file mode 100644 index e5c810944e..0000000000 --- a/ext/simplexml/tests/018.phpt +++ /dev/null @@ -1,65 +0,0 @@ ---TEST-- -SimpleXML: iteration through subnodes and attributes ---SKIPIF-- -<?php if (!extension_loaded("simplexml")) print "skip"; ?> ---FILE-- -<?php -$xml =<<<EOF -<people> - <person name="Joe"> - Text1 - <child name="Ann" /> - Text2 - <child name="Marray" /> - Text3 - </person> - <person name="Boe"> - <child name="Joe" /> - <child name="Ann" /> - </person> -</people> -EOF; -$xml1 =<<<EOF -<people> - <person name="Joe"> - <child /> - </person> -</people> -EOF; - -function traverse_xml($pad,$xml) { - foreach($xml->children() as $name => $node) { - echo $pad."<$name"; - foreach($node->attributes() as $attr => $value) { - echo " $attr=\"$value\""; - } - echo ">\n"; - traverse_xml($pad." ",$node); - echo $pad."</$name>\n"; - } -} - -traverse_xml("",simplexml_load_string($xml)); -echo "----------\n"; -traverse_xml("",simplexml_load_string($xml1)); -echo "---Done---\n"; -?> ---EXPECT-- -<person name="Joe"> - <child name="Ann"> - </child> - <child name="Marray"> - </child> -</person> -<person name="Boe"> - <child name="Joe"> - </child> - <child name="Ann"> - </child> -</person> ----------- -<person name="Joe"> - <child> - </child> -</person> ----Done---
\ No newline at end of file diff --git a/ext/simplexml/tests/019.phpt b/ext/simplexml/tests/019.phpt deleted file mode 100755 index 09f0569d7a..0000000000 --- a/ext/simplexml/tests/019.phpt +++ /dev/null @@ -1,80 +0,0 @@ ---TEST-- -SimpleXML and foreach with children() ---SKIPIF-- -<?php if (!extension_loaded("simplexml")) print "skip"; ?> ---FILE-- -<?php - -$sxe = simplexml_load_string(<<<EOF -<?xml version='1.0'?> -<!DOCTYPE sxe SYSTEM "notfound.dtd"> -<sxe id="elem1"> - Plain text. - <elem1 attr1='first'> - Bla bla 1. - <!-- comment --> - <elem2> - Here we have some text data. - <elem3> - And here some more. - <elem4> - Wow once again. - </elem4> - </elem3> - </elem2> - </elem1> - <elem11 attr2='second'> - Bla bla 2. - <elem111> - Foo Bar - </elem111> - </elem11> -</sxe> -EOF -); - -foreach($sxe->children() as $name => $data) { - var_dump($name); - var_dump(trim($data)); -} - -echo "===CLONE===\n"; - -foreach($sxe->children()->__clone() as $name => $data) { - var_dump($name); - var_dump(trim($data)); -} - -echo "===ELEMENT===\n"; - -foreach($sxe->elem11->children() as $name => $data) { - var_dump($name); - var_dump(trim($data)); -} - -echo "===COMMENT===\n"; - -foreach($sxe->elem1->children() as $name => $data) { - var_dump($name); - var_dump(trim($data)); -} - -?> -===DONE=== ---EXPECT-- -string(5) "elem1" -string(10) "Bla bla 1." -string(6) "elem11" -string(10) "Bla bla 2." -===CLONE=== -string(5) "elem1" -string(10) "Bla bla 1." -string(6) "elem11" -string(10) "Bla bla 2." -===ELEMENT=== -string(7) "elem111" -string(7) "Foo Bar" -===COMMENT=== -string(5) "elem2" -string(28) "Here we have some text data." -===DONE=== diff --git a/ext/simplexml/tests/book.xml b/ext/simplexml/tests/book.xml deleted file mode 100644 index ea40508e01..0000000000 --- a/ext/simplexml/tests/book.xml +++ /dev/null @@ -1,10 +0,0 @@ -<books> - <book> - <title>The Grapes of Wrath</title> - <author>John Steinbeck</author> - </book> - <book> - <title>The Pearl</title> - <author>John Steinbeck</author> - </book> -</books> diff --git a/ext/simplexml/tests/bug24392.phpt b/ext/simplexml/tests/bug24392.phpt deleted file mode 100644 index 0a462e5770..0000000000 --- a/ext/simplexml/tests/bug24392.phpt +++ /dev/null @@ -1,22 +0,0 @@ ---TEST-- -Bug #24392 (empty namespaces causing confusion) ---SKIPIF-- -<?php if (!extension_loaded("simplexml")) print "skip simplexml extension is not loaded"; ?> ---FILE-- -<?php -$s = simplexml_load_file(dirname(__FILE__).'/bug24392.xml'); -foreach ($s->item as $item) { - echo $item->title . "\n"; -} -?> ---EXPECT-- -EU Parliament to Vote on New Patent Rules -Most Powerful Amateur Rocket in Canada -GF FX 5900 Ultra vs. ATi Radeon 9800 Pro -PHP 5 Beta 1 -Engaging with the OSS Community -Pure Math, Pure Joy -Windows Tech Writer Looks at Linux -US Cell Phone Users Discover SMS Spam -Verizon Sues Nextel For Espionage -Introduction to Debian diff --git a/ext/simplexml/tests/bug24392.xml b/ext/simplexml/tests/bug24392.xml deleted file mode 100644 index d669f1df41..0000000000 --- a/ext/simplexml/tests/bug24392.xml +++ /dev/null @@ -1,76 +0,0 @@ -<?xml version="1.0"?> - -<rdf:RDF -xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" -xmlns="http://my.netscape.com/rdf/simple/0.9/"> - -<channel> -<title>Slashdot</title> -<link>http://slashdot.org/</link> -<description>News for nerds, stuff that matters</description> -</channel> - -<image> -<title>Slashdot</title> -<url>http://images.slashdot.org/topics/topicslashdot.gif</url> -<link>http://slashdot.org/</link> -</image> - -<item> -<title>EU Parliament to Vote on New Patent Rules</title> -<link>http://slashdot.org/article.pl?sid=03/06/30/002211</link> -</item> - -<item> -<title>Most Powerful Amateur Rocket in Canada</title> -<link>http://slashdot.org/article.pl?sid=03/06/29/2121211</link> -</item> - -<item> -<title>GF FX 5900 Ultra vs. ATi Radeon 9800 Pro</title> -<link>http://slashdot.org/article.pl?sid=03/06/29/202218</link> -</item> - -<item> -<title>PHP 5 Beta 1</title> -<link>http://slashdot.org/article.pl?sid=03/06/29/1957253</link> -</item> - -<item> -<title>Engaging with the OSS Community</title> -<link>http://slashdot.org/article.pl?sid=03/06/29/1913235</link> -</item> - -<item> -<title>Pure Math, Pure Joy</title> -<link>http://slashdot.org/article.pl?sid=03/06/29/183258</link> -</item> - -<item> -<title>Windows Tech Writer Looks at Linux</title> -<link>http://slashdot.org/article.pl?sid=03/06/29/1554201</link> -</item> - -<item> -<title>US Cell Phone Users Discover SMS Spam</title> -<link>http://slashdot.org/article.pl?sid=03/06/29/1542249</link> -</item> - -<item> -<title>Verizon Sues Nextel For Espionage</title> -<link>http://slashdot.org/article.pl?sid=03/06/29/1443230</link> -</item> - -<item> -<title>Introduction to Debian</title> -<link>http://slashdot.org/article.pl?sid=03/06/29/1424213</link> -</item> - -<textinput> -<title>Search Slashdot</title> -<description>Search Slashdot stories</description> -<name>query</name> -<link>http://slashdot.org/search.pl</link> -</textinput> - -</rdf:RDF>
\ No newline at end of file diff --git a/ext/simplexml/tests/bug25756.xsd b/ext/simplexml/tests/bug25756.xsd deleted file mode 100644 index 427b7a1a14..0000000000 --- a/ext/simplexml/tests/bug25756.xsd +++ /dev/null @@ -1,24 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" ?> -<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"> - <xsd:element name="foo" type="foo-type" /> - <xsd:complexType name="item-type"> - <xsd:all> - <xsd:element name="product-name" type="xsd:string" - minOccurs="1" maxOccurs="1"/> - <xsd:element name="quantity" type="xsd:decimal" - minOccurs="1" maxOccurs="1"/> - </xsd:all> - </xsd:complexType> - <xsd:complexType name="foo-type"> - <xsd:sequence> - <xsd:element name="items" minoccurs="1" maxOccurs="1"> - <xsd:complexType> - <xsd:sequence> - <xsd:element name="item" type="item-type" - minOccurs="0" maxOccurs="unbounded" /> - </xsd:sequence> - </xsd:complexType> - </xsd:element> - </xsd:sequence> - </xsd:complexType> -</xsd:schema> diff --git a/ext/simplexml/tests/bug25756_1.xml b/ext/simplexml/tests/bug25756_1.xml deleted file mode 100644 index 33ab30be10..0000000000 --- a/ext/simplexml/tests/bug25756_1.xml +++ /dev/null @@ -1,13 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" ?> -<foo> - <items> - <item> - <product-name>abc</product-name> - <quantity>123</quantity> - </item> - <item> - <product-name>def</product-name> - <quantity>456</quantity> - </item> - </items> -</foo> diff --git a/ext/simplexml/tests/bug25756_2.xml b/ext/simplexml/tests/bug25756_2.xml deleted file mode 100644 index 53037ef769..0000000000 --- a/ext/simplexml/tests/bug25756_2.xml +++ /dev/null @@ -1,13 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" ?> -<foo> - <items> - <item> - <product-name>abc</product-name> - <quantity>abc</quantity> - </item> - <item> - <product-name>abc</product-name> - <quantity>123</quantity> - </item> - </items> -</foo> diff --git a/ext/simplexml/tests/bug26976.phpt b/ext/simplexml/tests/bug26976.phpt deleted file mode 100644 index 657c229737..0000000000 --- a/ext/simplexml/tests/bug26976.phpt +++ /dev/null @@ -1,28 +0,0 @@ ---TEST-- -Bug #26976 (Can not access array elements using array indices) ---SKIPIF-- -<?php if (!extension_loaded("simplexml")) print "skip simplexml extension is not loaded"; ?> ---FILE-- -<?php - -$root = simplexml_load_string( -'<?xml version="1.0"?> -<root> - <child>a</child> - <child>b</child> - <child>c</child> - <child>d</child> -</root> -'); - -echo $root->child[0], "\n"; -echo $root->child[1], "\n"; -echo $root->child[2], "\n"; -echo $root->child[3], "\n"; - -?> ---EXPECT-- -a -b -c -d diff --git a/ext/simplexml/tests/bug27010.phpt b/ext/simplexml/tests/bug27010.phpt deleted file mode 100755 index dffb7476b6..0000000000 --- a/ext/simplexml/tests/bug27010.phpt +++ /dev/null @@ -1,31 +0,0 @@ ---TEST-- -#27010: segfault and node text not displayed when returned from children() ---FILE-- -<?php - -$xml=<<<EOF -<drinks xmlns:hot="http://www.example.com/hot"> - <hot:drink><hot:name>Coffee</hot:name></hot:drink> - <hot:drink><hot:name>Tea</hot:name></hot:drink> - <drink><name>Cola</name></drink> - <drink><name>Juice</name></drink> -</drinks> -EOF; - -$sxe = simplexml_load_string($xml); - -foreach ($sxe as $element_name => $element) { - print "$element_name is $element->name\n"; -} - -foreach ($sxe->children('http://www.example.com/hot') as $element_name => $element) { - print "$element_name is $element->name\n"; -} -?> -===DONE=== ---EXPECT-- -drink is Cola -drink is Juice -drink is Coffee -drink is Tea -===DONE=== diff --git a/ext/simplexml/tests/profile01.phpt b/ext/simplexml/tests/profile01.phpt deleted file mode 100644 index 91b9544f66..0000000000 --- a/ext/simplexml/tests/profile01.phpt +++ /dev/null @@ -1,18 +0,0 @@ ---TEST-- -SimpleXML [profile]: Accessing a simple node ---SKIPIF-- -<?php if (!extension_loaded("simplexml")) print "skip"; ?> ---FILE-- -<?php -$root = simplexml_load_string('<?xml version="1.0"?> -<root> - <child>Hello</child> -</root> -'); - -echo $root->child; -echo "\n---Done---\n"; -?> ---EXPECT-- -Hello ----Done--- diff --git a/ext/simplexml/tests/profile02.phpt b/ext/simplexml/tests/profile02.phpt deleted file mode 100644 index 14b5bb86b2..0000000000 --- a/ext/simplexml/tests/profile02.phpt +++ /dev/null @@ -1,21 +0,0 @@ ---TEST-- -SimpleXML [profile]: Accessing an array of subnodes ---SKIPIF-- -<?php if (!extension_loaded("simplexml")) print "skip"; ?> ---FILE-- -<?php -$root = simplexml_load_string('<?xml version="1.0"?> -<root> - <child>Hello</child> - <child>World</child> -</root> -'); - -foreach ($root->child as $child) { - echo "$child "; -} -echo "\n---Done---\n"; -?> ---EXPECT-- -Hello World ----Done--- diff --git a/ext/simplexml/tests/profile03.phpt b/ext/simplexml/tests/profile03.phpt deleted file mode 100644 index 14f1c5fe88..0000000000 --- a/ext/simplexml/tests/profile03.phpt +++ /dev/null @@ -1,18 +0,0 @@ ---TEST-- -SimpleXML [profile]: Accessing an attribute ---SKIPIF-- -<?php if (!extension_loaded("simplexml")) print "skip"; ?> ---FILE-- -<?php -$root = simplexml_load_string('<?xml version="1.0"?> -<root> - <child attribute="Sample" /> -</root> -'); - -echo $root->child['attribute']; -echo "\n---Done---\n"; -?> ---EXPECT-- -Sample ----Done--- diff --git a/ext/simplexml/tests/profile04.phpt b/ext/simplexml/tests/profile04.phpt deleted file mode 100644 index 27714e9927..0000000000 --- a/ext/simplexml/tests/profile04.phpt +++ /dev/null @@ -1,18 +0,0 @@ ---TEST-- -SimpleXML [profile]: Accessing a namespaced element ---SKIPIF-- -<?php if (!extension_loaded("simplexml")) print "skip"; ?> ---FILE-- -<?php -$root = simplexml_load_string('<?xml version="1.0"?> -<root xmlns:reserved="reserved-ns"> - <reserved:child>Hello</reserved:child> -</root> -'); - -echo $root->children('reserved-ns')->child; -echo "\n---Done---\n"; -?> ---EXPECT-- -Hello ----Done--- diff --git a/ext/simplexml/tests/profile05.phpt b/ext/simplexml/tests/profile05.phpt deleted file mode 100644 index f69622118a..0000000000 --- a/ext/simplexml/tests/profile05.phpt +++ /dev/null @@ -1,18 +0,0 @@ ---TEST-- -SimpleXML [profile]: Accessing an aliased namespaced element ---SKIPIF-- -<?php if (!extension_loaded("simplexml")) print "skip"; ?> ---FILE-- -<?php -error_reporting(E_ALL & ~E_NOTICE); -$root = simplexml_load_string('<?xml version="1.0"?> -<root xmlns:reserved="reserved-ns"> - <reserved:child>Hello</reserved:child> -</root> -'); - -echo $root->children('reserved')->child; -echo "\n---Done---\n"; -?> ---EXPECT-- ----Done--- diff --git a/ext/simplexml/tests/profile06.phpt b/ext/simplexml/tests/profile06.phpt deleted file mode 100644 index e519fa9d64..0000000000 --- a/ext/simplexml/tests/profile06.phpt +++ /dev/null @@ -1,20 +0,0 @@ ---TEST-- -SimpleXML [profile]: Accessing a namespaced attribute ---SKIPIF-- -<?php if (!extension_loaded("simplexml")) print "skip"; ?> ---FILE-- -<?php -error_reporting(E_ALL & ~E_NOTICE); -$root = simplexml_load_string('<?xml version="1.0"?> -<root xmlns:reserved="reserved-ns"> - <child reserved:attribute="Sample" /> -</root> -'); - -$attr = $root->child->attributes('reserved-ns'); -echo $attr['attribute']; -echo "\n---Done---\n"; -?> ---EXPECT-- -Sample ----Done--- diff --git a/ext/simplexml/tests/profile07.phpt b/ext/simplexml/tests/profile07.phpt deleted file mode 100644 index c8a4269274..0000000000 --- a/ext/simplexml/tests/profile07.phpt +++ /dev/null @@ -1,23 +0,0 @@ ---TEST-- -SimpleXML [profile]: Accessing an aliased namespaced attribute ---SKIPIF-- -<?php if (!extension_loaded("simplexml")) print "skip"; ?> ---FILE-- -<?php -error_reporting(E_ALL & ~E_NOTICE); -$root = simplexml_load_string('<?xml version="1.0"?> -<root xmlns:reserved="reserved-ns"> - <child reserved:attribute="Sample" /> -</root> -'); - -$rsattr = $root->child->attributes('reserved'); -$myattr = $root->child->attributes('reserved-ns'); - -echo $rsattr['attribute']; -echo $myattr['attribute']; -echo "\n---Done---\n"; -?> ---EXPECT-- -Sample ----Done--- diff --git a/ext/simplexml/tests/profile08.phpt b/ext/simplexml/tests/profile08.phpt deleted file mode 100644 index bbb69b75a8..0000000000 --- a/ext/simplexml/tests/profile08.phpt +++ /dev/null @@ -1,18 +0,0 @@ ---TEST-- -SimpleXML [profile]: Accessing a namespaced attribute without a namespace ---SKIPIF-- -<?php if (!extension_loaded("simplexml")) print "skip"; ?> ---FILE-- -<?php -error_reporting(E_ALL & ~E_NOTICE); -$root = simplexml_load_string('<?xml version="1.0"?> -<root xmlns:reserved="reserved-ns"> - <child reserved:attribute="Sample" /> -</root> -'); - -echo $root->child['attribute']; -echo "\n---Done---\n"; -?> ---EXPECT-- ----Done--- diff --git a/ext/simplexml/tests/profile09.phpt b/ext/simplexml/tests/profile09.phpt deleted file mode 100644 index 714572df1e..0000000000 --- a/ext/simplexml/tests/profile09.phpt +++ /dev/null @@ -1,19 +0,0 @@ ---TEST-- -SimpleXML [profile]: Accessing a namespaced element without a namespace ---SKIPIF-- -<?php if (!extension_loaded("simplexml")) print "skip"; ?> ---FILE-- -<?php -error_reporting(E_ALL & ~E_NOTICE); -$root = simplexml_load_string('<?xml version="1.0"?> -<root xmlns:reserved="reserved-ns"> - <reserved:child>Hello</reserved:child> -</root> -'); - -echo $root->child; -echo "\n---Done---\n"; -?> ---EXPECT-- - ----Done--- diff --git a/ext/simplexml/tests/profile10.phpt b/ext/simplexml/tests/profile10.phpt deleted file mode 100644 index 6ef7456c51..0000000000 --- a/ext/simplexml/tests/profile10.phpt +++ /dev/null @@ -1,25 +0,0 @@ ---TEST-- -SimpleXML [profile]: Accessing two attributes with the same name, but different namespaces ---SKIPIF-- -<?php if (!extension_loaded("simplexml")) print "skip"; ?> ---FILE-- -<?php -error_reporting(E_ALL & ~E_NOTICE); -$root = simplexml_load_string('<?xml version="1.0"?> -<root xmlns:reserved="reserved-ns" xmlns:special="special-ns"> - <child reserved:attribute="Sample" special:attribute="Test" /> -</root> -'); - -$rsattr = $root->child->attributes('reserved-ns'); -$spattr = $root->child->attributes('special-ns'); - -echo $rsattr['attribute']; -echo "\n"; -echo $spattr['attribute']; -echo "\n---Done---\n"; -?> ---EXPECT-- -Sample -Test ----Done--- diff --git a/ext/simplexml/tests/profile11.phpt b/ext/simplexml/tests/profile11.phpt deleted file mode 100644 index e68e6bd510..0000000000 --- a/ext/simplexml/tests/profile11.phpt +++ /dev/null @@ -1,26 +0,0 @@ ---TEST-- -SimpleXML [profile]: Accessing two elements with the same name, but different namespaces ---SKIPIF-- -<?php if (!extension_loaded("simplexml")) print "skip"; ?> ---FILE-- -<?php -error_reporting(E_ALL & ~E_NOTICE); -$root = simplexml_load_string('<?xml version="1.0"?> -<root xmlns:reserved="reserved-ns" xmlns:special="special-ns"> - <reserved:child>Hello</reserved:child> - <special:child>World</special:child> -</root> -'); - -echo $root->children('reserved-ns')->child; -echo "\n"; -echo $root->children('special-ns')->child; -foreach ($root->child as $child) { - echo "$child\n"; -} -echo "\n---Done---\n"; -?> ---EXPECT-- -Hello -World ----Done--- diff --git a/ext/simplexml/tests/simplexml_import_dom.phpt b/ext/simplexml/tests/simplexml_import_dom.phpt deleted file mode 100755 index c66ba8f087..0000000000 --- a/ext/simplexml/tests/simplexml_import_dom.phpt +++ /dev/null @@ -1,22 +0,0 @@ ---TEST-- -Interop: simplexml_import_dom ---SKIPIF-- -<?php if (!extension_loaded("simplexml")) print "skip"; ?> -<?php if (!extension_loaded("dom")) print "skip. dom extension not loaded"; ?> ---FILE-- -<?php -$dom = new domDocument; -$dom->load(dirname(__FILE__)."/book.xml"); -if(!$dom) { - echo "Error while parsing the document\n"; - exit; -} -$s = simplexml_import_dom($dom); -$books = $s->book; -foreach ($books as $book) { - echo "{$book->title} was written by {$book->author}\n"; -} -?> ---EXPECT-- -The Grapes of Wrath was written by John Steinbeck -The Pearl was written by John Steinbeck diff --git a/ext/simplexml/tests/sxe.dtd b/ext/simplexml/tests/sxe.dtd deleted file mode 100755 index 8a8dde4308..0000000000 --- a/ext/simplexml/tests/sxe.dtd +++ /dev/null @@ -1,21 +0,0 @@ -<?xml encoding='US-ASCII'?>
-
-<!ELEMENT sxe elem1, elem 11>
-<!ATTLIST sxe id CDATA #implied>
-
-<!ELEMENT elem1 elem2>
-<!ATTLIST elem1 attr1 CDATA #required
- attr2 CDATA "default>
-
-<!ELEMENT elem2 elem3>
-<!ATTLIST elem2>
-
-<!ELEMENT elem3 elem4>
-<!ATTLIST elem3>
-
-<!ELEMENT elem4 EMPTY>
-<!ATTLIST elem4>
-
-<!ELEMENT elem11 EMPTY>
-<!ATTLIST elem11>
-
diff --git a/ext/simplexml/tests/sxe.ent b/ext/simplexml/tests/sxe.ent deleted file mode 100755 index 8f86465c2a..0000000000 --- a/ext/simplexml/tests/sxe.ent +++ /dev/null @@ -1 +0,0 @@ -<!ENTITY included-entity "This is text included from an entity"> diff --git a/ext/simplexml/tests/sxe.xml b/ext/simplexml/tests/sxe.xml deleted file mode 100755 index 909b4e652c..0000000000 --- a/ext/simplexml/tests/sxe.xml +++ /dev/null @@ -1,17 +0,0 @@ -<?xml version='1.0'?> -<!DOCTYPE sxe SYSTEM "notfound.dtd" [ -<!ENTITY % incent SYSTEM "sxe.ent"> -%incent; -]> -<sxe id="elem1"> - <elem1 attr1='first'> - <!-- comment --> - <elem2> - <elem3> - <elem4> - <?test processing instruction ?> - </elem4> - </elem3> - </elem2> - </elem1> -</sxe>
\ No newline at end of file |