diff options
author | Dmitry Stogov <dmitry@php.net> | 2004-01-14 16:24:09 +0000 |
---|---|---|
committer | Dmitry Stogov <dmitry@php.net> | 2004-01-14 16:24:09 +0000 |
commit | 49b698c67ed0f8408c54d0754672e552376b7554 (patch) | |
tree | e0bcefe36cb1496ee4b9b81bfe5b4e13262cdc03 /ext/soap/php_sdl.c | |
parent | 51cbc1f84fbe2b6e762e527608e62835f2baa753 (diff) | |
download | php-git-49b698c67ed0f8408c54d0754672e552376b7554.tar.gz |
WSDL: restrictions support (whiteSpace, minLength, maxLength, length)
Diffstat (limited to 'ext/soap/php_sdl.c')
-rw-r--r-- | ext/soap/php_sdl.c | 48 |
1 files changed, 43 insertions, 5 deletions
diff --git a/ext/soap/php_sdl.c b/ext/soap/php_sdl.c index 1a6a688336..1e41f45ea2 100644 --- a/ext/soap/php_sdl.c +++ b/ext/soap/php_sdl.c @@ -120,6 +120,34 @@ zval *sdl_guess_convert_zval(encodeType enc, xmlNodePtr data) sdlTypePtr type; type = enc.sdl_type; + + if (type && type->restrictions && + data && data->children && data->children->content) { + if (type->restrictions->whiteSpace && type->restrictions->whiteSpace->value) { + if (strcmp(type->restrictions->whiteSpace->value,"replace") == 0) { + whiteSpace_replace(data->children->content); + } else if (strcmp(type->restrictions->whiteSpace->value,"collapse") == 0) { + whiteSpace_collapse(data->children->content); + } + } + if (type->restrictions->enumeration) { + if (!zend_hash_exists(type->restrictions->enumeration,data->children->content,strlen(data->children->content)+1)) { + php_error(E_WARNING,"Restriction: invalid enumeration value \"%s\"",data->children->content); + } + } + if (type->restrictions->minLength && + strlen(data->children->content) < type->restrictions->minLength->value) { + php_error(E_WARNING,"Restriction: length less then 'minLength'"); + } + if (type->restrictions->maxLength && + strlen(data->children->content) > type->restrictions->maxLength->value) { + php_error(E_WARNING,"Restriction: length greater then 'maxLength'"); + } + if (type->restrictions->length && + strlen(data->children->content) != type->restrictions->length->value) { + php_error(E_WARNING,"Restriction: length is not equal to 'length'"); + } + } if (type->encode) { if (type->encode->details.type == IS_ARRAY || type->encode->details.type == SOAP_ENC_ARRAY) { @@ -149,14 +177,24 @@ xmlNodePtr sdl_guess_convert_xml(encodeType enc, zval *data, int style) type = enc.sdl_type; - if (type->restrictions) { + if (type && type->restrictions && Z_TYPE_P(data) == IS_STRING) { if (type->restrictions->enumeration) { - if (Z_TYPE_P(data) == IS_STRING) { - if (!zend_hash_exists(type->restrictions->enumeration,Z_STRVAL_P(data),Z_STRLEN_P(data)+1)) { - php_error(E_WARNING,"Restriction: invalid enumeration value \"%s\".",Z_STRVAL_P(data)); - } + if (!zend_hash_exists(type->restrictions->enumeration,Z_STRVAL_P(data),Z_STRLEN_P(data)+1)) { + php_error(E_WARNING,"Restriction: invalid enumeration value \"%s\".",Z_STRVAL_P(data)); } } + if (type->restrictions->minLength && + Z_STRLEN_P(data) < type->restrictions->minLength->value) { + php_error(E_WARNING,"Restriction: length less then 'minLength'"); + } + if (type->restrictions->maxLength && + Z_STRLEN_P(data) > type->restrictions->maxLength->value) { + php_error(E_WARNING,"Restriction: length greater then 'maxLength'"); + } + if (type->restrictions->length && + Z_STRLEN_P(data) != type->restrictions->length->value) { + php_error(E_WARNING,"Restriction: length is not equal to 'length'"); + } } if (type->encode) { |