cvs: php-src /ext/simplexml simplexml.c /ext/simplexml/tests 025.phpt

From: Date: Tue, 01 Nov 2005 11:53:14 +0000
Subject: cvs: php-src /ext/simplexml simplexml.c /ext/simplexml/tests 025.phpt
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-34933@lists.php.net to get a copy of this message
helly Tue Nov 1 06:53:14 2005 EDT Modified files: /php-src/ext/simplexml simplexml.c /php-src/ext/simplexml/tests 025.phpt Log: - Handle default namespaces # Another time it shows xml is far from being simple http://cvs.php.net/diff.php/php-src/ext/simplexml/simplexml.c?r1=1.173&r2=1.174&ty=u Index: php-src/ext/simplexml/simplexml.c diff -u php-src/ext/simplexml/simplexml.c:1.173 php-src/ext/simplexml/simplexml.c:1.174 --- php-src/ext/simplexml/simplexml.c:1.173 Mon Oct 31 15:06:23 2005 +++ php-src/ext/simplexml/simplexml.c Tue Nov 1 06:53:12 2005 @@ -18,7 +18,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: simplexml.c,v 1.173 2005/10/31 20:06:23 helly Exp $ */ +/* $Id: simplexml.c,v 1.174 2005/11/01 11:53:12 helly Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -1102,18 +1102,25 @@ } /* }}} */ +#define SXE_NS_PREFIX(ns) (ns->prefix ? (char*)ns->prefix : "") + +static inline void sxe_add_namespace_name(zval *return_value, xmlNsPtr ns) +{ + add_assoc_string(return_value, SXE_NS_PREFIX(ns), (char*)ns->href, 1); +} + static void sxe_add_namespaces(php_sxe_object *sxe, xmlNodePtr node, zend_bool recursive, zval *return_value TSRMLS_DC) /* {{{ */ { xmlAttrPtr attr; if (node->ns) { - add_assoc_string(return_value, (char*)node->ns->prefix, (char*)node->ns->href, 1); + sxe_add_namespace_name(return_value, node->ns); } attr = node->properties; while (attr) { if (attr->ns) { - add_assoc_string(return_value, (char*)attr->ns->prefix, (char*)attr->ns->href, 1); + sxe_add_namespace_name(return_value, attr->ns); } attr = attr->next; } @@ -1152,7 +1159,7 @@ if (node->type == XML_ELEMENT_NODE) { sxe_add_namespaces(sxe, node, recursive, return_value TSRMLS_CC); } else if (node->type == XML_ATTRIBUTE_NODE && node->ns) { - add_assoc_string(return_value, (char*)node->ns->prefix, (char*)node->ns->href, 1); + sxe_add_namespace_name(return_value, node->ns); } next_iter: node = node->next; @@ -1165,7 +1172,7 @@ xmlNsPtr *ns = xmlGetNsList(doc, node); while (ns && ns[0]) { - add_assoc_string(return_value, (char*)ns[0]->prefix, (char*)ns[0]->href, 1); + sxe_add_namespace_name(return_value, ns[0]); ns++; } @@ -2003,7 +2010,7 @@ { php_info_print_table_start(); php_info_print_table_header(2, "Simplexml support", "enabled"); - php_info_print_table_row(2, "Revision", "$Revision: 1.173 $"); + php_info_print_table_row(2, "Revision", "$Revision: 1.174 $"); php_info_print_table_row(2, "Schema support", #ifdef LIBXML_SCHEMAS_ENABLED "enabled"); http://cvs.php.net/diff.php/php-src/ext/simplexml/tests/025.phpt?r1=1.1&r2=1.2&ty=u Index: php-src/ext/simplexml/tests/025.phpt diff -u php-src/ext/simplexml/tests/025.phpt:1.1 php-src/ext/simplexml/tests/025.phpt:1.2 --- php-src/ext/simplexml/tests/025.phpt:1.1 Mon Oct 31 14:09:13 2005 +++ php-src/ext/simplexml/tests/025.phpt Tue Nov 1 06:53:14 2005 @@ -23,8 +23,19 @@ var_dump($sxe->getDocNamespaces()); var_dump($sxe->getDocNamespaces(true)); +$xml =<<<EOF +<?xml version='1.0'?> +<html xmlns='http://www.w3.org/1999/xhtml'/> +EOF; + +$sxe = simplexml_load_string($xml); + +var_dump($sxe->getNamespaces()); +var_dump($sxe->getDocNamespaces()); + ?> ===DONE=== +<?php exit(0); ?> --EXPECTF-- array(1) { ["xhtml"]=> @@ -54,6 +65,14 @@ ["baz"]=> string(9) "foobarbaz" } +array(1) { + [""]=> + string(28) "http://www.w3.org/1999/xhtml" +} +array(1) { + [""]=> + string(28) "http://www.w3.org/1999/xhtml" +} ===DONE=== --UEXPECTF-- array(1) { @@ -84,4 +103,12 @@ [u"baz"]=> string(9) "foobarbaz" } +array(1) { + [u""]=> + string(28) "http://www.w3.org/1999/xhtml" +} +array(1) { + [u""]=> + string(28) "http://www.w3.org/1999/xhtml" +} ===DONE===

« previous php.cvs (#34933) next »