IXML_Node* xmldb_getMetaVariable(IXML_Element* obj, const char* name)
{
    IXML_Element* metaInfo = xmldb_getMetaInfo(obj);
    if (metaInfo == NULL)
    {
        return NULL;
    }

    // iterate through all meta tags until we find corresponding name
    IXML_Node* metaNode = ixmlNode_getFirstChild(ixmlElement_getNode(metaInfo));

    for (; metaNode != NULL; metaNode = ixmlNode_getNextSibling(metaNode))
    {
        IXML_Element* metaElement = ixmlNode_convertToElement(metaNode);
        if (metaElement == NULL)
        {
            // this piece of meta data is not an element - ignore it
            continue;
        }

        if (strcmp(ixmlElement_getTagName(metaElement), name) == 0)
        {
            return ixmlAttr_getNode(
                       ixmlElement_getAttributeNode(metaElement, OBIX_ATTR_VAL));
        }
    }

    // no meta tag with such name found
    return NULL;
}
int xmldb_changeMetaVariable(IXML_Node* meta, const char* newValue)
{
    int error = ixmlNode_setNodeValue(meta, newValue);
    if (error != IXML_SUCCESS)
    {
        const char* metaName =
            ixmlElement_getTagName(ixmlAttr_getOwnerElement(
                                       ixmlNode_convertToAttr(meta)));
        log_error("Unable to change value of meta attribute \"%s\" to \"%s\":"
                  "ixmlNode_setNodeValue returned %d.",
                  metaName, newValue, error);
        return -1;
    }
    return 0;
}
Exemple #3
0
const DOMString rtpxmlElement_getTagName(RTPXML_Element* element)
{
	return ixmlElement_getTagName((IXML_Element *)element);
}
Exemple #4
0
int L_getTagName(lua_State *L)
{
	lua_pushstring(L, ixmlElement_getTagName(checkelement(L, 1)));
	return 1;
}
/**
 * Helper function for #getNodeByHref(IXML_Document*,const char*).
 *
 * @param checked specifies number of symbols from href which are already
 * checked (and match) in parent node.
 */
static IXML_Node* getNodeByHrefRecursive(IXML_Node* node, const char* href,
        int checked, int* slashFlag)
{
    if (node == NULL)
    {
        //recursion exit point
        return NULL;
    }

    IXML_Node* match = NULL;
    IXML_Element* element = ixmlNode_convertToElement(node);
    int compareResult = 0;
    // ignore all nodes which are not tags, are reference tags
    // or do not have 'href' attribute
    if (element != NULL)
    {
        const char* currentUri =
            ixmlElement_getAttribute(element, OBIX_ATTR_HREF);
        if ((strcmp(ixmlElement_getTagName(element), OBIX_OBJ_REF) != 0)
                && (currentUri != NULL))
        {
            compareResult = compare_uri(currentUri, href, checked, slashFlag);
            if (compareResult == 0)
            {
                // we found the required node
                return node;
            }
        }
    }

    // check children
    // note that compareResult == 0 means that URI's
    // were not compared at all
    if (compareResult == 0)
    {
        match = getNodeByHrefRecursive(ixmlNode_getFirstChild(node),
                                       href,
                                       checked,
                                       slashFlag);
    }
    else if (compareResult > 0)
    {
        // we found part of the uri on this step
        // continue search in children the remaining address
        match = getNodeByHrefRecursive(ixmlNode_getFirstChild(node),
                                       href,
                                       compareResult,
                                       slashFlag);
    }
    // do not check children if compareResult < 0

    if (match == NULL)
    {
        match = getNodeByHrefRecursive(ixmlNode_getNextSibling(node),
                                       href,
                                       checked,
                                       slashFlag);
    }

    return match;
}