helly Sat Oct 29 12:12:57 2005 EDT
Added files:
/php-src/ext/simplexml/tests 000.phpt 000.xml
Modified files:
/php-src/ext/simplexml simplexml.c
/php-src/ext/simplexml/tests 001.phpt 002.phpt 003.phpt 004.phpt
005.phpt 006.phpt 007.phpt 008.phpt
009.phpt 010.phpt 011.phpt 012.phpt
013.phpt 019.phpt 020.phpt 021.phpt
022.phpt 023.phpt bug27010.phpt
profile11.phpt
simplexml_import_dom.phpt sxe.dtd
Log:
- Change var_dump to include all that is reachable, incl. @attributes
- Adapt tests and add new one
http://cvs.php.net/diff.php/php-src/ext/simplexml/simplexml.c?r1=1.164&r2=1.165&ty=u
Index: php-src/ext/simplexml/simplexml.c
diff -u php-src/ext/simplexml/simplexml.c:1.164
php-src/ext/simplexml/simplexml.c:1.165
--- php-src/ext/simplexml/simplexml.c:1.164 Sun Oct 23 19:41:18 2005
+++ php-src/ext/simplexml/simplexml.c Sat Oct 29 12:12:55 2005
@@ -18,7 +18,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: simplexml.c,v 1.164 2005/10/23 23:41:18 helly Exp $ */
+/* $Id: simplexml.c,v 1.165 2005/10/29 16:12:55 helly Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -38,6 +38,8 @@
#include "ext/spl/spl_sxe.h"
#endif
+#define SXE_ELEMENT_BY_NAME 0
+
zend_class_entry *sxe_class_entry = NULL;
ZEND_API zend_class_entry *sxe_get_element_class_entry(TSRMLS_D)
@@ -112,10 +114,7 @@
}
}
-/* {{{ match_ns()
- */
-static inline int
-match_ns(php_sxe_object *sxe, xmlNodePtr node, xmlChar *name)
+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;
@@ -129,9 +128,8 @@
}
/* }}} */
-/* {{{ sxe_get_element_node()
- */
-static xmlNodePtr sxe_get_element_by_offset(php_sxe_object *sxe, long offset,
xmlNodePtr 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) {
@@ -156,6 +154,71 @@
}
/* }}} */
+#if SXE_ELEMENT_BY_NAME
+static xmlNodePtr sxe_find_element_by_name(php_sxe_object *sxe, xmlNodePtr
node, char *name TSRMLS_DC) /* {{{ */
+{
+ while (node) {
+ SKIP_TEXT(node)
+ if (node->type == XML_ELEMENT_NODE && match_ns(sxe, node,
sxe->iter.nsprefix)) {
+ if (!xmlStrcmp(node->name, name)) {
+ return node;
+ }
+ }
+next_iter:
+ node = node->next;
+ }
+ return NULL;
+} /* }}} */
+
+static xmlNodePtr sxe_get_element_by_name(php_sxe_object *sxe, xmlNodePtr
node, char **name, int *type TSRMLS_DC) /* {{{ */
+{
+ int orgtype;
+ xmlNodePtr orgnode = node;
+ xmlNodePtr retnode = NULL;
+
+ if (sxe->iter.type != SXE_ITER_ATTRLIST)
+ {
+ orgtype = sxe->iter.type;
+ if (sxe->iter.type == SXE_ITER_NONE) {
+ sxe->iter.type = SXE_ITER_CHILD;
+ }
+ node = php_sxe_get_first_node(sxe, node TSRMLS_CC);
+ sxe->iter.type = orgtype;
+ }
+
+ if (sxe->iter.type == SXE_ITER_ELEMENT) {
+ orgnode = sxe_find_element_by_name(sxe, node, sxe->iter.name
TSRMLS_CC);
+ node = orgnode->children;
+ }
+
+ while (node) {
+ SKIP_TEXT(node)
+ if (node->type == XML_ELEMENT_NODE && match_ns(sxe, node,
sxe->iter.nsprefix)) {
+ if (!xmlStrcmp(node->name, *name)) {
+ if (1||retnode)
+ {
+ *type = SXE_ITER_ELEMENT;
+ return orgnode;
+ }
+ retnode = node;
+ }
+ }
+next_iter:
+ node = node->next;
+ }
+
+ if (retnode)
+ {
+ *type = SXE_ITER_NONE;
+ *name = NULL;
+ return retnode;
+ }
+
+ return NULL;
+}
+/* }}} */
+#endif /* SXE_ELEMENT_BY_NAME */
+
/* {{{ 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)
@@ -166,7 +229,7 @@
xmlNodePtr node;
xmlAttrPtr attr;
zval tmp_zv;
- int nodendx = 0;
+ int nodendx = 0;
sxe = php_sxe_fetch_object(object TSRMLS_CC);
@@ -175,6 +238,7 @@
attribs = 0;
elements = 1;
}
+ name = NULL;
} else {
if (Z_TYPE_P(member) != IS_STRING) {
tmp_zv = *member;
@@ -182,24 +246,23 @@
member = &tmp_zv;
convert_to_string(member);
}
+ name = Z_STRVAL_P(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) {
+ if (sxe->iter.type == SXE_ITER_ATTRLIST) {
+ attribs = 1;
+ elements = 0;
+ } else 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 {
+ if (Z_TYPE_P(member) != IS_LONG || sxe->iter.type ==
SXE_ITER_ATTRLIST) {
attr = node->properties;
if (Z_TYPE_P(member) == IS_LONG) {
while (attr && nodendx <=
Z_LVAL_P(member)) {
@@ -237,7 +300,17 @@
_node_as_zval(sxe, node, return_value,
SXE_ITER_NONE, NULL, sxe->iter.nsprefix TSRMLS_CC);
}
} else {
+#if SXE_ELEMENT_BY_NAME
+ int newtype;
+
+ GET_NODE(sxe, node);
+ node = sxe_get_element_by_name(sxe, node,
&name, &newtype TSRMLS_CC);
+ if (node) {
+ _node_as_zval(sxe, node, return_value,
newtype, name, sxe->iter.nsprefix TSRMLS_CC);
+ }
+#else
_node_as_zval(sxe, node, return_value,
SXE_ITER_ELEMENT, name, sxe->iter.nsprefix TSRMLS_CC);
+#endif
}
}
}
@@ -671,19 +744,41 @@
}
/* }}} */
+static void sxe_properties_add(HashTable *rv, char *name, int namelen, zval
*value TSRMLS_DC)
+{
+ zval **data_ptr;
+ zval *newptr;
+ ulong 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);
+ }
+}
+
/* {{{ sxe_properties_get()
*/
-static HashTable *
-sxe_properties_get(zval *object TSRMLS_DC)
+static HashTable * sxe_properties_get(zval *object TSRMLS_DC)
{
- zval **data_ptr;
zval *value;
- zval *newptr;
+ zval *zattr;
HashTable *rv;
php_sxe_object *sxe;
char *name;
xmlNodePtr node;
- ulong h;
+ xmlAttrPtr attr;
int namelen;
sxe = php_sxe_fetch_object(object TSRMLS_CC);
@@ -698,9 +793,31 @@
}
GET_NODE(sxe, node);
- node = php_sxe_get_first_node(sxe, node TSRMLS_CC);
+ if (1||sxe->iter.type != SXE_ITER_CHILD) {
+ if (sxe->iter.type == SXE_ITER_ELEMENT) {
+ node = php_sxe_get_first_node(sxe, node TSRMLS_CC);
+ }
+ attr = node ? (xmlAttrPtr)node->properties : NULL;
+ zattr = NULL;
+ while (attr) {
+ if (match_ns(sxe, (xmlNodePtr)attr,
sxe->iter.nsprefix)) {
+ MAKE_STD_ZVAL(value);
+ ZVAL_STRING(value,
xmlNodeListGetString((xmlDocPtr) sxe->document->ptr, attr->children, 1), 1);
+ namelen = xmlStrlen(attr->name) + 1;
+ if (!zattr) {
+ MAKE_STD_ZVAL(zattr);
+ array_init(zattr);
+ sxe_properties_add(rv, "@attributes",
sizeof("@attributes"), zattr TSRMLS_CC);
+ }
+ add_assoc_zval_ex(zattr, (char*)attr->name,
namelen, value);
+ }
+ attr = attr->next;
+ }
+ }
- if (node) {
+ GET_NODE(sxe, node);
+ node = php_sxe_get_first_node(sxe, node TSRMLS_CC);
+ if (node && sxe->iter.type != SXE_ITER_ATTRLIST) {
if (node->type == XML_ATTRIBUTE_NODE) {
MAKE_STD_ZVAL(value);
ZVAL_U_STRING(ZEND_U_CONVERTER(UG(runtime_encoding_conv)), value,
xmlNodeListGetString(node->doc, node->children, 1), 1);
@@ -735,24 +852,7 @@
_get_base_node_value(sxe, node, &value,
sxe->iter.nsprefix 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);
- }
-
+ sxe_properties_add(rv, name, namelen, value TSRMLS_CC);
next_iter:
node = node->next;
}
@@ -1007,8 +1107,7 @@
/* {{{ cast_object()
*/
-static int
-cast_object(zval *object, int type, char *contents TSRMLS_DC)
+static int cast_object(zval *object, int type, char *contents TSRMLS_DC)
{
if (contents) {
ZVAL_STRINGL(object, contents, strlen(contents), 1);
@@ -1046,8 +1145,7 @@
/* {{{ sxe_object_cast()
*/
-static int
-sxe_object_cast(zval *readobj, zval *writeobj, int type TSRMLS_DC)
+static int sxe_object_cast(zval *readobj, zval *writeobj, int type TSRMLS_DC)
{
php_sxe_object *sxe;
char *contents = NULL;
@@ -1764,7 +1862,7 @@
{
php_info_print_table_start();
php_info_print_table_header(2, "Simplexml support", "enabled");
- php_info_print_table_row(2, "Revision", "$Revision: 1.164 $");
+ php_info_print_table_row(2, "Revision", "$Revision: 1.165 $");
php_info_print_table_row(2, "Schema support",
#ifdef LIBXML_SCHEMAS_ENABLED
"enabled");
http://cvs.php.net/diff.php/php-src/ext/simplexml/tests/001.phpt?r1=1.4&r2=1.5&ty=u
Index: php-src/ext/simplexml/tests/001.phpt
diff -u php-src/ext/simplexml/tests/001.phpt:1.4
php-src/ext/simplexml/tests/001.phpt:1.5
--- php-src/ext/simplexml/tests/001.phpt:1.4 Mon Mar 29 14:58:01 2004
+++ php-src/ext/simplexml/tests/001.phpt Sat Oct 29 12:12:57 2005
@@ -5,39 +5,39 @@
--FILE--
<?php
-$sxe = simplexml_load_file(dirname(__FILE__).'/sxe.xml');
-
-print_r($sxe);
-
-echo "---Done---\n";
+var_dump(simplexml_load_file(dirname(__FILE__).'/sxe.xml'));
?>
---EXPECT--
-SimpleXMLElement Object
-(
- [elem1] => SimpleXMLElement Object
- (
- [comment] => SimpleXMLElement Object
- (
- )
-
- [elem2] => SimpleXMLElement Object
- (
- [elem3] => SimpleXMLElement Object
- (
- [elem4] => SimpleXMLElement Object
- (
- [test] => SimpleXMLElement Object
- (
- )
-
- )
-
- )
-
- )
-
- )
-
-)
----Done---
+===DONE===
+--EXPECTF--
+object(SimpleXMLElement)#%d (2) {
+ ["@attributes"]=>
+ array(1) {
+ ["id"]=>
+ string(5) "elem1"
+ }
+ ["elem1"]=>
+ object(SimpleXMLElement)#%d (3) {
+ ["@attributes"]=>
+ array(1) {
+ ["attr1"]=>
+ string(5) "first"
+ }
+ ["comment"]=>
+ object(SimpleXMLElement)#%d (0) {
+ }
+ ["elem2"]=>
+ object(SimpleXMLElement)#%d (1) {
+ ["elem3"]=>
+ object(SimpleXMLElement)#%d (1) {
+ ["elem4"]=>
+ object(SimpleXMLElement)#%d (1) {
+ ["test"]=>
+ object(SimpleXMLElement)#%d (0) {
+ }
+ }
+ }
+ }
+ }
+}
+===DONE===
http://cvs.php.net/diff.php/php-src/ext/simplexml/tests/002.phpt?r1=1.8&r2=1.9&ty=u
Index: php-src/ext/simplexml/tests/002.phpt
diff -u php-src/ext/simplexml/tests/002.phpt:1.8
php-src/ext/simplexml/tests/002.phpt:1.9
--- php-src/ext/simplexml/tests/002.phpt:1.8 Mon Mar 29 14:58:01 2004
+++ php-src/ext/simplexml/tests/002.phpt Sat Oct 29 12:12:57 2005
@@ -1,5 +1,5 @@
--TEST--
-SimpleXML and clone
+SimpleXML: clone
--SKIPIF--
<?php if (!extension_loaded("simplexml")) print "skip"; ?>
--FILE--
@@ -26,37 +26,39 @@
$copy = clone $sxe;
-print_r($copy);
-
-echo "---Done---\n";
+var_dump($copy);
?>
---EXPECT--
-SimpleXMLElement Object
-(
- [elem1] => SimpleXMLElement Object
- (
- [comment] => SimpleXMLElement Object
- (
- )
-
- [elem2] => SimpleXMLElement Object
- (
- [elem3] => SimpleXMLElement Object
- (
- [elem4] => SimpleXMLElement Object
- (
- [test] => SimpleXMLElement Object
- (
- )
-
- )
-
- )
-
- )
-
- )
-
-)
----Done---
+===DONE===
+--EXPECTF--
+object(SimpleXMLElement)#%d (2) {
+ ["@attributes"]=>
+ array(1) {
+ ["id"]=>
+ string(5) "elem1"
+ }
+ ["elem1"]=>
+ object(SimpleXMLElement)#%d (3) {
+ ["@attributes"]=>
+ array(1) {
+ ["attr1"]=>
+ string(5) "first"
+ }
+ ["comment"]=>
+ object(SimpleXMLElement)#%d (0) {
+ }
+ ["elem2"]=>
+ object(SimpleXMLElement)#%d (1) {
+ ["elem3"]=>
+ object(SimpleXMLElement)#%d (1) {
+ ["elem4"]=>
+ object(SimpleXMLElement)#%d (1) {
+ ["test"]=>
+ object(SimpleXMLElement)#%d (0) {
+ }
+ }
+ }
+ }
+ }
+}
+===DONE===
http://cvs.php.net/diff.php/php-src/ext/simplexml/tests/003.phpt?r1=1.3&r2=1.4&ty=u
Index: php-src/ext/simplexml/tests/003.phpt
diff -u php-src/ext/simplexml/tests/003.phpt:1.3
php-src/ext/simplexml/tests/003.phpt:1.4
--- php-src/ext/simplexml/tests/003.phpt:1.3 Mon Mar 29 14:58:01 2004
+++ php-src/ext/simplexml/tests/003.phpt Sat Oct 29 12:12:57 2005
@@ -1,5 +1,5 @@
--TEST--
-SimpleXML and Entities
+SimpleXML: Entities
--SKIPIF--
<?php if (!extension_loaded("simplexml")) print "skip"; ?>
--FILE--
@@ -26,44 +26,44 @@
</sxe>
EOF;
-$sxe = simplexml_load_string($xml);
-
-print_r($sxe);
-
-echo "---Done---\n";
+var_dump(simplexml_load_string($xml));
?>
---EXPECT--
-SimpleXMLElement Object
-(
- [elem1] => SimpleXMLElement Object
- (
- [comment] => SimpleXMLElement Object
- (
- )
-
- [elem2] => SimpleXMLElement Object
- (
- [elem3] => SimpleXMLElement Object
- (
- [included-entity] => SimpleXMLElement Object
- (
- [included-entity] => This is text included
from an entity
- )
-
- [elem4] => SimpleXMLElement Object
- (
- [test] => SimpleXMLElement Object
- (
- )
-
- )
-
- )
-
- )
-
- )
-
-)
----Done---
+===DONE===
+--EXPECTF--
+object(SimpleXMLElement)#%d (2) {
+ ["@attributes"]=>
+ array(1) {
+ ["id"]=>
+ string(5) "elem1"
+ }
+ ["elem1"]=>
+ object(SimpleXMLElement)#%d (3) {
+ ["@attributes"]=>
+ array(1) {
+ ["attr1"]=>
+ string(5) "first"
+ }
+ ["comment"]=>
+ object(SimpleXMLElement)#%d (0) {
+ }
+ ["elem2"]=>
+ object(SimpleXMLElement)#%d (1) {
+ ["elem3"]=>
+ object(SimpleXMLElement)#%d (2) {
+ ["included-entity"]=>
+ object(SimpleXMLElement)#%d (1) {
+ ["included-entity"]=>
+ string(36) "This is text included from an entity"
+ }
+ ["elem4"]=>
+ object(SimpleXMLElement)#%d (1) {
+ ["test"]=>
+ object(SimpleXMLElement)#%d (0) {
+ }
+ }
+ }
+ }
+ }
+}
+===DONE===
http://cvs.php.net/diff.php/php-src/ext/simplexml/tests/004.phpt?r1=1.7&r2=1.8&ty=u
Index: php-src/ext/simplexml/tests/004.phpt
diff -u php-src/ext/simplexml/tests/004.phpt:1.7
php-src/ext/simplexml/tests/004.phpt:1.8
--- php-src/ext/simplexml/tests/004.phpt:1.7 Wed Aug 17 07:36:28 2005
+++ php-src/ext/simplexml/tests/004.phpt Sat Oct 29 12:12:57 2005
@@ -1,5 +1,5 @@
--TEST--
-SimpleXML and CDATA
+SimpleXML: CDATA
--SKIPIF--
<?php if (!extension_loaded("simplexml")) print "skip"; ?>
--FILE--
@@ -25,7 +25,7 @@
EOF
);
-print_r($sxe);
+var_dump($sxe);
$elem1 = $sxe->elem1;
$elem2 = $elem1->elem2;
@@ -33,63 +33,36 @@
?>
===DONE===
---EXPECT--
-SimpleXMLElement Object
-(
- [elem1] => SimpleXMLElement Object
- (
- [comment] => SimpleXMLElement Object
- (
- )
-
- [elem2] => SimpleXMLElement Object
- (
- [elem3] => SimpleXMLElement Object
- (
- [elem4] => SimpleXMLElement Object
- (
- [test] => SimpleXMLElement Object
- (
- )
-
- )
-
- )
-
- )
-
- )
-
-)
+--EXPECTF--
+object(SimpleXMLElement)#%d (2) {
+ ["@attributes"]=>
+ array(1) {
+ ["id"]=>
+ string(5) "elem1"
+ }
+ ["elem1"]=>
+ object(SimpleXMLElement)#%d (3) {
+ ["@attributes"]=>
+ array(1) {
+ ["attr1"]=>
+ string(5) "first"
+ }
+ ["comment"]=>
+ object(SimpleXMLElement)#%d (0) {
+ }
+ ["elem2"]=>
+ object(SimpleXMLElement)#%d (1) {
+ ["elem3"]=>
+ object(SimpleXMLElement)#%d (1) {
+ ["elem4"]=>
+ object(SimpleXMLElement)#%d (1) {
+ ["test"]=>
+ object(SimpleXMLElement)#%d (0) {
+ }
+ }
+ }
+ }
+ }
+}
string(11) "CDATA block"
===DONE===
---UEXPECT--
-SimpleXMLElement Object
-(
- [elem1] => SimpleXMLElement Object
- (
- [comment] => SimpleXMLElement Object
- (
- )
-
- [elem2] => SimpleXMLElement Object
- (
- [elem3] => SimpleXMLElement Object
- (
- [elem4] => SimpleXMLElement Object
- (
- [test] => SimpleXMLElement Object
- (
- )
-
- )
-
- )
-
- )
-
- )
-
-)
-unicode(11) "CDATA block"
-===DONE===
http://cvs.php.net/diff.php/php-src/ext/simplexml/tests/005.phpt?r1=1.3&r2=1.4&ty=u
Index: php-src/ext/simplexml/tests/005.phpt
diff -u php-src/ext/simplexml/tests/005.phpt:1.3
php-src/ext/simplexml/tests/005.phpt:1.4
--- php-src/ext/simplexml/tests/005.phpt:1.3 Mon Aug 15 10:37:55 2005
+++ php-src/ext/simplexml/tests/005.phpt Sat Oct 29 12:12:57 2005
@@ -1,5 +1,5 @@
--TEST--
-SimpleXML and text data
+SimpleXML: Text data
--SKIPIF--
<?php if (!extension_loaded("simplexml")) print "skip"; ?>
--FILE--
http://cvs.php.net/diff.php/php-src/ext/simplexml/tests/006.phpt?r1=1.6&r2=1.7&ty=u
Index: php-src/ext/simplexml/tests/006.phpt
diff -u php-src/ext/simplexml/tests/006.phpt:1.6
php-src/ext/simplexml/tests/006.phpt:1.7
--- php-src/ext/simplexml/tests/006.phpt:1.6 Mon Aug 15 10:37:55 2005
+++ php-src/ext/simplexml/tests/006.phpt Sat Oct 29 12:12:57 2005
@@ -1,5 +1,5 @@
--TEST--
-SimpleXML and foreach
+SimpleXML: foreach
--SKIPIF--
<?php if (!extension_loaded("simplexml")) print "skip"; ?>
--FILE--
http://cvs.php.net/diff.php/php-src/ext/simplexml/tests/007.phpt?r1=1.9&r2=1.10&ty=u
Index: php-src/ext/simplexml/tests/007.phpt
diff -u php-src/ext/simplexml/tests/007.phpt:1.9
php-src/ext/simplexml/tests/007.phpt:1.10
--- php-src/ext/simplexml/tests/007.phpt:1.9 Mon Aug 15 10:37:55 2005
+++ php-src/ext/simplexml/tests/007.phpt Sat Oct 29 12:12:57 2005
@@ -1,5 +1,5 @@
--TEST--
-SimpleXML and attributes
+SimpleXML: Attributes
--SKIPIF--
<?php if (!extension_loaded("simplexml")) print "skip"; ?>
--FILE--
@@ -48,7 +48,12 @@
===Done===
--EXPECTF--
===Property===
-object(SimpleXMLElement)#%d (2) {
+object(SimpleXMLElement)#%d (3) {
+ ["@attributes"]=>
+ array(1) {
+ ["attr1"]=>
+ string(5) "first"
+ }
["comment"]=>
object(SimpleXMLElement)#%d (0) {
}
@@ -90,47 +95,3 @@
int(4)
int(4)
===Done===
---UEXPECTF--
-===Property===
-object(SimpleXMLElement)#%d (2) {
- [u"comment"]=>
- object(SimpleXMLElement)#%d (0) {
- }
- [u"elem2"]=>
- object(SimpleXMLElement)#%d (1) {
- [u"elem3"]=>
- object(SimpleXMLElement)#%d (1) {
- [u"elem4"]=>
- object(SimpleXMLElement)#%d (1) {
- [u"test"]=>
- object(SimpleXMLElement)#%d (0) {
- }
- }
- }
- }
-}
-===Array===
-object(SimpleXMLElement)#%d (1) {
- [0]=>
- unicode(5) "elem1"
-}
-object(SimpleXMLElement)#%d (1) {
- [0]=>
- unicode(5) "first"
-}
-===Set===
-object(SimpleXMLElement)#%d (1) {
- [0]=>
- unicode(8) "Changed1"
-}
-object(SimpleXMLElement)#%d (1) {
- [0]=>
- unicode(2) "12"
-}
-===Unset===
-NULL
-NULL
-===Misc.===
-int(4)
-int(4)
-===Done===
http://cvs.php.net/diff.php/php-src/ext/simplexml/tests/008.phpt?r1=1.5&r2=1.6&ty=u
Index: php-src/ext/simplexml/tests/008.phpt
diff -u php-src/ext/simplexml/tests/008.phpt:1.5
php-src/ext/simplexml/tests/008.phpt:1.6
--- php-src/ext/simplexml/tests/008.phpt:1.5 Tue Aug 16 11:09:45 2005
+++ php-src/ext/simplexml/tests/008.phpt Sat Oct 29 12:12:57 2005
@@ -1,5 +1,5 @@
--TEST--
-SimpleXML and XPath
+SimpleXML: XPath
--SKIPIF--
<?php if (!extension_loaded("simplexml")) print "skip"; ?>
--FILE--
http://cvs.php.net/diff.php/php-src/ext/simplexml/tests/009.phpt?r1=1.6&r2=1.7&ty=u
Index: php-src/ext/simplexml/tests/009.phpt
diff -u php-src/ext/simplexml/tests/009.phpt:1.6
php-src/ext/simplexml/tests/009.phpt:1.7
--- php-src/ext/simplexml/tests/009.phpt:1.6 Tue Aug 16 11:09:45 2005
+++ php-src/ext/simplexml/tests/009.phpt Sat Oct 29 12:12:57 2005
@@ -1,5 +1,5 @@
--TEST--
-SimpleXML and foreach
+SimpleXML: foreach
--SKIPIF--
<?php if (!extension_loaded("simplexml")) print "skip"; ?>
--FILE--
http://cvs.php.net/diff.php/php-src/ext/simplexml/tests/010.phpt?r1=1.5&r2=1.6&ty=u
Index: php-src/ext/simplexml/tests/010.phpt
diff -u php-src/ext/simplexml/tests/010.phpt:1.5
php-src/ext/simplexml/tests/010.phpt:1.6
--- php-src/ext/simplexml/tests/010.phpt:1.5 Mon Mar 29 14:58:01 2004
+++ php-src/ext/simplexml/tests/010.phpt Sat Oct 29 12:12:57 2005
@@ -26,38 +26,39 @@
</sxe>
EOF;
-$sxe = simplexml_load_string($xml, 'simplexml_inherited');
-
-print_r($sxe);
+var_dump(simplexml_load_string($xml, 'simplexml_inherited'));
?>
===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
- (
- )
-
- )
-
- )
-
- )
-
- )
-
-)
+--EXPECTF--
+object(simplexml_inherited)#%d (2) {
+ ["@attributes"]=>
+ array(1) {
+ ["id"]=>
+ string(5) "elem1"
+ }
+ ["elem1"]=>
+ object(simplexml_inherited)#%d (3) {
+ ["@attributes"]=>
+ array(1) {
+ ["attr1"]=>
+ string(5) "first"
+ }
+ ["comment"]=>
+ object(simplexml_inherited)#%d (0) {
+ }
+ ["elem2"]=>
+ object(simplexml_inherited)#%d (1) {
+ ["elem3"]=>
+ object(simplexml_inherited)#%d (1) {
+ ["elem4"]=>
+ object(simplexml_inherited)#%d (1) {
+ ["test"]=>
+ object(simplexml_inherited)#%d (0) {
+ }
+ }
+ }
+ }
+ }
+}
===DONE===
http://cvs.php.net/diff.php/php-src/ext/simplexml/tests/011.phpt?r1=1.3&r2=1.4&ty=u
Index: php-src/ext/simplexml/tests/011.phpt
diff -u php-src/ext/simplexml/tests/011.phpt:1.3
php-src/ext/simplexml/tests/011.phpt:1.4
--- php-src/ext/simplexml/tests/011.phpt:1.3 Sat Jan 17 14:41:32 2004
+++ php-src/ext/simplexml/tests/011.phpt Sat Oct 29 12:12:57 2005
@@ -1,5 +1,5 @@
--TEST--
-SimpleXML and echo/print
+SimpleXML: echo/print
--SKIPIF--
<?php
if (!extension_loaded('simplexml')) print 'skip';
http://cvs.php.net/diff.php/php-src/ext/simplexml/tests/012.phpt?r1=1.5&r2=1.6&ty=u
Index: php-src/ext/simplexml/tests/012.phpt
diff -u php-src/ext/simplexml/tests/012.phpt:1.5
php-src/ext/simplexml/tests/012.phpt:1.6
--- php-src/ext/simplexml/tests/012.phpt:1.5 Mon Sep 19 02:11:12 2005
+++ php-src/ext/simplexml/tests/012.phpt Sat Oct 29 12:12:57 2005
@@ -1,5 +1,5 @@
--TEST--
-SimpleXML and Attribute creation
+SimpleXML: Attribute creation
--SKIPIF--
<?php
if (!extension_loaded('simplexml')) print 'skip';
http://cvs.php.net/diff.php/php-src/ext/simplexml/tests/013.phpt?r1=1.2&r2=1.3&ty=u
Index: php-src/ext/simplexml/tests/013.phpt
diff -u php-src/ext/simplexml/tests/013.phpt:1.2
php-src/ext/simplexml/tests/013.phpt:1.3
--- php-src/ext/simplexml/tests/013.phpt:1.2 Tue Dec 16 16:02:54 2003
+++ php-src/ext/simplexml/tests/013.phpt Sat Oct 29 12:12:57 2005
@@ -1,5 +1,5 @@
--TEST--
-SimpleXML and Split text content
+SimpleXML: Split text content
--SKIPIF--
<?php
if (!extension_loaded('simplexml')) print 'skip';
http://cvs.php.net/diff.php/php-src/ext/simplexml/tests/019.phpt?r1=1.3&r2=1.4&ty=u
Index: php-src/ext/simplexml/tests/019.phpt
diff -u php-src/ext/simplexml/tests/019.phpt:1.3
php-src/ext/simplexml/tests/019.phpt:1.4
--- php-src/ext/simplexml/tests/019.phpt:1.3 Mon Aug 15 10:37:55 2005
+++ php-src/ext/simplexml/tests/019.phpt Sat Oct 29 12:12:57 2005
@@ -1,5 +1,5 @@
--TEST--
-SimpleXML and foreach with children()
+SimpleXML: foreach with children()
--SKIPIF--
<?php if (!extension_loaded("simplexml")) print "skip"; ?>
--FILE--
http://cvs.php.net/diff.php/php-src/ext/simplexml/tests/020.phpt?r1=1.1&r2=1.2&ty=u
Index: php-src/ext/simplexml/tests/020.phpt
diff -u php-src/ext/simplexml/tests/020.phpt:1.1
php-src/ext/simplexml/tests/020.phpt:1.2
--- php-src/ext/simplexml/tests/020.phpt:1.1 Sun Mar 14 10:33:15 2004
+++ php-src/ext/simplexml/tests/020.phpt Sat Oct 29 12:12:57 2005
@@ -1,5 +1,5 @@
--TEST--
-SimpleXML attribute compared to string
+SimpleXML: Attribute compared to string
--SKIPIF--
<?php if (!extension_loaded("simplexml")) print "skip"; ?>
--FILE--
http://cvs.php.net/diff.php/php-src/ext/simplexml/tests/021.phpt?r1=1.1&r2=1.2&ty=u
Index: php-src/ext/simplexml/tests/021.phpt
diff -u php-src/ext/simplexml/tests/021.phpt:1.1
php-src/ext/simplexml/tests/021.phpt:1.2
--- php-src/ext/simplexml/tests/021.phpt:1.1 Wed Mar 24 10:20:32 2004
+++ php-src/ext/simplexml/tests/021.phpt Sat Oct 29 12:12:57 2005
@@ -1,5 +1,5 @@
--TEST--
-SimpleXML element check
+SimpleXML: Element check
--SKIPIF--
<?php if (!extension_loaded("simplexml")) print "skip"; ?>
--FILE--
http://cvs.php.net/diff.php/php-src/ext/simplexml/tests/022.phpt?r1=1.2&r2=1.3&ty=u
Index: php-src/ext/simplexml/tests/022.phpt
diff -u php-src/ext/simplexml/tests/022.phpt:1.2
php-src/ext/simplexml/tests/022.phpt:1.3
--- php-src/ext/simplexml/tests/022.phpt:1.2 Tue Aug 16 11:09:45 2005
+++ php-src/ext/simplexml/tests/022.phpt Sat Oct 29 12:12:57 2005
@@ -1,5 +1,5 @@
--TEST--
-SimpleXML and attributes inside foreach
+SimpleXML: Attributes inside foreach
--SKIPIF--
<?php if (!extension_loaded("simplexml")) print "skip"; ?>
--FILE--
@@ -12,6 +12,13 @@
$sxe = simplexml_load_string($xml);
+echo "===CONTENT===\n";
+var_dump($sxe->content);
+
+echo "===FILE===\n";
+var_dump($sxe->content->file);
+
+echo "===FOREACH===\n";
foreach($sxe->content->file as $file)
{
var_dump($file);
@@ -21,18 +28,35 @@
?>
===DONE===
--EXPECTF--
-object(SimpleXMLElement)#%d (0) {
+===CONTENT===
+object(SimpleXMLElement)#%d (1) {
+ ["file"]=>
+ object(SimpleXMLElement)#%d (1) {
+ ["@attributes"]=>
+ array(1) {
+ ["glob"]=>
+ string(11) "slide_*.xml"
+ }
+ }
}
+===FILE===
object(SimpleXMLElement)#%d (1) {
- [0]=>
- string(11) "slide_*.xml"
+ ["@attributes"]=>
+ array(1) {
+ ["glob"]=>
+ string(11) "slide_*.xml"
+ }
}
-===DONE===
---UEXPECTF--
-object(SimpleXMLElement)#%d (0) {
+===FOREACH===
+object(SimpleXMLElement)#%d (1) {
+ ["@attributes"]=>
+ array(1) {
+ ["glob"]=>
+ string(11) "slide_*.xml"
+ }
}
object(SimpleXMLElement)#%d (1) {
[0]=>
- unicode(11) "slide_*.xml"
+ string(11) "slide_*.xml"
}
===DONE===
http://cvs.php.net/diff.php/php-src/ext/simplexml/tests/023.phpt?r1=1.2&r2=1.3&ty=u
Index: php-src/ext/simplexml/tests/023.phpt
diff -u php-src/ext/simplexml/tests/023.phpt:1.2
php-src/ext/simplexml/tests/023.phpt:1.3
--- php-src/ext/simplexml/tests/023.phpt:1.2 Sun Oct 23 19:41:20 2005
+++ php-src/ext/simplexml/tests/023.phpt Sat Oct 29 12:12:57 2005
@@ -22,7 +22,12 @@
?>
===DONE===
--EXPECTF--
-object(SimpleXMLElement)#%d (0) {
+object(SimpleXMLElement)#%d (1) {
+ ["@attributes"]=>
+ array(1) {
+ ["attr"]=>
+ string(%d) "foo%sbar%sbaz"
+ }
}
object(SimpleXMLElement)#%d (1) {
[0]=>
http://cvs.php.net/diff.php/php-src/ext/simplexml/tests/bug27010.phpt?r1=1.2&r2=1.3&ty=u
Index: php-src/ext/simplexml/tests/bug27010.phpt
diff -u php-src/ext/simplexml/tests/bug27010.phpt:1.2
php-src/ext/simplexml/tests/bug27010.phpt:1.3
--- php-src/ext/simplexml/tests/bug27010.phpt:1.2 Wed Feb 11 07:19:26 2004
+++ php-src/ext/simplexml/tests/bug27010.phpt Sat Oct 29 12:12:57 2005
@@ -1,5 +1,5 @@
--TEST--
-#27010: segfault and node text not displayed when returned from children()
+Bug #27010: segfault and node text not displayed when returned from children()
--FILE--
<?php
http://cvs.php.net/diff.php/php-src/ext/simplexml/tests/profile11.phpt?r1=1.3&r2=1.4&ty=u
Index: php-src/ext/simplexml/tests/profile11.phpt
diff -u php-src/ext/simplexml/tests/profile11.phpt:1.3
php-src/ext/simplexml/tests/profile11.phpt:1.4
--- php-src/ext/simplexml/tests/profile11.phpt:1.3 Sat Jan 17 16:47:43 2004
+++ php-src/ext/simplexml/tests/profile11.phpt Sat Oct 29 12:12:57 2005
@@ -12,15 +12,24 @@
</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";
+var_dump($root->children('reserved-ns')->child);
+var_dump($root->children('special-ns')->child);
+var_dump((string)$root->children('reserved-ns')->child);
+var_dump((string)$root->children('special-ns')->child);
+var_dump($root->child);
?>
---EXPECT--
-Hello
-World
----Done---
+===DONE===
+--EXPECTF--
+object(SimpleXMLElement)#%d (1) {
+ [0]=>
+ string(5) "Hello"
+}
+object(SimpleXMLElement)#%d (1) {
+ [0]=>
+ string(5) "World"
+}
+string(5) "Hello"
+string(5) "World"
+object(SimpleXMLElement)#%d (0) {
+}
+===DONE===
http://cvs.php.net/diff.php/php-src/ext/simplexml/tests/simplexml_import_dom.phpt?r1=1.1&r2=1.2&ty=u
Index: php-src/ext/simplexml/tests/simplexml_import_dom.phpt
diff -u php-src/ext/simplexml/tests/simplexml_import_dom.phpt:1.1
php-src/ext/simplexml/tests/simplexml_import_dom.phpt:1.2
--- php-src/ext/simplexml/tests/simplexml_import_dom.phpt:1.1 Mon Oct 27
06:34:45 2003
+++ php-src/ext/simplexml/tests/simplexml_import_dom.phpt Sat Oct 29
12:12:57 2005
@@ -1,5 +1,5 @@
--TEST--
-Interop: simplexml_import_dom
+SimpleXML [interop]: simplexml_import_dom
--SKIPIF--
<?php if (!extension_loaded("simplexml")) print "skip"; ?>
<?php if (!extension_loaded("dom")) print "skip. dom extension not loaded"; ?>
http://cvs.php.net/diff.php/php-src/ext/simplexml/tests/sxe.dtd?r1=1.2&r2=1.3&ty=u
Index: php-src/ext/simplexml/tests/sxe.dtd
diff -u php-src/ext/simplexml/tests/sxe.dtd:1.2
php-src/ext/simplexml/tests/sxe.dtd:1.3
--- php-src/ext/simplexml/tests/sxe.dtd:1.2 Sun Oct 26 08:18:59 2003
+++ php-src/ext/simplexml/tests/sxe.dtd Sat Oct 29 12:12:57 2005
@@ -1,21 +1,34 @@
<?xml encoding='US-ASCII'?>
-<!ELEMENT sxe elem1, elem 11>
+<!ELEMENT sxe (elem1+, elem11, elem22*)>
<!ATTLIST sxe id CDATA #implied>
-<!ELEMENT elem1 elem2>
+<!ELEMENT elem1 elem2*>
<!ATTLIST elem1 attr1 CDATA #required
attr2 CDATA "default>
-<!ELEMENT elem2 elem3>
-<!ATTLIST elem2>
+<!ELEMENT elem2 elem3*>
+<!ATTLIST elem2 att25 CDATA #implied
+ att42 CDATA #implied>
-<!ELEMENT elem3 elem4>
+<!ELEMENT elem3 elem4*>
<!ATTLIST elem3>
<!ELEMENT elem4 EMPTY>
<!ATTLIST elem4>
-<!ELEMENT elem11 EMPTY>
+<!ELEMENT elem11 elem111*>
<!ATTLIST elem11>
+<!ELEMNET elem111 elem1111*>
+<!ATTLIST elem111>
+
+<!ELEMENT elem1111 EMPTY>
+<!ATTLIST elem1111>
+
+<!ELEMENT elem22 elem222*>
+<!ATTLIST elem22 attr22 CDATA #implied>
+
+<!ELEMENT elem222 EMPTY>
+<!ATTLIST elem222>
+
http://cvs.php.net/co.php/php-src/ext/simplexml/tests/000.phpt?r=1.1&p=1
Index: php-src/ext/simplexml/tests/000.phpt
+++ php-src/ext/simplexml/tests/000.phpt
--TEST--
SimpleXML: var_dump()
--SKIPIF--
<?php if (!extension_loaded("simplexml")) print "skip"; ?>
--FILE--
<?php
$sxe = simplexml_load_file(dirname(__FILE__).'/000.xml');
function test($what)
{
global $sxe;
echo "===$what\n";
eval("var_dump(isset(\$$what));");
eval("var_dump(\$$what);");
}
test('sxe');
test('sxe->elem1');
test('sxe->elem1[0]');
test('sxe->elem1[0]->elem2');
test('sxe->elem1[0]->elem2->bla');
test('sxe->elem1[0]["attr1"]');
test('sxe->elem1[0]->attr1');
test('sxe->elem1[1]');
test('sxe->elem1[2]');
test('sxe->elem11');
test('sxe->elem11->elem111');
test('sxe->elem11->elem111->elem1111');
test('sxe->elem22');
test('sxe->elem22->elem222');
test('sxe->elem22->attr22');
test('sxe->elem22["attr22"]');
?>
===DONE===
<?php exit(0); ?>
--EXPECTF--
===sxe
bool(true)
object(SimpleXMLElement)#%d (3) {
["@attributes"]=>
array(1) {
["id"]=>
string(3) "123"
}
["elem1"]=>
array(2) {
[0]=>
string(36) "There is some text.Here is some more"
[1]=>
object(SimpleXMLElement)#%d (1) {
["@attributes"]=>
array(2) {
["attr1"]=>
string(2) "11"
["attr2"]=>
string(2) "12"
}
}
}
["elem11"]=>
object(SimpleXMLElement)#%d (1) {
["elem111"]=>
object(SimpleXMLElement)#%d (1) {
["elem1111"]=>
object(SimpleXMLElement)#%d (0) {
}
}
}
}
===sxe->elem1
bool(true)
object(SimpleXMLElement)#%d (3) {
["@attributes"]=>
array(2) {
["attr1"]=>
string(5) "first"
["attr2"]=>
string(6) "second"
}
["comment"]=>
object(SimpleXMLElement)#%d (0) {
}
["elem2"]=>
object(SimpleXMLElement)#%d (2) {
["@attributes"]=>
array(2) {
["att25"]=>
string(2) "25"
["att42"]=>
string(2) "42"
}
["elem3"]=>
object(SimpleXMLElement)#%d (1) {
["elem4"]=>
object(SimpleXMLElement)#%d (1) {
["test"]=>
object(SimpleXMLElement)#%d (0) {
}
}
}
}
}
===sxe->elem1[0]
bool(true)
object(SimpleXMLElement)#%d (3) {
["@attributes"]=>
array(2) {
["attr1"]=>
string(5) "first"
["attr2"]=>
string(6) "second"
}
["comment"]=>
object(SimpleXMLElement)#%d (0) {
}
["elem2"]=>
object(SimpleXMLElement)#%d (2) {
["@attributes"]=>
array(2) {
["att25"]=>
string(2) "25"
["att42"]=>
string(2) "42"
}
["elem3"]=>
object(SimpleXMLElement)#%d (1) {
["elem4"]=>
object(SimpleXMLElement)#%d (1) {
["test"]=>
object(SimpleXMLElement)#%d (0) {
}
}
}
}
}
===sxe->elem1[0]->elem2
bool(true)
object(SimpleXMLElement)#%d (2) {
["@attributes"]=>
array(2) {
["att25"]=>
string(2) "25"
["att42"]=>
string(2) "42"
}
["elem3"]=>
object(SimpleXMLElement)#%d (1) {
["elem4"]=>
object(SimpleXMLElement)#%d (1) {
["test"]=>
object(SimpleXMLElement)#%d (0) {
}
}
}
}
===sxe->elem1[0]->elem2->bla
bool(false)
object(SimpleXMLElement)#%d (0) {
}
===sxe->elem1[0]["attr1"]
bool(true)
object(SimpleXMLElement)#%d (1) {
[0]=>
string(5) "first"
}
===sxe->elem1[0]->attr1
bool(false)
object(SimpleXMLElement)#%d (0) {
}
===sxe->elem1[1]
bool(true)
object(SimpleXMLElement)#%d (1) {
["@attributes"]=>
array(2) {
["attr1"]=>
string(2) "11"
["attr2"]=>
string(2) "12"
}
}
===sxe->elem1[2]
bool(false)
NULL
===sxe->elem11
bool(true)
object(SimpleXMLElement)#%d (1) {
["elem111"]=>
object(SimpleXMLElement)#%d (1) {
["elem1111"]=>
object(SimpleXMLElement)#%d (0) {
}
}
}
===sxe->elem11->elem111
bool(true)
object(SimpleXMLElement)#%d (1) {
["elem1111"]=>
object(SimpleXMLElement)#%d (0) {
}
}
===sxe->elem11->elem111->elem1111
bool(true)
object(SimpleXMLElement)#%d (0) {
}
===sxe->elem22
bool(false)
object(SimpleXMLElement)#%d (0) {
}
===sxe->elem22->elem222
bool(false)
NULL
===sxe->elem22->attr22
bool(false)
NULL
===sxe->elem22["attr22"]
bool(false)
NULL
===DONE===
http://cvs.php.net/co.php/php-src/ext/simplexml/tests/000.xml?r=1.1&p=1
Index: php-src/ext/simplexml/tests/000.xml
+++ php-src/ext/simplexml/tests/000.xml
<?xml version='1.0'?>
<!DOCTYPE sxe SYSTEM "sxe.dtd" [
<!ENTITY % incent SYSTEM "sxe.ent">
%incent;
]>
<sxe id="123">
<elem1 attr1='first' attr2='second'>There is some text.<!-- comment --><elem2
att25='25' att42='42'>
<elem3>
<elem4>
<?test processing instruction ?>
</elem4>
</elem3>
</elem2>Here is some more</elem1>
<elem1 attr1='11' attr2='12'/>
<elem11><elem111><elem1111/></elem111></elem11>
</sxe>
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php