From a68777e9545a505635f60bd881c5771e36cd4e69 Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Mon, 19 Jan 2004 07:22:53 +0000 Subject: [PATCH] XML Scheam support --- ext/soap/php_schema.c | 31 ++++++++++++++++--------------- ext/soap/php_sdl.c | 12 ++++++++---- ext/soap/php_sdl.h | 1 + ext/soap/soap.c | 6 +++++- 4 files changed, 30 insertions(+), 20 deletions(-) diff --git a/ext/soap/php_schema.c b/ext/soap/php_schema.c index 04b274bdbe..7621e1a5f3 100644 --- a/ext/soap/php_schema.c +++ b/ext/soap/php_schema.c @@ -50,6 +50,10 @@ int load_schema(sdlPtr sdl,xmlNodePtr schema) sdl->types = malloc(sizeof(HashTable)); zend_hash_init(sdl->types, 0, NULL, delete_type, 1); } + if (!sdl->elements) { + sdl->elements = malloc(sizeof(HashTable)); + zend_hash_init(sdl->elements, 0, NULL, delete_type, 1); + } tns = get_attribute(schema->properties, "targetNamespace"); @@ -866,7 +870,7 @@ static int schema_element(sdlPtr sdl, xmlAttrPtr tsn, xmlNodePtr element, sdlTyp newType->max_occurs = 1; if (cur_type == NULL) { - addHash = sdl->types; + addHash = sdl->elements; smart_str_appends(&key, newType->namens); smart_str_appendc(&key, ':'); smart_str_appends(&key, newType->name); @@ -926,17 +930,10 @@ static int schema_element(sdlPtr sdl, xmlAttrPtr tsn, xmlNodePtr element, sdlTyp xmlNsPtr nsptr; parse_namespace(curattr->children->content, &cptype, &str_ns); -/* - if (str_ns) { -*/ - nsptr = xmlSearchNs(element->doc, element, str_ns); -/* - } else { - nsptr = xmlSearchNsByHref(element->doc, element, ns->children->content); + nsptr = xmlSearchNs(element->doc, element, str_ns); + if (nsptr != NULL) { + cur_type->encode = get_create_encoder(sdl, cur_type, (char *)nsptr->href, (char *)cptype); } -*/ - - cur_type->encode = get_create_encoder(sdl, cur_type, (char *)nsptr->href, (char *)cptype); if (str_ns) {efree(str_ns);} if (cptype) {efree(cptype);} } @@ -1037,16 +1034,20 @@ static int schema_attribute(sdlPtr sdl, xmlAttrPtr tsn, xmlNodePtr attrType, sdl parse_namespace(newAttr->ref, &value, &prefix); ns = xmlSearchNs(attrType->doc, attrType, prefix); - smart_str_appends(&key, ns->href); - smart_str_appendc(&key, ':'); + if (ns != NULL) { + smart_str_appends(&key, ns->href); + smart_str_appendc(&key, ':'); + } smart_str_appends(&key, value); if (value) {efree(value);} if (prefix) {efree(prefix);} } else { ns = node_find_ns(attrType); - smart_str_appends(&key, ns->href); - smart_str_appendc(&key, ':'); + if (ns != NULL) { + smart_str_appends(&key, ns->href); + smart_str_appendc(&key, ':'); + } smart_str_appends(&key, newAttr->name); } diff --git a/ext/soap/php_sdl.c b/ext/soap/php_sdl.c index b898035898..c694f8bdd7 100644 --- a/ext/soap/php_sdl.c +++ b/ext/soap/php_sdl.c @@ -33,7 +33,7 @@ encodePtr get_encoder_from_element(sdlPtr sdl, xmlNodePtr node, const char *type encodePtr enc = NULL; TSRMLS_FETCH(); - if (sdl && sdl->types) { + if (sdl && sdl->elements) { xmlNsPtr nsptr; char *ns, *cptype; sdlTypePtr *sdl_type; @@ -48,14 +48,14 @@ encodePtr get_encoder_from_element(sdlPtr sdl, xmlNodePtr node, const char *type smart_str_appends(&nscat, cptype); smart_str_0(&nscat); - if (zend_hash_find(sdl->types, nscat.c, nscat.len + 1, (void **)&sdl_type) == SUCCESS) { + if (zend_hash_find(sdl->elements, nscat.c, nscat.len + 1, (void **)&sdl_type) == SUCCESS) { enc = (*sdl_type)->encode; - } else if (zend_hash_find(sdl->types, (char*)type, strlen(type) + 1, (void **)&sdl_type) == SUCCESS) { + } else if (zend_hash_find(sdl->elements, (char*)type, strlen(type) + 1, (void **)&sdl_type) == SUCCESS) { enc = (*sdl_type)->encode; } smart_str_free(&nscat); } else { - if (zend_hash_find(sdl->types, (char*)type, strlen(type) + 1, (void **)&sdl_type) == SUCCESS) { + if (zend_hash_find(sdl->elements, (char*)type, strlen(type) + 1, (void **)&sdl_type) == SUCCESS) { enc = (*sdl_type)->encode; } } @@ -895,6 +895,10 @@ void delete_sdl(void *handle) zend_hash_destroy(tmp->types); free(tmp->types); } + if (tmp->elements) { + zend_hash_destroy(tmp->elements); + free(tmp->elements); + } if (tmp->bindings) { zend_hash_destroy(tmp->bindings); free(tmp->bindings); diff --git a/ext/soap/php_sdl.h b/ext/soap/php_sdl.h index 9b35bd2fcf..06c0a83274 100644 --- a/ext/soap/php_sdl.h +++ b/ext/soap/php_sdl.h @@ -18,6 +18,7 @@ struct _sdl { HashTable docs; /* pointer to the parsed xml file */ HashTable functions; /* array of sdlFunction */ HashTable *types; /* array of sdlTypesPtr */ + HashTable *elements; /* array of sdlTypesPtr */ HashTable *encoders; /* array of encodePtr */ HashTable *bindings; /* array of sdlBindings (key'd by name) */ HashTable *requests; /* array of sdlFunction (references) */ diff --git a/ext/soap/soap.c b/ext/soap/soap.c index 41faae2da2..b7b060fcd7 100644 --- a/ext/soap/soap.c +++ b/ext/soap/soap.c @@ -1703,8 +1703,10 @@ zval* add_soap_fault(zval *obj, char *fault_code, char *fault_string, char *faul { zval *fault; MAKE_STD_ZVAL(fault); -// set_soap_fault(fault, fault_string, fault_code, fault_actor, fault_detail TSRMLS_CC); set_soap_fault(fault, fault_code, fault_string, fault_actor, fault_detail TSRMLS_CC); +#ifdef ZEND_ENGINE_2 + fault->refcount--; /*FIXME*/ +#endif add_property_zval(obj, "__soap_fault", fault); return fault; } @@ -2204,6 +2206,8 @@ static xmlNodePtr seralize_parameter(sdlParamPtr param, zval *param_val, int ind xmlParam = seralize_zval(param_val, param, paramName, style TSRMLS_CC); + efree(paramName); + return xmlParam; } -- 2.40.0