]> granicus.if.org Git - php/commitdiff
XML Scheam support
authorDmitry Stogov <dmitry@php.net>
Mon, 19 Jan 2004 07:22:53 +0000 (07:22 +0000)
committerDmitry Stogov <dmitry@php.net>
Mon, 19 Jan 2004 07:22:53 +0000 (07:22 +0000)
ext/soap/php_schema.c
ext/soap/php_sdl.c
ext/soap/php_sdl.h
ext/soap/soap.c

index 04b274bdbe7bfdee85c0fdc2d11506cbb0929692..7621e1a5f390de67fb033346a164be2d1bc0862a 100644 (file)
@@ -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);
                }
 
index b8980358980bceddfa5864fa3da01f179af3efab..c694f8bdd70fcda967ca3d0cf15f1d3dfe4daede 100644 (file)
@@ -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);
index 9b35bd2fcfc716b5781514c423d83679f60c2bd9..06c0a8327442397570a1613f854ac760379038e0 100644 (file)
@@ -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) */
index 41faae2da24a804e3ff2184aae1a093924d52a38..b7b060fcd722cc00d1c1c92acefb12b26466e0e0 100644 (file)
@@ -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;
 }