Beispiel #1
0
/*================================================================
*   ixmlDocument_createElement
*       Creates an element of the type specified. 
*       External function.
*   Parameters:
*       doc:        pointer to document
*       tagName:    The name of the element, it is case-sensitive.
*   Return Value: 
*       A new element object with the nodeName set to tagName, and
*       localName, prefix and namespaceURI set to null.
*
*=================================================================*/
IXML_Element *
ixmlDocument_createElement( IN IXML_Document * doc,
                            IN DOMString tagName )
{
  IXML_Element *newElement = NULL;

  ixmlDocument_createElementEx( doc, tagName, &newElement );
  return newElement;

}
Beispiel #2
0
/*================================================================
*   ixmlDocument_createElement
*       Creates an element of the type specified.
*       External function.
*   Parameters:
*       doc:        pointer to document
*       tagName:    The name of the element, it is case-sensitive.
*   Return Value:
*       A new element object with the nodeName set to tagName, and
*       localName, prefix and namespaceURI set to null.
*
*=================================================================*/
IXML_Element *
ixmlDocument_createElement( IN IXML_Document * doc,
                            IN DOMString tagName )
{
    int errCode;
    IXML_Element *newElement = NULL;

    errCode = ixmlDocument_createElementEx( doc, tagName, &newElement );
    if(errCode == IXML_SUCCESS)
    return newElement;
    else
    return NULL;

}
Beispiel #3
0
int ixmlDocument_createElementNSEx(
	IXML_Document *doc,
	const DOMString namespaceURI,
	const DOMString qualifiedName,
	IXML_Element **rtElement)
{
	IXML_Element *newElement = NULL;
	int ret = IXML_SUCCESS;
	int line = 0;

	if (doc == NULL || namespaceURI == NULL || qualifiedName == NULL) {
		line = __LINE__;
		ret = IXML_INVALID_PARAMETER;
		goto ErrorHandler;
	}

	ret = ixmlDocument_createElementEx(doc, qualifiedName, &newElement);
	if (ret != IXML_SUCCESS) {
		line = __LINE__;
		goto ErrorHandler;
	}
	/* set the namespaceURI field */
	newElement->n.namespaceURI = _strdup(namespaceURI);
	if (newElement->n.namespaceURI == NULL) {
		line = __LINE__;
		ixmlElement_free(newElement);
		newElement = NULL;
		ret = IXML_INSUFFICIENT_MEMORY;
		goto ErrorHandler;
	}
	/* set the localName and prefix */
	ret = ixmlNode_setNodeName((IXML_Node *)newElement, qualifiedName);
	if (ret != IXML_SUCCESS) {
		line = __LINE__;
		ixmlElement_free(newElement);
		newElement = NULL;
		ret = IXML_INSUFFICIENT_MEMORY;
		goto ErrorHandler;
	}

	newElement->n.nodeValue = NULL;

ErrorHandler:
	*rtElement = newElement;
	if (ret != IXML_SUCCESS) {
		IxmlPrintf(__FILE__, line, "ixmlDocument_createElementNSEx", "Error %d\n", ret);
	}

	return ret;
}
Beispiel #4
0
IXML_Element *ixmlDocument_createElement(
	IXML_Document *doc,
	const DOMString tagName)
{
	IXML_Element *newElement = NULL;
	int ret = IXML_SUCCESS;

	ret = ixmlDocument_createElementEx(doc, tagName, &newElement);
	if (ret != IXML_SUCCESS) {
                IxmlPrintf(__FILE__, __LINE__, "ixmlDocument_createElement",
			"Error %d\n", ret);
		return NULL;
        }
	return newElement;
}
Beispiel #5
0
/*================================================================
*   ixmlDocument_createElementNSEx
*       Creates an element of the given qualified name and namespace URI.
*       External function.
*   Parameters:
*       namespaceURI: the namespace URI of the element to create.
*       qualifiedName: the qualified name of the element to instantiate.
*   Return Value:
*   Return Value:
*       IXML_SUCCESS
*       IXML_INVALID_PARAMETER:     if either doc,namespaceURI or qualifiedName is NULL
*       IXML_INSUFFICIENT_MEMORY:   if not enough memory to finish this operations.
*
*=================================================================*/
int
ixmlDocument_createElementNSEx( IN IXML_Document * doc,
                                IN DOMString namespaceURI,
                                IN DOMString qualifiedName,
                                OUT IXML_Element ** rtElement )
{

    IXML_Element *newElement = NULL;
    int errCode = IXML_SUCCESS;

    if( ( doc == NULL ) || ( namespaceURI == NULL )
        || ( qualifiedName == NULL ) ) {
        errCode = IXML_INVALID_PARAMETER;
        goto ErrorHandler;
    }

    errCode =
        ixmlDocument_createElementEx( doc, qualifiedName, &newElement );
    if( errCode != IXML_SUCCESS ) {
        goto ErrorHandler;
    }
    /* set the namespaceURI field */
    newElement->n.namespaceURI = strdup( namespaceURI );
    if( newElement->n.namespaceURI == NULL ) {
        ixmlElement_free( newElement );
        newElement = NULL;
        errCode = IXML_INSUFFICIENT_MEMORY;
        goto ErrorHandler;
    }
    /* set the localName and prefix */
    errCode =
        ixmlNode_setNodeName( ( IXML_Node * ) newElement, qualifiedName );
    if( errCode != IXML_SUCCESS ) {
        ixmlElement_free( newElement );
        newElement = NULL;
        errCode = IXML_INSUFFICIENT_MEMORY;
        goto ErrorHandler;
    }

    newElement->n.nodeValue = NULL;

  ErrorHandler:
    *rtElement = newElement;
    return errCode;

}