From: Dmitry Stogov Date: Wed, 20 Apr 2005 08:30:43 +0000 (+0000) Subject: Support for element's form and schema's elementFormDefault attributes (qualified... X-Git-Tag: php-5.0.1b1~468 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7288226dbae36a37b8f754defda826e6e1ad577e;p=php Support for element's form and schema's elementFormDefault attributes (qualified/unqualified) --- diff --git a/ext/soap/php_encoding.c b/ext/soap/php_encoding.c index c2fdef0680..b9027ddd4e 100644 --- a/ext/soap/php_encoding.c +++ b/ext/soap/php_encoding.c @@ -1234,7 +1234,9 @@ static int model_to_xml_object(xmlNodePtr node, sdlContentModelPtr model, zval * } } xmlNodeSetName(property, model->u.element->name); - if (style == SOAP_LITERAL && model->u.element->namens) { + if (style == SOAP_LITERAL && + model->u.element->namens && + model->u.element->form == XSD_FORM_QUALIFIED) { xmlNsPtr nsp = encode_add_ns(property, model->u.element->namens); xmlSetNs(property, nsp); } @@ -1482,8 +1484,9 @@ static xmlNodePtr to_xml_object(encodeTypePtr type, zval *data, int style, xmlNo /* we need to handle xml: namespace specially, since it is an implicit schema. Otherwise, use form. */ - if ((!strncmp((*attr)->namens, XML_NAMESPACE, sizeof(XML_NAMESPACE)) || - ((*attr)->form == XSD_FORM_QUALIFIED)) && (*attr)->namens) { + if ((*attr)->namens && + (!strncmp((*attr)->namens, XML_NAMESPACE, sizeof(XML_NAMESPACE)) || + (*attr)->form == XSD_FORM_QUALIFIED)) { xmlNsPtr nsp = encode_add_ns(xmlParam, (*attr)->namens); xmlSetNsProp(xmlParam, nsp, (*attr)->name, dummy->children->content); diff --git a/ext/soap/php_schema.c b/ext/soap/php_schema.c index b0e537f348..b292a60862 100644 --- a/ext/soap/php_schema.c +++ b/ext/soap/php_schema.c @@ -1664,6 +1664,39 @@ static int schema_element(sdlPtr sdl, xmlAttrPtr tns, xmlNodePtr element, sdlTyp cur_type->def = estrdup(attr->children->content); } + /* form */ + attr = get_attribute(attrs, "form"); + if (attr) { + if (strncmp(attr->children->content,"qualified",sizeof("qualified")) == 0) { + cur_type->form = XSD_FORM_QUALIFIED; + } else if (strncmp(attr->children->content,"unqualified",sizeof("unqualified")) == 0) { + cur_type->form = XSD_FORM_UNQUALIFIED; + } else { + cur_type->form = XSD_FORM_DEFAULT; + } + } else { + cur_type->form = XSD_FORM_DEFAULT; + } + if (cur_type->form == XSD_FORM_DEFAULT) { + xmlNodePtr parent = element->parent; + while (parent) { + if (node_is_equal_ex(parent, "schema", SCHEMA_NAMESPACE)) { + xmlAttrPtr def; + def = get_attribute(parent->properties, "elementFormDefault"); + if(def == NULL || strncmp(def->children->content, "qualified", sizeof("qualified"))) { + cur_type->form = XSD_FORM_UNQUALIFIED; + } else { + cur_type->form = XSD_FORM_QUALIFIED; + } + break; + } + parent = parent->parent; + } + if (parent == NULL) { + cur_type->form = XSD_FORM_UNQUALIFIED; + } + } + /* type = QName */ type = get_attribute(attrs, "type"); if (type) { @@ -1890,10 +1923,10 @@ static int schema_attribute(sdlPtr sdl, xmlAttrPtr tns, xmlNodePtr attrType, sdl } attr = attr->next; } - if(newAttr->form == XSD_FORM_DEFAULT) { - xmlNodePtr parent = attrType->parent; - while(parent) { - if(node_is_equal_ex(parent, "schema", SCHEMA_NAMESPACE)) { + if (newAttr->form == XSD_FORM_DEFAULT) { + xmlNodePtr parent = attrType->parent; + while (parent) { + if (node_is_equal_ex(parent, "schema", SCHEMA_NAMESPACE)) { xmlAttrPtr def; def = get_attribute(parent->properties, "attributeFormDefault"); if(def == NULL || strncmp(def->children->content, "qualified", sizeof("qualified"))) { @@ -1904,8 +1937,8 @@ static int schema_attribute(sdlPtr sdl, xmlAttrPtr tns, xmlNodePtr attrType, sdl break; } parent = parent->parent; - } - if(parent == NULL) { + } + if (parent == NULL) { newAttr->form = XSD_FORM_UNQUALIFIED; } } @@ -2209,6 +2242,7 @@ static void schema_type_fixup(sdlCtx *ctx, sdlTypePtr type) if ((*tmp)->def) { type->def = estrdup((*tmp)->def); } + type->form = (*tmp)->form; } else if (strcmp(type->ref, SCHEMA_NAMESPACE ":schema") == 0) { type->encode = get_conversion(XSD_ANYXML); } else { diff --git a/ext/soap/php_sdl.c b/ext/soap/php_sdl.c index 70dd4705a1..fa736a4192 100644 --- a/ext/soap/php_sdl.c +++ b/ext/soap/php_sdl.c @@ -1065,7 +1065,7 @@ static sdlPtr load_wsdl(zval *this_ptr, char *struri TSRMLS_DC) return ctx.sdl; } -#define WSDL_CACHE_VERSION 0x0c +#define WSDL_CACHE_VERSION 0x0d #define WSDL_CACHE_GET(ret,type,buf) memcpy(&ret,*buf,sizeof(type)); *buf += sizeof(type); #define WSDL_CACHE_GET_INT(ret,buf) ret = ((unsigned char)(*buf)[0])|((unsigned char)(*buf)[1]<<8)|((unsigned char)(*buf)[2]<<16)|((int)(*buf)[3]<<24); *buf += 4; @@ -1214,6 +1214,7 @@ static void sdl_deserialize_type(sdlTypePtr type, sdlTypePtr *types, encodePtr * type->fixed = sdl_deserialize_string(in); type->ref = sdl_deserialize_string(in); WSDL_CACHE_GET_1(type->nillable, char, in); + WSDL_CACHE_GET_1(type->form, sdlForm, in); WSDL_CACHE_GET_INT(i, in); type->encode = encoders[i]; @@ -1788,6 +1789,7 @@ static void sdl_serialize_type(sdlTypePtr type, HashTable *tmp_encoders, HashTab sdl_serialize_string(type->fixed, out); sdl_serialize_string(type->ref, out); WSDL_CACHE_PUT_1(type->nillable, out); + WSDL_CACHE_PUT_1(type->form, out); sdl_serialize_encoder_ref(type->encode, tmp_encoders, out); if (type->restrictions) { diff --git a/ext/soap/php_sdl.h b/ext/soap/php_sdl.h index d2c9bfd033..63f961ab71 100644 --- a/ext/soap/php_sdl.h +++ b/ext/soap/php_sdl.h @@ -180,6 +180,19 @@ typedef enum _sdlTypeKind { XSD_TYPEKIND_EXTENSION } sdlTypeKind; +typedef enum _sdlUse { + XSD_USE_DEFAULT, + XSD_USE_OPTIONAL, + XSD_USE_PROHIBITED, + XSD_USE_REQUIRED +} sdlUse; + +typedef enum _sdlForm { + XSD_FORM_DEFAULT, + XSD_FORM_QUALIFIED, + XSD_FORM_UNQUALIFIED +} sdlForm; + struct _sdlType { sdlTypeKind kind; char *name; @@ -193,6 +206,7 @@ struct _sdlType { char *def; char *fixed; char *ref; + sdlForm form; }; struct _sdlParam { @@ -219,19 +233,6 @@ struct _sdlFunction { HashTable *faults; /* array of sdlFaultPtr */ }; -typedef enum _sdlUse { - XSD_USE_DEFAULT, - XSD_USE_OPTIONAL, - XSD_USE_PROHIBITED, - XSD_USE_REQUIRED -} sdlUse; - -typedef enum _sdlForm { - XSD_FORM_DEFAULT, - XSD_FORM_QUALIFIED, - XSD_FORM_UNQUALIFIED -} sdlForm; - typedef struct _sdlExtraAttribute { char *ns; char *val; diff --git a/ext/soap/tests/interop/Round3/GroupD/round3_groupD_doclitparams.wsdl b/ext/soap/tests/interop/Round3/GroupD/round3_groupD_doclitparams.wsdl index 8b8558de45..9ecf1e170b 100644 --- a/ext/soap/tests/interop/Round3/GroupD/round3_groupD_doclitparams.wsdl +++ b/ext/soap/tests/interop/Round3/GroupD/round3_groupD_doclitparams.wsdl @@ -11,7 +11,7 @@ + xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" elementFormDefault="qualified"> diff --git a/ext/soap/tests/interop/Round3/GroupD/round3_groupD_rpcenc.wsdl b/ext/soap/tests/interop/Round3/GroupD/round3_groupD_rpcenc.wsdl index 03568f7b3a..5e24411a37 100644 --- a/ext/soap/tests/interop/Round3/GroupD/round3_groupD_rpcenc.wsdl +++ b/ext/soap/tests/interop/Round3/GroupD/round3_groupD_rpcenc.wsdl @@ -11,7 +11,7 @@ + xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" elementFormDefault="qualified"> diff --git a/ext/soap/tests/interop/Round4/GroupH/round4_groupH_complex_doclit.wsdl b/ext/soap/tests/interop/Round4/GroupH/round4_groupH_complex_doclit.wsdl index 90a5884230..f1c383dc1d 100644 --- a/ext/soap/tests/interop/Round4/GroupH/round4_groupH_complex_doclit.wsdl +++ b/ext/soap/tests/interop/Round4/GroupH/round4_groupH_complex_doclit.wsdl @@ -10,7 +10,7 @@ targetNamespace="http://soapinterop.org/wsdl"> - @@ -62,7 +62,7 @@ - @@ -74,7 +74,7 @@ - diff --git a/ext/soap/tests/interop/Round4/GroupH/round4_groupH_complex_rpcenc.wsdl b/ext/soap/tests/interop/Round4/GroupH/round4_groupH_complex_rpcenc.wsdl index 86f58520a4..e78ca38ea5 100644 --- a/ext/soap/tests/interop/Round4/GroupH/round4_groupH_complex_rpcenc.wsdl +++ b/ext/soap/tests/interop/Round4/GroupH/round4_groupH_complex_rpcenc.wsdl @@ -8,7 +8,7 @@ targetNamespace="http://soapinterop.org/wsdl"> - - @@ -41,7 +41,7 @@ - @@ -61,7 +61,7 @@ - diff --git a/ext/soap/tests/interop/Round4/GroupH/round4_groupH_simple_rpcenc.wsdl b/ext/soap/tests/interop/Round4/GroupH/round4_groupH_simple_rpcenc.wsdl index 2eb40856f7..24f73fcb0e 100644 --- a/ext/soap/tests/interop/Round4/GroupH/round4_groupH_simple_rpcenc.wsdl +++ b/ext/soap/tests/interop/Round4/GroupH/round4_groupH_simple_rpcenc.wsdl @@ -7,7 +7,7 @@ xmlns:ns2="http://soapinterop.org/types" targetNamespace="http://soapinterop.org/wsdl"> - +--FILE-- + + + + + +EOF; + +test_schema($schema,'type="tns:testType"',(object)array("int1"=>1.1,"int2"=>2.2,"int3"=>3.3), "rpc", "encoded", 'attributeFormDefault="qualified"'); +echo "ok"; +?> +--EXPECTF-- + + +object(stdClass)#5 (3) { + ["int1"]=> + int(1) + ["int2"]=> + int(2) + ["int3"]=> + int(3) +} +ok diff --git a/ext/soap/tests/schema/schema076.phpt b/ext/soap/tests/schema/schema076.phpt new file mode 100644 index 0000000000..dfa7791fed --- /dev/null +++ b/ext/soap/tests/schema/schema076.phpt @@ -0,0 +1,30 @@ +--TEST-- +SOAP XML Schema 76: Attributes form qualified/unqualified (attributeFormDefault="unqualified") +--SKIPIF-- + +--FILE-- + + + + + +EOF; + +test_schema($schema,'type="tns:testType"',(object)array("int1"=>1.1,"int2"=>2.2,"int3"=>3.3), "rpc", "encoded", 'attributeFormDefault="unqualified"'); +echo "ok"; +?> +--EXPECTF-- + + +object(stdClass)#5 (3) { + ["int1"]=> + int(1) + ["int2"]=> + int(2) + ["int3"]=> + int(3) +} +ok diff --git a/ext/soap/tests/schema/schema077.phpt b/ext/soap/tests/schema/schema077.phpt new file mode 100644 index 0000000000..baf10449d6 --- /dev/null +++ b/ext/soap/tests/schema/schema077.phpt @@ -0,0 +1,30 @@ +--TEST-- +SOAP XML Schema 77: Attributes form qualified/unqualified (attributeFormDefault - default) +--SKIPIF-- + +--FILE-- + + + + + +EOF; + +test_schema($schema,'type="tns:testType"',(object)array("int1"=>1.1,"int2"=>2.2,"int3"=>3.3), "rpc", "encoded"); +echo "ok"; +?> +--EXPECTF-- + + +object(stdClass)#5 (3) { + ["int1"]=> + int(1) + ["int2"]=> + int(2) + ["int3"]=> + int(3) +} +ok diff --git a/ext/soap/tests/schema/schema078.phpt b/ext/soap/tests/schema/schema078.phpt new file mode 100644 index 0000000000..a674270dff --- /dev/null +++ b/ext/soap/tests/schema/schema078.phpt @@ -0,0 +1,32 @@ +--TEST-- +SOAP XML Schema 78: Element form qualified/unqualified (elementFormDefault="qualified") +--SKIPIF-- + +--FILE-- + + + + + + + +EOF; + +test_schema($schema,'type="tns:testType"',(object)array("int1"=>1.1,"int2"=>2.2,"int3"=>3.3), "rpc", "literal", 'elementFormDefault="qualified"'); +echo "ok"; +?> +--EXPECTF-- + +123 +object(stdClass)#5 (3) { + ["int1"]=> + int(1) + ["int2"]=> + int(2) + ["int3"]=> + int(3) +} +ok diff --git a/ext/soap/tests/schema/schema079.phpt b/ext/soap/tests/schema/schema079.phpt new file mode 100644 index 0000000000..d7f2ab97c6 --- /dev/null +++ b/ext/soap/tests/schema/schema079.phpt @@ -0,0 +1,32 @@ +--TEST-- +SOAP XML Schema 79: Element form qualified/unqualified (elementFormDefault="unqualified") +--SKIPIF-- + +--FILE-- + + + + + + + +EOF; + +test_schema($schema,'type="tns:testType"',(object)array("int1"=>1.1,"int2"=>2.2,"int3"=>3.3), "rpc", "literal", 'elementFormDefault="unqualified"'); +echo "ok"; +?> +--EXPECTF-- + +123 +object(stdClass)#5 (3) { + ["int1"]=> + int(1) + ["int2"]=> + int(2) + ["int3"]=> + int(3) +} +ok diff --git a/ext/soap/tests/schema/schema080.phpt b/ext/soap/tests/schema/schema080.phpt new file mode 100644 index 0000000000..4accf551f1 --- /dev/null +++ b/ext/soap/tests/schema/schema080.phpt @@ -0,0 +1,32 @@ +--TEST-- +SOAP XML Schema 80: Element form qualified/unqualified (elementFormDefault - default) +--SKIPIF-- + +--FILE-- + + + + + + + +EOF; + +test_schema($schema,'type="tns:testType"',(object)array("int1"=>1.1,"int2"=>2.2,"int3"=>3.3), "rpc", "literal"); +echo "ok"; +?> +--EXPECTF-- + +123 +object(stdClass)#5 (3) { + ["int1"]=> + int(1) + ["int2"]=> + int(2) + ["int3"]=> + int(3) +} +ok