rrichards Wed Jan 21 09:04:47 2004 EDT
Modified files:
/php-src/ext/simplexml simplexml.c
/php-src/ext/simplexml/tests profile10.phpt
Log:
Fix namespace regression bug
Read attributes correctly
Update sxe_prop_dim_exists logic
Update profile
http://cvs.php.net/diff.php/php-src/ext/simplexml/simplexml.c?r1=1.120&r2=1.121&ty=u
Index: php-src/ext/simplexml/simplexml.c
diff -u php-src/ext/simplexml/simplexml.c:1.120 php-src/ext/simplexml/simplexml.c:1.121
--- php-src/ext/simplexml/simplexml.c:1.120 Wed Jan 21 06:32:29 2004
+++ php-src/ext/simplexml/simplexml.c Wed Jan 21 09:04:46 2004
@@ -18,7 +18,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: simplexml.c,v 1.120 2004/01/21 11:32:29 rrichards Exp $ */
+/* $Id: simplexml.c,v 1.121 2004/01/21 14:04:46 rrichards Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -117,7 +117,7 @@
static inline int
match_ns(php_sxe_object *sxe, xmlNodePtr node, xmlChar *name)
{
- if (name == NULL && (node->ns == NULL || node->ns->href == NULL)) {
+ if (name == NULL && (node->ns == NULL || node->ns->prefix == NULL)) {
return 1;
}
@@ -145,7 +145,7 @@
sxe = php_sxe_fetch_object(object TSRMLS_CC);
if (Z_TYPE_P(member) == IS_LONG) {
- if (sxe->iter.type != SXE_ITER_ATTR) {
+ if (sxe->iter.type != SXE_ITER_ATTRLIST) {
attribs = 0;
elements = 1;
}
@@ -165,20 +165,36 @@
GET_NODE(sxe, node);
- if (sxe->iter.type != SXE_ITER_CHILD) {
+ 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)) {
- _node_as_zval(sxe, (xmlNodePtr) attr,
return_value, SXE_ITER_NONE, NULL, NULL TSRMLS_CC);
- break;
+ 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, NULL 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, NULL TSRMLS_CC);
+ break;
+ }
+ attr = attr->next;
+ }
}
- attr = attr->next;
}
}
@@ -414,12 +430,17 @@
xmlNodePtr node;
xmlAttrPtr attr = NULL;
int exists = 0;
+ int nodendx = 0;
sxe = php_sxe_fetch_object(object TSRMLS_CC);
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) {
attr = node->properties;
@@ -434,16 +455,32 @@
}
if (elements) {
- node = node->children;
- while (node) {
- SKIP_TEXT(node);
-
- if (!xmlStrcmp(node->name, name)) {
- return 1;
+ if (Z_TYPE_P(member) == IS_LONG) {
+ if (sxe->iter.type == SXE_ITER_NONE || sxe->iter.type
== SXE_ITER_ATTR) {
+ node = NULL;
}
+ while (node && nodendx <= Z_LVAL_P(member)) {
+ SKIP_TEXT(node)
+ if (node->type == XML_ELEMENT_NODE) {
+ if (match_ns(sxe, node,
sxe->iter.nsprefix)) {
+ if (sxe->iter.type ==
SXE_ITER_ELEMENT && !xmlStrcmp(node->name, sxe->iter.name)) {
+ if (nodendx ==
Z_LVAL_P(member)) {
+ break;
+ }
+ nodendx++;
+ }
+ } else {
+ break;
+ }
+ }
next_iter:
- node = node->next;
+ node = node->next;
+ }
+ }
+
+ if (node) {
+ return 1;
}
}
}
@@ -1522,7 +1559,7 @@
{
php_info_print_table_start();
php_info_print_table_header(2, "Simplexml support", "enabled");
- php_info_print_table_row(2, "Revision", "$Revision: 1.120 $");
+ php_info_print_table_row(2, "Revision", "$Revision: 1.121 $");
php_info_print_table_row(2, "Schema support",
#ifdef LIBXML_SCHEMAS_ENABLED
"enabled");
http://cvs.php.net/diff.php/php-src/ext/simplexml/tests/profile10.phpt?r1=1.4&r2=1.5&ty=u
Index: php-src/ext/simplexml/tests/profile10.phpt
diff -u php-src/ext/simplexml/tests/profile10.phpt:1.4
php-src/ext/simplexml/tests/profile10.phpt:1.5
--- php-src/ext/simplexml/tests/profile10.phpt:1.4 Sat Jan 17 16:22:26 2004
+++ php-src/ext/simplexml/tests/profile10.phpt Wed Jan 21 09:04:47 2004
@@ -17,9 +17,6 @@
echo $rsattr['attribute'];
echo "\n";
echo $spattr['attribute'];
-foreach ($root->child['attribute'] as $attr) {
- echo "$attr\n";
-}
echo "\n---Done---\n";
?>
--EXPECT--
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php