diff options
| author | Dmitry Stogov <dmitry@php.net> | 2004-01-30 15:07:19 +0000 | 
|---|---|---|
| committer | Dmitry Stogov <dmitry@php.net> | 2004-01-30 15:07:19 +0000 | 
| commit | b81645edd3912d6dca99d56649736a0b23056964 (patch) | |
| tree | 3db256bb236511558a7a5e2b01d804bac1cf8c9f /ext/soap/php_xml.c | |
| parent | 356e8f9b7d9495874244143e0ec490b519c1c3cf (diff) | |
| download | php-git-b81645edd3912d6dca99d56649736a0b23056964.tar.gz | |
SOAP 1.2 specification conformity was improved
Diffstat (limited to 'ext/soap/php_xml.c')
| -rw-r--r-- | ext/soap/php_xml.c | 47 | 
1 files changed, 47 insertions, 0 deletions
diff --git a/ext/soap/php_xml.c b/ext/soap/php_xml.c index f2a50b50f9..65e058c2bf 100644 --- a/ext/soap/php_xml.c +++ b/ext/soap/php_xml.c @@ -194,3 +194,50 @@ int parse_namespace(const char *inval, char **value, char **namespace)  	return FALSE;  } + +static int is_blank(const char* str) +{ +	while (*str != '\0') { +		if (*str != ' '  && *str != 0x9 && *str != 0xa && *str != 0xd) { +			return 0; +		} +		str++; +	} +	return 1; +} + +/* removes all empty text, comments and other insignoficant nodes */ +static void cleanup_xml_node(xmlNodePtr node) +{ +	xmlNodePtr trav; +	xmlNodePtr del = NULL; + +	trav = node->children; +	while (trav != NULL) { +		if (del != NULL) { +			xmlUnlinkNode(del); +			xmlFreeNode(del); +			del = NULL; +		} +		if (trav->type == XML_TEXT_NODE) { +			if (is_blank(trav->content)) { +				del = trav; +			} +		} else if ((trav->type != XML_ELEMENT_NODE) && +		           (trav->type != XML_CDATA_SECTION_NODE)) { +			del = trav; +		} else if (trav->children != NULL) { +			cleanup_xml_node(trav); +		} +		trav = trav->next; +	} +	if (del != NULL) { +		xmlUnlinkNode(del); +		xmlFreeNode(del); +	} +} + +void cleanup_xml(xmlDocPtr doc) +{ +	cleanup_xml_node((xmlNodePtr)doc); +}  | 
