Back to index

php5  5.3.10
Functions
php_schema.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

int load_schema (sdlCtx *ctx, xmlNodePtr schema TSRMLS_DC)
void schema_pass2 (sdlCtx *ctx)
void delete_model (void *handle)
void delete_model_persistent (void *handle)
void delete_type (void *data)
void delete_type_persistent (void *data)
void delete_extra_attribute (void *attribute)
void delete_extra_attribute_persistent (void *attribute)
void delete_attribute (void *attribute)
void delete_attribute_persistent (void *attribute)
void delete_restriction_var_int (void *rvi)
void delete_restriction_var_int_persistent (void *rvi)
void delete_restriction_var_char (void *srvc)
void delete_restriction_var_char_persistent (void *srvc)

Function Documentation

void delete_attribute ( void *  attribute)

Definition at line 2461 of file php_schema.c.

{
       sdlAttributePtr attr = *((sdlAttributePtr*)attribute);

       if (attr->def) {
              efree(attr->def);
       }
       if (attr->fixed) {
              efree(attr->fixed);
       }
       if (attr->name) {
              efree(attr->name);
       }
       if (attr->namens) {
              efree(attr->namens);
       }
       if (attr->ref) {
              efree(attr->ref);
       }
       if (attr->extraAttributes) {
              zend_hash_destroy(attr->extraAttributes);
              efree(attr->extraAttributes);
       }
       efree(attr);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void delete_attribute_persistent ( void *  attribute)

Definition at line 2487 of file php_schema.c.

{
       sdlAttributePtr attr = *((sdlAttributePtr*)attribute);

       if (attr->def) {
              free(attr->def);
       }
       if (attr->fixed) {
              free(attr->fixed);
       }
       if (attr->name) {
              free(attr->name);
       }
       if (attr->namens) {
              free(attr->namens);
       }
       if (attr->ref) {
              free(attr->ref);
       }
       if (attr->extraAttributes) {
              zend_hash_destroy(attr->extraAttributes);
              free(attr->extraAttributes);
       }
       free(attr);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void delete_extra_attribute ( void *  attribute)

Definition at line 2435 of file php_schema.c.

{
       sdlExtraAttributePtr attr = *((sdlExtraAttributePtr*)attribute);

       if (attr->ns) {
              efree(attr->ns);
       }
       if (attr->val) {
              efree(attr->val);
       }
       efree(attr);
}

Here is the caller graph for this function:

void delete_extra_attribute_persistent ( void *  attribute)

Definition at line 2448 of file php_schema.c.

{
       sdlExtraAttributePtr attr = *((sdlExtraAttributePtr*)attribute);

       if (attr->ns) {
              free(attr->ns);
       }
       if (attr->val) {
              free(attr->val);
       }
       free(attr);
}

Here is the caller graph for this function:

void delete_model ( void *  handle)

Definition at line 2296 of file php_schema.c.

{
       sdlContentModelPtr tmp = *((sdlContentModelPtr*)handle);
       switch (tmp->kind) {
              case XSD_CONTENT_ELEMENT:
              case XSD_CONTENT_GROUP:
                     break;
              case XSD_CONTENT_SEQUENCE:
              case XSD_CONTENT_ALL:
              case XSD_CONTENT_CHOICE:
                     zend_hash_destroy(tmp->u.content);
                     efree(tmp->u.content);
                     break;
              case XSD_CONTENT_GROUP_REF:
                     efree(tmp->u.group_ref);
                     break;
              default:
                     break;
       }
       efree(tmp);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void delete_model_persistent ( void *  handle)

Definition at line 2318 of file php_schema.c.

{
       sdlContentModelPtr tmp = *((sdlContentModelPtr*)handle);
       switch (tmp->kind) {
              case XSD_CONTENT_ELEMENT:
              case XSD_CONTENT_GROUP:
                     break;
              case XSD_CONTENT_SEQUENCE:
              case XSD_CONTENT_ALL:
              case XSD_CONTENT_CHOICE:
                     zend_hash_destroy(tmp->u.content);
                     free(tmp->u.content);
                     break;
              case XSD_CONTENT_GROUP_REF:
                     free(tmp->u.group_ref);
                     break;
              default:
                     break;
       }
       free(tmp);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void delete_restriction_var_char ( void *  srvc)

Definition at line 2529 of file php_schema.c.

{
       sdlRestrictionCharPtr ptr = *((sdlRestrictionCharPtr*)srvc);
       if (ptr) {
              if (ptr->value) {
                     efree(ptr->value);
              }
              efree(ptr);
       }
}

Here is the caller graph for this function:

Definition at line 2540 of file php_schema.c.

{
       sdlRestrictionCharPtr ptr = *((sdlRestrictionCharPtr*)srvc);
       if (ptr) {
              if (ptr->value) {
                     free(ptr->value);
              }
              free(ptr);
       }
}

Here is the caller graph for this function:

void delete_restriction_var_int ( void *  rvi)

Definition at line 2513 of file php_schema.c.

{
       sdlRestrictionIntPtr ptr = *((sdlRestrictionIntPtr*)rvi);
       if (ptr) {
              efree(ptr);
       }
}

Here is the caller graph for this function:

Definition at line 2521 of file php_schema.c.

{
       sdlRestrictionIntPtr ptr = *((sdlRestrictionIntPtr*)rvi);
       if (ptr) {
              free(ptr);
       }
}

Here is the caller graph for this function:

void delete_type ( void *  data)

Definition at line 2340 of file php_schema.c.

{
       sdlTypePtr type = *((sdlTypePtr*)data);

       if (type->name) {
              efree(type->name);
       }
       if (type->namens) {
              efree(type->namens);
       }
       if (type->def) {
              efree(type->def);
       }
       if (type->fixed) {
              efree(type->fixed);
       }
       if (type->elements) {
              zend_hash_destroy(type->elements);
              efree(type->elements);
       }
       if (type->attributes) {
              zend_hash_destroy(type->attributes);
              efree(type->attributes);
       }
       if (type->model) {
              delete_model((void**)&type->model);
       }
       if (type->restrictions) {
              delete_restriction_var_int(&type->restrictions->minExclusive);
              delete_restriction_var_int(&type->restrictions->minInclusive);
              delete_restriction_var_int(&type->restrictions->maxExclusive);
              delete_restriction_var_int(&type->restrictions->maxInclusive);
              delete_restriction_var_int(&type->restrictions->totalDigits);
              delete_restriction_var_int(&type->restrictions->fractionDigits);
              delete_restriction_var_int(&type->restrictions->length);
              delete_restriction_var_int(&type->restrictions->minLength);
              delete_restriction_var_int(&type->restrictions->maxLength);
              delete_restriction_var_char(&type->restrictions->whiteSpace);
              delete_restriction_var_char(&type->restrictions->pattern);
              if (type->restrictions->enumeration) {
                     zend_hash_destroy(type->restrictions->enumeration);
                     efree(type->restrictions->enumeration);
              }
              efree(type->restrictions);
       }
       efree(type);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void delete_type_persistent ( void *  data)

Definition at line 2388 of file php_schema.c.

{
       sdlTypePtr type = *((sdlTypePtr*)data);
       if (type->name) {
              free(type->name);
       }
       if (type->namens) {
              free(type->namens);
       }
       if (type->def) {
              free(type->def);
       }
       if (type->fixed) {
              free(type->fixed);
       }
       if (type->elements) {
              zend_hash_destroy(type->elements);
              free(type->elements);
       }
       if (type->attributes) {
              zend_hash_destroy(type->attributes);
              free(type->attributes);
       }
       if (type->model) {
              delete_model_persistent((void**)&type->model);
       }
       if (type->restrictions) {
              delete_restriction_var_int_persistent(&type->restrictions->minExclusive);
              delete_restriction_var_int_persistent(&type->restrictions->minInclusive);
              delete_restriction_var_int_persistent(&type->restrictions->maxExclusive);
              delete_restriction_var_int_persistent(&type->restrictions->maxInclusive);
              delete_restriction_var_int_persistent(&type->restrictions->totalDigits);
              delete_restriction_var_int_persistent(&type->restrictions->fractionDigits);
              delete_restriction_var_int_persistent(&type->restrictions->length);
              delete_restriction_var_int_persistent(&type->restrictions->minLength);
              delete_restriction_var_int_persistent(&type->restrictions->maxLength);
              delete_restriction_var_char_persistent(&type->restrictions->whiteSpace);
              delete_restriction_var_char_persistent(&type->restrictions->pattern);
              if (type->restrictions->enumeration) {
                     zend_hash_destroy(type->restrictions->enumeration);
                     free(type->restrictions->enumeration);
              }
              free(type->restrictions);
       }
       free(type);
}

Here is the call graph for this function:

Here is the caller graph for this function:

int load_schema ( sdlCtx ctx,
xmlNodePtr schema  TSRMLS_DC 
)

Definition at line 163 of file php_schema.c.

{
       xmlNodePtr trav;
       xmlAttrPtr tns;

       if (!ctx->sdl->types) {
              ctx->sdl->types = emalloc(sizeof(HashTable));
              zend_hash_init(ctx->sdl->types, 0, NULL, delete_type, 0);
       }
       if (!ctx->attributes) {
              ctx->attributes = emalloc(sizeof(HashTable));
              zend_hash_init(ctx->attributes, 0, NULL, delete_attribute, 0);
       }
       if (!ctx->attributeGroups) {
              ctx->attributeGroups = emalloc(sizeof(HashTable));
              zend_hash_init(ctx->attributeGroups, 0, NULL, delete_type, 0);
       }

       tns = get_attribute(schema->properties, "targetNamespace");
       if (tns == NULL) {
              tns = xmlSetProp(schema, BAD_CAST("targetNamespace"), BAD_CAST(""));
              xmlNewNs(schema, BAD_CAST(""), NULL);
       }

       trav = schema->children;
       while (trav != NULL) {
              if (node_is_equal(trav,"include")) {
                     xmlAttrPtr location;

                     location = get_attribute(trav->properties, "schemaLocation");
                     if (location == NULL) {
                            soap_error0(E_ERROR, "Parsing Schema: include has no 'schemaLocation' attribute");
                     } else {
                            xmlChar *uri;
                            xmlChar *base = xmlNodeGetBase(trav->doc, trav);

                            if (base == NULL) {
                         uri = xmlBuildURI(location->children->content, trav->doc->URL);
                            } else {
                     uri = xmlBuildURI(location->children->content, base);
                         xmlFree(base);
                            }
                            schema_load_file(ctx, NULL, uri, tns, 0 TSRMLS_CC);
                            xmlFree(uri);
                     }

              } else if (node_is_equal(trav,"redefine")) {
                     xmlAttrPtr location;

                     location = get_attribute(trav->properties, "schemaLocation");
                     if (location == NULL) {
                            soap_error0(E_ERROR, "Parsing Schema: redefine has no 'schemaLocation' attribute");
                     } else {
                       xmlChar *uri;
                            xmlChar *base = xmlNodeGetBase(trav->doc, trav);

                            if (base == NULL) {
                         uri = xmlBuildURI(location->children->content, trav->doc->URL);
                            } else {
                     uri = xmlBuildURI(location->children->content, base);
                         xmlFree(base);
                            }
                            schema_load_file(ctx, NULL, uri, tns, 0 TSRMLS_CC);
                            xmlFree(uri);
                            /* TODO: <redefine> support */
                     }

              } else if (node_is_equal(trav,"import")) {
                     xmlAttrPtr ns, location;
                     xmlChar *uri = NULL;

                     ns = get_attribute(trav->properties, "namespace");
                     location = get_attribute(trav->properties, "schemaLocation");

                     if (ns != NULL && tns != NULL && xmlStrcmp(ns->children->content, tns->children->content) == 0) {
                            if (location) {
                                   soap_error1(E_ERROR, "Parsing Schema: can't import schema from '%s', namespace must not match the enclosing schema 'targetNamespace'", location->children->content);
                            } else {
                                   soap_error0(E_ERROR, "Parsing Schema: can't import schema. Namespace must not match the enclosing schema 'targetNamespace'");
                            }
                     }
                     if (location) {
                            xmlChar *base = xmlNodeGetBase(trav->doc, trav);

                            if (base == NULL) {
                         uri = xmlBuildURI(location->children->content, trav->doc->URL);
                            } else {
                     uri = xmlBuildURI(location->children->content, base);
                         xmlFree(base);
                            }
                     }
                     schema_load_file(ctx, ns, uri, tns, 1 TSRMLS_CC);
                     if (uri != NULL) {xmlFree(uri);}
              } else if (node_is_equal(trav,"annotation")) {
                     /* TODO: <annotation> support */
/* annotation cleanup
                     xmlNodePtr tmp = trav;
                     trav = trav->next;
                     xmlUnlinkNode(tmp);
                     xmlFreeNode(tmp);
                     continue;
*/
              } else {
                     break;
              }
              trav = trav->next;
       }

       while (trav != NULL) {
              if (node_is_equal(trav,"simpleType")) {
                     schema_simpleType(ctx->sdl, tns, trav, NULL);
              } else if (node_is_equal(trav,"complexType")) {
                     schema_complexType(ctx->sdl, tns, trav, NULL);
              } else if (node_is_equal(trav,"group")) {
                     schema_group(ctx->sdl, tns, trav, NULL, NULL);
              } else if (node_is_equal(trav,"attributeGroup")) {
                     schema_attributeGroup(ctx->sdl, tns, trav, NULL, ctx);
              } else if (node_is_equal(trav,"element")) {
                     schema_element(ctx->sdl, tns, trav, NULL, NULL);
              } else if (node_is_equal(trav,"attribute")) {
                     schema_attribute(ctx->sdl, tns, trav, NULL, ctx);
              } else if (node_is_equal(trav,"notation")) {
                     /* TODO: <notation> support */
              } else if (node_is_equal(trav,"annotation")) {
                     /* TODO: <annotation> support */
              } else {
                     soap_error1(E_ERROR, "Parsing Schema: unexpected <%s> in schema", trav->name);
              }
              trav = trav->next;
       }
       return TRUE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void schema_pass2 ( sdlCtx ctx)

Definition at line 2245 of file php_schema.c.

{
       sdlPtr sdl = ctx->sdl;
       sdlAttributePtr *attr;
       sdlTypePtr *type;

       if (ctx->attributes) {
              zend_hash_internal_pointer_reset(ctx->attributes);
              while (zend_hash_get_current_data(ctx->attributes,(void**)&attr) == SUCCESS) {
                     schema_attribute_fixup(ctx,*attr);
                     zend_hash_move_forward(ctx->attributes);
              }
       }
       if (ctx->attributeGroups) {
              zend_hash_internal_pointer_reset(ctx->attributeGroups);
              while (zend_hash_get_current_data(ctx->attributeGroups,(void**)&type) == SUCCESS) {
                     schema_type_fixup(ctx,*type);
                     zend_hash_move_forward(ctx->attributeGroups);
              }
       }
       if (sdl->elements) {
              zend_hash_internal_pointer_reset(sdl->elements);
              while (zend_hash_get_current_data(sdl->elements,(void**)&type) == SUCCESS) {
                     schema_type_fixup(ctx,*type);
                     zend_hash_move_forward(sdl->elements);
              }
       }
       if (sdl->groups) {
              zend_hash_internal_pointer_reset(sdl->groups);
              while (zend_hash_get_current_data(sdl->groups,(void**)&type) == SUCCESS) {
                     schema_type_fixup(ctx,*type);
                     zend_hash_move_forward(sdl->groups);
              }
       }
       if (sdl->types) {
              zend_hash_internal_pointer_reset(sdl->types);
              while (zend_hash_get_current_data(sdl->types,(void**)&type) == SUCCESS) {
                     schema_type_fixup(ctx,*type);
                     zend_hash_move_forward(sdl->types);
              }
       }
       if (ctx->attributes) {
              zend_hash_destroy(ctx->attributes);
              efree(ctx->attributes);
       }
       if (ctx->attributeGroups) {
              zend_hash_destroy(ctx->attributeGroups);
              efree(ctx->attributeGroups);
       }
}

Here is the call graph for this function:

Here is the caller graph for this function: