}
}
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);
}
/* 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);
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) {
}
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"))) {
break;
}
parent = parent->parent;
- }
- if(parent == NULL) {
+ }
+ if (parent == NULL) {
newAttr->form = XSD_FORM_UNQUALIFIED;
}
}
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 {
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;
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];
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) {
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;
char *def;
char *fixed;
char *ref;
+ sdlForm form;
};
struct _sdlParam {
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;
--- /dev/null
+--TEST--
+SOAP XML Schema 75: Attributes form qualified/unqualified (attributeFormDefault="qualified")
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+include "test_schema.inc";
+$schema = <<<EOF
+ <complexType name="testType">
+ <attribute name="int1" type="int"/>
+ <attribute name="int2" type="int" form="qualified"/>
+ <attribute name="int3" type="int" form="unqualified"/>
+ </complexType>
+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--
+<?xml version="1.0" encoding="UTF-8"?>
+<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://test-uri/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><SOAP-ENV:Body><ns1:test><testParam ns1:int1="1" ns1:int2="2" int3="3" xsi:type="ns1:testType"/></ns1:test></SOAP-ENV:Body></SOAP-ENV:Envelope>
+object(stdClass)#5 (3) {
+ ["int1"]=>
+ int(1)
+ ["int2"]=>
+ int(2)
+ ["int3"]=>
+ int(3)
+}
+ok
--- /dev/null
+--TEST--
+SOAP XML Schema 76: Attributes form qualified/unqualified (attributeFormDefault="unqualified")
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+include "test_schema.inc";
+$schema = <<<EOF
+ <complexType name="testType">
+ <attribute name="int1" type="int"/>
+ <attribute name="int2" type="int" form="qualified"/>
+ <attribute name="int3" type="int" form="unqualified"/>
+ </complexType>
+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--
+<?xml version="1.0" encoding="UTF-8"?>
+<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://test-uri/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><SOAP-ENV:Body><ns1:test><testParam int1="1" ns1:int2="2" int3="3" xsi:type="ns1:testType"/></ns1:test></SOAP-ENV:Body></SOAP-ENV:Envelope>
+object(stdClass)#5 (3) {
+ ["int1"]=>
+ int(1)
+ ["int2"]=>
+ int(2)
+ ["int3"]=>
+ int(3)
+}
+ok
--- /dev/null
+--TEST--
+SOAP XML Schema 77: Attributes form qualified/unqualified (attributeFormDefault - default)
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+include "test_schema.inc";
+$schema = <<<EOF
+ <complexType name="testType">
+ <attribute name="int1" type="int"/>
+ <attribute name="int2" type="int" form="qualified"/>
+ <attribute name="int3" type="int" form="unqualified"/>
+ </complexType>
+EOF;
+
+test_schema($schema,'type="tns:testType"',(object)array("int1"=>1.1,"int2"=>2.2,"int3"=>3.3), "rpc", "encoded");
+echo "ok";
+?>
+--EXPECTF--
+<?xml version="1.0" encoding="UTF-8"?>
+<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://test-uri/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><SOAP-ENV:Body><ns1:test><testParam int1="1" ns1:int2="2" int3="3" xsi:type="ns1:testType"/></ns1:test></SOAP-ENV:Body></SOAP-ENV:Envelope>
+object(stdClass)#5 (3) {
+ ["int1"]=>
+ int(1)
+ ["int2"]=>
+ int(2)
+ ["int3"]=>
+ int(3)
+}
+ok
--- /dev/null
+--TEST--
+SOAP XML Schema 78: Element form qualified/unqualified (elementFormDefault="qualified")
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+include "test_schema.inc";
+$schema = <<<EOF
+ <complexType name="testType">
+ <sequence>
+ <element name="int1" type="int"/>
+ <element name="int2" type="int" form="qualified"/>
+ <element name="int3" type="int" form="unqualified"/>
+ </sequence>
+ </complexType>
+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--
+<?xml version="1.0" encoding="UTF-8"?>
+<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://test-uri/"><SOAP-ENV:Body><ns1:test><testParam><ns1:int1>1</ns1:int1><ns1:int2>2</ns1:int2><int3>3</int3></testParam></ns1:test></SOAP-ENV:Body></SOAP-ENV:Envelope>
+object(stdClass)#5 (3) {
+ ["int1"]=>
+ int(1)
+ ["int2"]=>
+ int(2)
+ ["int3"]=>
+ int(3)
+}
+ok
--- /dev/null
+--TEST--
+SOAP XML Schema 79: Element form qualified/unqualified (elementFormDefault="unqualified")
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+include "test_schema.inc";
+$schema = <<<EOF
+ <complexType name="testType">
+ <sequence>
+ <element name="int1" type="int"/>
+ <element name="int2" type="int" form="qualified"/>
+ <element name="int3" type="int" form="unqualified"/>
+ </sequence>
+ </complexType>
+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--
+<?xml version="1.0" encoding="UTF-8"?>
+<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://test-uri/"><SOAP-ENV:Body><ns1:test><testParam><int1>1</int1><ns1:int2>2</ns1:int2><int3>3</int3></testParam></ns1:test></SOAP-ENV:Body></SOAP-ENV:Envelope>
+object(stdClass)#5 (3) {
+ ["int1"]=>
+ int(1)
+ ["int2"]=>
+ int(2)
+ ["int3"]=>
+ int(3)
+}
+ok
--- /dev/null
+--TEST--
+SOAP XML Schema 80: Element form qualified/unqualified (elementFormDefault - default)
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+include "test_schema.inc";
+$schema = <<<EOF
+ <complexType name="testType">
+ <sequence>
+ <element name="int1" type="int"/>
+ <element name="int2" type="int" form="qualified"/>
+ <element name="int3" type="int" form="unqualified"/>
+ </sequence>
+ </complexType>
+EOF;
+
+test_schema($schema,'type="tns:testType"',(object)array("int1"=>1.1,"int2"=>2.2,"int3"=>3.3), "rpc", "literal");
+echo "ok";
+?>
+--EXPECTF--
+<?xml version="1.0" encoding="UTF-8"?>
+<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://test-uri/"><SOAP-ENV:Body><ns1:test><testParam><int1>1</int1><ns1:int2>2</ns1:int2><int3>3</int3></testParam></ns1:test></SOAP-ENV:Body></SOAP-ENV:Envelope>
+object(stdClass)#5 (3) {
+ ["int1"]=>
+ int(1)
+ ["int2"]=>
+ int(2)
+ ["int3"]=>
+ int(3)
+}
+ok