axis2_bool_t axis2_json_element_is_nil(axiom_element_t* om_element, const axutil_env_t* env) { axiom_attribute_t* attr = NULL; axutil_hash_index_t* index; axutil_hash_t* attr_hash = axiom_element_get_all_attributes(om_element, env); if (!attr_hash) return AXIS2_FALSE; for (index = axutil_hash_first(attr_hash, env); index; index = axutil_hash_next(env, index)) { axutil_hash_this(index, NULL, NULL, (void**)&attr); if (attr && !strcmp(axiom_attribute_get_localname(attr, env), "nil")) { /* found some "nil" attribute, check it namespace */ axutil_qname_t* qname = axiom_attribute_get_qname(attr, env); if (qname && !strcmp(axutil_qname_get_uri(qname, env), AXIS2_JSON_XSI_URI)) { axis2_char_t* attr_value = axiom_attribute_get_value(attr, env); return (!strcmp(attr_value, "true") || !strcmp(attr_value, "1")) ? AXIS2_TRUE : AXIS2_FALSE; } } } return AXIS2_FALSE; }
/** * Auxiliary function to determine an ADB object type from its Axiom node. * @param env pointer to environment struct * @param node double pointer to the parent node to deserialize * @return type name on success, else NULL */ axis2_char_t *AXIS2_CALL axis2_extension_mapper_type_from_node( const axutil_env_t *env, axiom_node_t** node) { axiom_node_t *parent = *node; axutil_qname_t *element_qname = NULL; axiom_element_t *element = NULL; axutil_hash_index_t *hi; void *val; axiom_attribute_t *type_attr; axutil_hash_t *ht; axis2_char_t *temp; axis2_char_t *type; while(parent && axiom_node_get_node_type(parent, env) != AXIOM_ELEMENT) { parent = axiom_node_get_next_sibling(parent, env); } if (NULL == parent) { /* This should be checked before everything */ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Failed in building adb object : " "NULL elemenet can not be passed to deserialize"); return AXIS2_FAILURE; } element = (axiom_element_t *)axiom_node_get_data_element(parent, env); ht = axiom_element_get_all_attributes(element, env); if (ht == NULL) return NULL; for (hi = axutil_hash_first(ht, env); hi; hi = axutil_hash_next(env, hi)) { axis2_char_t *localpart; axutil_hash_this(hi, NULL, NULL, &val); type_attr = (axiom_attribute_t *)val; localpart = axutil_qname_get_localpart(axiom_attribute_get_qname(type_attr, env), env); if (axutil_strcmp(localpart, "type") == 0) break; } type = axiom_attribute_get_value(type_attr, env); if (type != NULL && (temp = axutil_strchr(type, ':')) != NULL) { if (axutil_strchr(temp, ':') != NULL) type = temp + 1; /* Pointer arithmetic */ } return type; }