summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry Stogov <dmitry@php.net>2004-01-13 17:20:10 +0000
committerDmitry Stogov <dmitry@php.net>2004-01-13 17:20:10 +0000
commit86d0b7a1ed9aac48245190628fdea936a685d5de (patch)
treeaa42a40ddc42288b049b96620d151e7a86489084
parentd4deb460bdbb77b3c75ce7a6a328e3070e2aa527 (diff)
downloadphp-git-86d0b7a1ed9aac48245190628fdea936a685d5de.tar.gz
bugfix
-rw-r--r--ext/soap/php_xml.c150
1 files changed, 49 insertions, 101 deletions
diff --git a/ext/soap/php_xml.c b/ext/soap/php_xml.c
index 4ccfce4917..d609ea4d1a 100644
--- a/ext/soap/php_xml.c
+++ b/ext/soap/php_xml.c
@@ -49,20 +49,10 @@ xmlNsPtr node_find_ns(xmlNodePtr node)
int attr_is_equal_ex(xmlAttrPtr node, char *name, char *ns)
{
- if (!strcmp(node->name, name)) {
+ if (name == NULL || strcmp(node->name, name) == 0) {
if (ns) {
- xmlNsPtr nsPtr;
- if (node->ns) {
- nsPtr = node->ns;
- } else if (node->parent->ns) {
- nsPtr = node->parent->ns;
- } else {
- nsPtr = xmlSearchNs(node->doc, node->parent, NULL);
- }
- if (!strcmp(nsPtr->href, ns)) {
- return TRUE;
- }
- return FALSE;
+ xmlNsPtr nsPtr = attr_find_ns(node);
+ return (strcmp(nsPtr->href, ns) == 0);
}
return TRUE;
}
@@ -71,151 +61,109 @@ int attr_is_equal_ex(xmlAttrPtr node, char *name, char *ns)
int node_is_equal_ex(xmlNodePtr node, char *name, char *ns)
{
- if (!strcmp(node->name, name)) {
+ if (name == NULL || strcmp(node->name, name) == 0) {
if (ns) {
- xmlNsPtr nsPtr;
- if (node->ns) {
- nsPtr = node->ns;
- } else {
- nsPtr = xmlSearchNs(node->doc, node, NULL);
- }
- if (!strcmp(nsPtr->href, ns)) {
- return TRUE;
- }
- return FALSE;
+ xmlNsPtr nsPtr = node_find_ns(node);
+ return (strcmp(nsPtr->href, ns) == 0);
}
return TRUE;
}
return FALSE;
}
+
xmlAttrPtr get_attribute_ex(xmlAttrPtr node, char *name, char *ns)
{
- xmlAttrPtr trav = node;
- while (trav!=NULL) {
- if (attr_is_equal_ex(trav, name, ns)) {
- return trav;
+ while (node!=NULL) {
+ if (attr_is_equal_ex(node, name, ns)) {
+ return node;
}
- trav = trav->next;
+ node = node->next;
}
return NULL;
}
xmlNodePtr get_node_ex(xmlNodePtr node, char *name, char *ns)
{
- xmlNodePtr trav = node;
- while (trav!=NULL) {
- if (node_is_equal_ex(trav, name, ns)) {
- return trav;
+ while (node!=NULL) {
+ if (node_is_equal_ex(node, name, ns)) {
+ return node;
}
- trav = trav->next;
+ node = node->next;
}
return NULL;
}
xmlNodePtr get_node_recurisve_ex(xmlNodePtr node, char *name, char *ns)
{
- xmlNodePtr trav = node;
- while (trav != NULL) {
- if (node_is_equal_ex(trav, name, ns)) {
- return trav;
- } else {
- if (node->children != NULL) {
- xmlNodePtr tmp;
- tmp = get_node_recurisve_ex(node->children, name, ns);
- if (tmp) {
- return tmp;
- }
+ while (node != NULL) {
+ if (node_is_equal_ex(node, name, ns)) {
+ return node;
+ } else if (node->children != NULL) {
+ xmlNodePtr tmp = get_node_recurisve_ex(node->children, name, ns);
+ if (tmp) {
+ return tmp;
}
}
- trav = trav->next;
+ node = node->next;
}
return NULL;
}
xmlNodePtr get_node_with_attribute_ex(xmlNodePtr node, char *name, char *name_ns, char *attribute, char *value, char *attr_ns)
{
- xmlNodePtr trav = node, cur = NULL;
xmlAttrPtr attr;
- while (trav != NULL) {
+ while (node != NULL) {
if (name != NULL) {
- cur = get_node_ex(trav, name, name_ns);
- if (!cur) {
- return cur;
+ node = get_node_ex(node, name, name_ns);
+ if (node==NULL) {
+ return NULL;
}
- } else {
- cur = trav;
}
- attr = get_attribute_ex(cur->properties, attribute, attr_ns);
+ attr = get_attribute_ex(node->properties, attribute, attr_ns);
if (attr != NULL && strcmp(attr->children->content, value) == 0) {
- return cur;
- } else {
- if (cur->children != NULL) {
- xmlNodePtr tmp;
- tmp = get_node_with_attribute_ex(cur->children, name, name_ns, attribute, value, attr_ns);
- if (tmp) {
- return tmp;
- }
- }
+ return node;
}
- trav = trav->next;
+ node = node->next;
}
return NULL;
}
xmlNodePtr get_node_with_attribute_recursive_ex(xmlNodePtr node, char *name, char *name_ns, char *attribute, char *value, char *attr_ns)
{
- xmlNodePtr trav = node, cur;
- xmlAttrPtr attr;
-
- while (trav != NULL) {
- if (name != NULL) {
- cur = get_node_recurisve_ex(trav, name, name_ns);
- if (!cur) {
- return cur;
+ while (node != NULL) {
+ if (node_is_equal_ex(node, name, name_ns)) {
+ xmlAttrPtr attr = get_attribute_ex(node->properties, attribute, attr_ns);
+ if (attr != NULL && strcmp(attr->children->content, value) == 0) {
+ return node;
}
- } else {
- cur = trav;
}
-
- attr = get_attribute_ex(cur->properties, attribute, attr_ns);
- if (attr != NULL && strcmp(attr->children->content, value) == 0) {
- return cur;
- } else {
- if (cur->children != NULL) {
- xmlNodePtr tmp;
- tmp = get_node_with_attribute_recursive_ex(cur->children, name, name_ns, attribute, value, attr_ns);
- if (tmp) {
- return tmp;
- }
+ if (node->children != NULL) {
+ xmlNodePtr tmp = get_node_with_attribute_recursive_ex(node->children, name, name_ns, attribute, value, attr_ns);
+ if (tmp) {
+ return tmp;
}
}
- trav = trav->next;
+ node = node->next;
}
return NULL;
}
xmlNodePtr check_and_resolve_href(xmlNodePtr data)
{
- xmlAttrPtr href;
- xmlNodePtr ret = data;
-
- if (!data || !data->properties) {
- return ret;
- }
-
- href = get_attribute(data->properties, "href");
- if (href) {
- /* Internal href try and find node */
- if (href->children->content[0] == '#') {
- ret = get_node_with_attribute_recursive(data->doc->children, NULL, "id", &href->children->content[1]);
+ if (data && data->properties) {
+ xmlAttrPtr href = get_attribute(data->properties, "href");
+ if (href) {
+ /* Internal href try and find node */
+ if (href->children->content[0] == '#') {
+ return get_node_with_attribute_recursive(data->doc->children, NULL, "id", &href->children->content[1]);
+ }
+ /* TODO: External href....? */
}
- /* External href....? */
}
-
- return ret;
+ return data;
}
int parse_namespace(const char *inval, char **value, char **namespace)