summaryrefslogtreecommitdiff
path: root/ext/simplexml
diff options
context:
space:
mode:
authorSterling Hughes <sterling@php.net>2004-01-17 21:22:26 (GMT)
committerSterling Hughes <sterling@php.net>2004-01-17 21:22:26 (GMT)
commitcb7e90119f4c231e0394622c4465cd846e215fca (patch)
treeb9ea751c0f5c352c11018f3ad8bf25464acf5da7 /ext/simplexml
parente91fdf570f707ecc4c1f4c06766b93a522bea373 (diff)
downloadphp-cb7e90119f4c231e0394622c4465cd846e215fca.tar.gz
namespace accesses are now soley URI based as opposed to prefix based.
Diffstat (limited to 'ext/simplexml')
-rw-r--r--ext/simplexml/php_simplexml.h6
-rw-r--r--ext/simplexml/simplexml.c96
-rw-r--r--ext/simplexml/tests/profile04.phpt2
-rw-r--r--ext/simplexml/tests/profile05.phpt4
-rw-r--r--ext/simplexml/tests/profile06.phpt2
-rw-r--r--ext/simplexml/tests/profile07.phpt4
-rw-r--r--ext/simplexml/tests/profile10.phpt4
7 files changed, 9 insertions, 109 deletions
diff --git a/ext/simplexml/php_simplexml.h b/ext/simplexml/php_simplexml.h
index 4b05cfa..5261505 100644
--- a/ext/simplexml/php_simplexml.h
+++ b/ext/simplexml/php_simplexml.h
@@ -53,16 +53,10 @@ PHP_RINIT_FUNCTION(simplexml);
PHP_MINFO_FUNCTION(simplexml);
typedef struct {
- xmlHashTablePtr nsmap;
- int refcount;
-} simplexml_nsmap;
-
-typedef struct {
zend_object zo;
php_libxml_node_ptr *node;
php_libxml_ref_obj *document;
HashTable *properties;
- simplexml_nsmap *nsmapptr;
xmlXPathContextPtr xpath;
struct {
php_libxml_node_ptr *node;
diff --git a/ext/simplexml/simplexml.c b/ext/simplexml/simplexml.c
index a2513bc..6a2c077 100644
--- a/ext/simplexml/simplexml.c
+++ b/ext/simplexml/simplexml.c
@@ -66,8 +66,6 @@ static void _node_as_zval(php_sxe_object *sxe, xmlNodePtr node, zval *value, int
subnode = php_sxe_object_new(sxe->zo.ce TSRMLS_CC);
subnode->document = sxe->document;
subnode->document->refcount++;
- subnode->nsmapptr = sxe->nsmapptr;
- subnode->nsmapptr->refcount++;
subnode->iter.type = itertype;
if (name) {
subnode->iter.name = xmlStrdup(name);
@@ -126,28 +124,12 @@ static xmlNodePtr php_sxe_get_first_node(php_sxe_object *sxe, xmlNodePtr node TS
static inline int
match_ns(php_sxe_object *sxe, xmlNodePtr node, xmlChar *name)
{
- xmlChar *prefix = NULL;
-
- if (name == NULL && (node->ns == NULL || node->ns->prefix == NULL)) {
+ if (name == NULL && (node->ns == NULL || node->ns->href == NULL)) {
return 1;
}
-
- if (node->ns) {
- if (sxe->nsmapptr) {
- prefix = xmlHashLookup(sxe->nsmapptr->nsmap, node->ns->href);
- }
-
- if (prefix == NULL) {
- prefix = (xmlChar*)node->ns->prefix;
- }
-
- if (prefix == NULL) {
- return 0;
- }
-
- if (!xmlStrcmp(prefix, name)) {
- return 1;
- }
+
+ if (!xmlStrcmp(node->ns->href, name)) {
+ return 1;
}
return 0;
@@ -597,8 +579,6 @@ _get_base_node_value(php_sxe_object *sxe_ref, xmlNodePtr node, zval **value TSRM
subnode = php_sxe_object_new(sxe_ref->zo.ce TSRMLS_CC);
subnode->document = sxe_ref->document;
subnode->document->refcount++;
- subnode->nsmapptr = sxe_ref->nsmapptr;
- subnode->nsmapptr->refcount++;
php_libxml_increment_node_ptr((php_libxml_node_object *)subnode, node, NULL TSRMLS_CC);
(*value)->type = IS_OBJECT;
@@ -712,16 +692,6 @@ sxe_objects_compare(zval *object1, zval *object2 TSRMLS_DC)
}
/* }}} */
-/* {{{ simplexml_ce_xpath_register_ns()
- */
-static void
-simplexml_ce_xpath_register_ns(char *prefix, xmlXPathContext *xpath, char *href)
-{
- xmlXPathRegisterNs(xpath, prefix, href);
-}
-/* }}} */
-
-
/* {{{ xpath()
*/
SXE_METHOD(xpath)
@@ -752,7 +722,6 @@ SXE_METHOD(xpath)
sxe->xpath->node = sxe->node->node;
ns = xmlGetNsList((xmlDocPtr) sxe->document->ptr, (xmlNodePtr) sxe->node->node);
-
if (ns != NULL) {
while (ns[nsnbr] != NULL) {
nsnbr++;
@@ -762,14 +731,7 @@ SXE_METHOD(xpath)
sxe->xpath->namespaces = ns;
sxe->xpath->nsNr = nsnbr;
- /* Register namespaces added in simplexml_cs_register_ns() */
- xmlHashScan((xmlHashTablePtr) sxe->nsmapptr->nsmap, (xmlHashScanner) simplexml_ce_xpath_register_ns, sxe->xpath);
-
retval = xmlXPathEval(query, sxe->xpath);
-
- /* Cleanup registered namespaces added in simplexml_cs_register_ns() */
- xmlXPathRegisteredNsCleanup(sxe->xpath);
-
if (ns != NULL) {
xmlFree(ns);
sxe->xpath->namespaces = NULL;
@@ -811,26 +773,6 @@ SXE_METHOD(xpath)
}
/* }}} */
-/* {{{ simplexml_ce_register_ns()
- */
-SXE_METHOD(register_ns)
-{
- php_sxe_object *sxe;
- char *nsname;
- char *nsvalue;
- int nsname_len;
- int nsvalue_len;
-
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss", &nsname, &nsname_len, &nsvalue, &nsvalue_len) == FAILURE) {
- return;
- }
-
- sxe = php_sxe_fetch_object(getThis() TSRMLS_CC);
-
- xmlHashAddEntry(sxe->nsmapptr->nsmap, nsvalue, xmlStrdup(nsname));
-}
-/* }}} */
-
/* {{{ proto asXML([string filename])
*/
SXE_METHOD(asXML)
@@ -1030,9 +972,6 @@ sxe_object_clone(void *object, void **clone_ptr TSRMLS_DC)
if (sxe->node) {
nodep = xmlDocCopyNode(sxe->node->node, docp, 1);
}
- clone->nsmapptr = emalloc(sizeof(simplexml_nsmap));
- clone->nsmapptr->nsmap = xmlHashCreate(10);
- clone->nsmapptr->refcount = 1;
php_libxml_increment_node_ptr((php_libxml_node_object *)clone, nodep, NULL TSRMLS_CC);
@@ -1040,15 +979,6 @@ sxe_object_clone(void *object, void **clone_ptr TSRMLS_DC)
}
/* }}} */
-/* {{{ _free_ns_entry()
- */
-static void
-_free_ns_entry(void *p, xmlChar *data)
-{
- xmlFree(p);
-}
-/* }}} */
-
/* {{{ sxe_object_dtor()
*/
static void sxe_object_dtor(void *object, zend_object_handle handle TSRMLS_DC)
@@ -1073,11 +1003,6 @@ static void sxe_object_dtor(void *object, zend_object_handle handle TSRMLS_DC)
php_libxml_node_decrement_resource((php_libxml_node_object *)sxe TSRMLS_CC);
- if (sxe->nsmapptr && --sxe->nsmapptr->refcount == 0) {
- xmlHashFree(sxe->nsmapptr->nsmap, _free_ns_entry);
- efree(sxe->nsmapptr);
- }
-
if (sxe->xpath) {
xmlXPathFreeContext(sxe->xpath);
}
@@ -1164,9 +1089,6 @@ PHP_FUNCTION(simplexml_load_file)
sxe = php_sxe_object_new(ce TSRMLS_CC);
php_libxml_increment_doc_ref((php_libxml_node_object *)sxe, docp TSRMLS_CC);
- sxe->nsmapptr = emalloc(sizeof(simplexml_nsmap));
- sxe->nsmapptr->nsmap = xmlHashCreate(10);
- sxe->nsmapptr->refcount = 1;
php_libxml_increment_node_ptr((php_libxml_node_object *)sxe, xmlDocGetRootElement(docp), NULL TSRMLS_CC);
return_value->type = IS_OBJECT;
@@ -1205,9 +1127,6 @@ PHP_FUNCTION(simplexml_load_string)
sxe = php_sxe_object_new(ce TSRMLS_CC);
php_libxml_increment_doc_ref((php_libxml_node_object *)sxe, docp TSRMLS_CC);
- sxe->nsmapptr = emalloc(sizeof(simplexml_nsmap));
- sxe->nsmapptr->nsmap = xmlHashCreate(10);
- sxe->nsmapptr->refcount = 1;
sxe->iter.type = SXE_ITER_NONE;
php_libxml_increment_node_ptr((php_libxml_node_object *)sxe, xmlDocGetRootElement(docp), NULL TSRMLS_CC);
@@ -1238,9 +1157,6 @@ SXE_METHOD(__construct)
}
php_libxml_increment_doc_ref((php_libxml_node_object *)sxe, docp TSRMLS_CC);
- sxe->nsmapptr = emalloc(sizeof(simplexml_nsmap));
- sxe->nsmapptr->nsmap = xmlHashCreate(10);
- sxe->nsmapptr->refcount = 1;
php_libxml_increment_node_ptr((php_libxml_node_object *)sxe, xmlDocGetRootElement(docp), NULL TSRMLS_CC);
}
@@ -1498,9 +1414,6 @@ PHP_FUNCTION(simplexml_import_dom)
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);
- sxe->nsmapptr = emalloc(sizeof(simplexml_nsmap));
- sxe->nsmapptr->nsmap = xmlHashCreate(10);
- sxe->nsmapptr->refcount = 1;
php_libxml_increment_node_ptr((php_libxml_node_object *)sxe, nodep, NULL TSRMLS_CC);
return_value->type = IS_OBJECT;
@@ -1544,7 +1457,6 @@ ZEND_GET_MODULE(simplexml)
/* 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(register_ns, NULL, ZEND_ACC_PUBLIC)
SXE_ME(asXML, NULL, ZEND_ACC_PUBLIC)
SXE_ME(xpath, NULL, ZEND_ACC_PUBLIC)
SXE_ME(attributes, NULL, ZEND_ACC_PUBLIC)
diff --git a/ext/simplexml/tests/profile04.phpt b/ext/simplexml/tests/profile04.phpt
index 7b7245d..27714e9 100644
--- a/ext/simplexml/tests/profile04.phpt
+++ b/ext/simplexml/tests/profile04.phpt
@@ -10,7 +10,7 @@ $root = simplexml_load_string('<?xml version="1.0"?>
</root>
');
-echo $root->children('reserved')->child;
+echo $root->children('reserved-ns')->child;
echo "\n---Done---\n";
?>
--EXPECT--
diff --git a/ext/simplexml/tests/profile05.phpt b/ext/simplexml/tests/profile05.phpt
index 217ac67..f696221 100644
--- a/ext/simplexml/tests/profile05.phpt
+++ b/ext/simplexml/tests/profile05.phpt
@@ -11,12 +11,8 @@ $root = simplexml_load_string('<?xml version="1.0"?>
</root>
');
-$root->register_ns('myns', 'reserved-ns');
-
-echo $root->children('myns')->child;
echo $root->children('reserved')->child;
echo "\n---Done---\n";
?>
--EXPECT--
-Hello
---Done---
diff --git a/ext/simplexml/tests/profile06.phpt b/ext/simplexml/tests/profile06.phpt
index 16d5220..e519fa9 100644
--- a/ext/simplexml/tests/profile06.phpt
+++ b/ext/simplexml/tests/profile06.phpt
@@ -11,7 +11,7 @@ $root = simplexml_load_string('<?xml version="1.0"?>
</root>
');
-$attr = $root->child->attributes('reserved');
+$attr = $root->child->attributes('reserved-ns');
echo $attr['attribute'];
echo "\n---Done---\n";
?>
diff --git a/ext/simplexml/tests/profile07.phpt b/ext/simplexml/tests/profile07.phpt
index 9972f79..c8a4269 100644
--- a/ext/simplexml/tests/profile07.phpt
+++ b/ext/simplexml/tests/profile07.phpt
@@ -11,10 +11,8 @@ $root = simplexml_load_string('<?xml version="1.0"?>
</root>
');
-$root->register_ns('myns', 'reserved-ns');
-
$rsattr = $root->child->attributes('reserved');
-$myattr = $root->child->attributes('myns');
+$myattr = $root->child->attributes('reserved-ns');
echo $rsattr['attribute'];
echo $myattr['attribute'];
diff --git a/ext/simplexml/tests/profile10.phpt b/ext/simplexml/tests/profile10.phpt
index 4c62aef..c2652c6 100644
--- a/ext/simplexml/tests/profile10.phpt
+++ b/ext/simplexml/tests/profile10.phpt
@@ -11,8 +11,8 @@ $root = simplexml_load_string('<?xml version="1.0"?>
</root>
');
-$rsattr = $root->child->attributes('reserved');
-$spattr = $root->child->attributes('special');
+$rsattr = $root->child->attributes('reserved-ns');
+$spattr = $root->child->attributes('special-ns');
echo $rsattr['attribute'];
echo "\n";