node.c File Reference
`#include "ixmlparser.h"`
`#include <assert.h>`
`#include <stdlib.h>`
`#include <string.h>`
`#include "posix_overwrites.h"`
Include dependency graph for node.c:

## Functions

void | ixmlNode_init (IXML_Node *nodeptr)
| Intializes a node.
void | ixmlCDATASection_init (IXML_CDATASection *nodeptr)
| Initializes a CDATASection node.
void | ixmlCDATASection_free (IXML_CDATASection *nodeptr)
| Frees a CDATASection node.
static void | ixmlNode_freeSingleNode (IXML_Node *nodeptr)
| Frees a node content.
void | ixmlNode_free (IXML_Node *nodeptr)
| Frees a Node and all Nodes in its subtree.
const DOMString | ixmlNode_getNodeName (IXML_Node *nodeptr)
| Returns the name of the Node, depending on what type of Node it is, in a read-only string.
const DOMString | ixmlNode_getLocalName (IXML_Node *nodeptr)
| Retrieves the local name of a Node, if present.
static int | ixmlNode_setNamespaceURI (IXML_Node *nodeptr, const char *namespaceURI)
| Sets the namespace URI of the node.
static int | ixmlNode_setPrefix (IXML_Node *nodeptr, const char *prefix)
static int | ixmlNode_setLocalName (IXML_Node *nodeptr, const char *localName)
| Set the localName of the node.
const DOMString | ixmlNode_getNamespaceURI (IXML_Node *nodeptr)
| Retrieves the namespace URI for a Node as a DOMString.
const DOMString | ixmlNode_getPrefix (IXML_Node *nodeptr)
| Retrieves the namespace prefix, if present.
const DOMString | ixmlNode_getNodeValue (IXML_Node *nodeptr)
| Returns the value of the Node as a string.
int | ixmlNode_setNodeValue (IXML_Node *nodeptr, const char *newNodeValue)
| Assigns a new value to a Node.
unsigned short | ixmlNode_getNodeType (IXML_Node *nodeptr)
| Retrieves the type of a Node. Note that not all possible return values are actually implemented.
IXML_Node * | ixmlNode_getParentNode (IXML_Node *nodeptr)
| Retrieves the parent Node for a Node.
IXML_Node * | ixmlNode_getFirstChild (IXML_Node *nodeptr)
| Retrieves the first child Node of a Node.
IXML_Node * | ixmlNode_getLastChild (IXML_Node *nodeptr)
| Retrieves the last child Node of a Node.
IXML_Node * | ixmlNode_getPreviousSibling (IXML_Node *nodeptr)
| Retrieves the sibling Node immediately preceding this Node.
IXML_Node * | ixmlNode_getNextSibling (IXML_Node *nodeptr)
| Retrieves the sibling Node immediately following this Node.
IXML_Document * | ixmlNode_getOwnerDocument (IXML_Node *nodeptr)
| Retrieves the document object associated with this Node.
static int | ixmlNode_isAncestor (IXML_Node *ancestorNode, IXML_Node *toFind)
| Check if ancestorNode is ancestor of toFind.
static int | ixmlNode_isParent (IXML_Node *nodeptr, IXML_Node *toFind)
| Check whether toFind is a children of nodeptr.
static int | ixmlNode_allowChildren (IXML_Node *nodeptr, IXML_Node *newChild)
| Check to see whether nodeptr allows children of type newChild.
int | ixmlNode_compare (const IXML_Node *srcNode, const IXML_Node *destNode)
| Compare two nodes to see whether they are the same node. Parent, sibling and children node are ignored.
int | ixmlNode_insertBefore (IXML_Node *nodeptr, IXML_Node *newChild, IXML_Node *refChild)
| Inserts a new child Node before the existing child Node.
int | ixmlNode_replaceChild (IXML_Node *nodeptr, IXML_Node *newChild, IXML_Node *oldChild, IXML_Node **returnNode)
| Replaces an existing child Node with a new child Node in the list of children of a Node.
int | ixmlNode_removeChild (IXML_Node *nodeptr, IXML_Node *oldChild, IXML_Node **returnNode)
| Removes a child from the list of children of a Node.
int | ixmlNode_appendChild (IXML_Node *nodeptr, IXML_Node *newChild)
| Appends a child Node to the list of children of a Node.
static IXML_Node * | ixmlNode_cloneTextNode (IXML_Node *nodeptr)
| Returns a clone of nodeptr.
static IXML_CDATASection * | ixmlNode_cloneCDATASect (IXML_CDATASection *nodeptr)
| Return a clone of CDATASection node.
static IXML_Element * | ixmlNode_cloneElement (IXML_Element *nodeptr)
| Returns a clone of element node.
static IXML_Document * | ixmlNode_newDoc (void)
| Returns a new document node.
static IXML_Attr * | ixmlNode_cloneAttr (IXML_Attr *nodeptr)
| Returns a clone of an attribute node.
static IXML_Attr * | ixmlNode_cloneAttrDirect (IXML_Attr *nodeptr)
| Return a clone of attribute node, with specified field set to 1.
static void | ixmlNode_setSiblingNodesParent (IXML_Node *nodeptr)
| Sets siblings nodes parent to be the same as this node's.
static IXML_Node * | ixmlNode_cloneNodeTreeRecursive (IXML_Node *nodeptr, int deep)
| Recursive function that clones a node tree of nodeptr.
static IXML_Node * | ixmlNode_cloneNodeTree (IXML_Node *nodeptr, int deep)
| Function that clones a node tree of nodeptr.
IXML_Node * | ixmlNode_cloneNode (IXML_Node *nodeptr, int deep)
| Clones a Node.
IXML_NodeList * | ixmlNode_getChildNodes (IXML_Node *nodeptr)
| Retrieves the list of children of a Node in a NodeList structure.
IXML_NamedNodeMap * | ixmlNode_getAttributes (IXML_Node *nodeptr)
| Retrieves the attributes of a Node, if it is an Element node, in a NamedNodeMap structure.
int | ixmlNode_hasChildNodes (IXML_Node *nodeptr)
| Queries whether or not a Node has children.
int | ixmlNode_hasAttributes (IXML_Node *nodeptr)
| Queries whether this Node has attributes.
static void | ixmlNode_getElementsByTagNameRecursive (IXML_Node *n, const char *tagname, IXML_NodeList **list)
| Recursively traverse the whole tree, search for element with the given tagname.
void | ixmlNode_getElementsByTagName (IXML_Node *n, const char *tagname, IXML_NodeList **list)
| Returns a nodeList of all descendant Elements with a given tagName, in the order in which they are encountered in a traversal of this element tree.
static void | ixmlNode_getElementsByTagNameNSRecursive (IXML_Node *n, const char *namespaceURI, const char *localName, IXML_NodeList **list)
void | ixmlNode_getElementsByTagNameNS (IXML_Node *n, const char *namespaceURI, const char *localName, IXML_NodeList **list)
| Returns a nodeList of all the descendant Elements with a given local name and namespace URI in the order in which they are encountered in a preorder traversal of this Elememt tree.
int | ixmlNode_setNodeName (IXML_Node *node, const DOMString qualifiedName)
int | ixmlNode_setNodeProperties (IXML_Node *destNode, IXML_Node *src)

## Function Documentation

## ixmlNode_allowChildren()

int ixmlNode_allowChildren | ( | IXML_Node * | nodeptr,
|  | IXML_Node * | newChild )

static

Check to see whether nodeptr allows children of type newChild.

Returns
  - 1, if nodeptr can have newChild as children.
  - 0, if nodeptr cannot have newChild as children.

Parameters

  [in] | nodeptr | The Node to check.
  [in] | newChild | The child Node to check.

Referenced by ixmlNode_appendChild(), ixmlNode_insertBefore(), and ixmlNode_replaceChild().

## ixmlNode_cloneAttr()

IXML_Attr * ixmlNode_cloneAttr | ( | IXML_Attr * | nodeptr | ) |

static

Returns a clone of an attribute node.

Returns
  A clone of an attribute node.

Parameters

  [in] | nodeptr | The Node to clone.

References ixmlAttr_free(), ixmlNode_setLocalName(), ixmlNode_setNamespaceURI(), ixmlNode_setNodeName(), ixmlNode_setNodeValue(), and ixmlNode_setPrefix().

Referenced by ixmlNode_cloneAttrDirect(), and ixmlNode_cloneNodeTreeRecursive().

## ixmlNode_cloneAttrDirect()

IXML_Attr * ixmlNode_cloneAttrDirect | ( | IXML_Attr * | nodeptr | ) |

static

Return a clone of attribute node, with specified field set to 1.

Returns
  A clone of attribute node, with specified field set to 1.

Parameters

  [in] | nodeptr | The Node to clone.

References ixmlNode_cloneAttr().

Referenced by ixmlNode_cloneNode().

## ixmlNode_cloneCDATASect()

IXML_CDATASection * ixmlNode_cloneCDATASect | ( | IXML_CDATASection * | nodeptr | ) |

static

Return a clone of CDATASection node.

Returns
  A clone of CDATASection node.

Parameters

  [in] | nodeptr | The Node to clone.

References ixmlCDATASection_free(), ixmlCDATASection_init(), ixmlNode_setNodeName(), and ixmlNode_setNodeValue().

Referenced by ixmlNode_cloneNodeTreeRecursive().

## ixmlNode_cloneElement()

IXML_Element * ixmlNode_cloneElement | ( | IXML_Element * | nodeptr | ) |

static

Returns a clone of element node.

Returns
  A clone of element node.

Parameters

  [in] | nodeptr | The Node to clone.

References ixmlElement_free(), ixmlElement_init(), ixmlElement_setTagName(), ixmlNode_setLocalName(), ixmlNode_setNamespaceURI(), ixmlNode_setNodeName(), ixmlNode_setNodeValue(), and ixmlNode_setPrefix().

Referenced by ixmlNode_cloneNodeTree(), and ixmlNode_cloneNodeTreeRecursive().

## ixmlNode_cloneNodeTree()

IXML_Node * ixmlNode_cloneNodeTree | ( | IXML_Node * | nodeptr,
|  | int | deep )

static

Function that clones a node tree of nodeptr.

Returns
  The cloned node/tree.

Parameters

  [in] | nodeptr | Node tree to clone.
  [in] | deep | 1 if you want to clone the tree.

References ixmlNode_cloneElement(), and ixmlNode_cloneNodeTreeRecursive().

Referenced by ixmlNode_cloneNode().

## ixmlNode_cloneNodeTreeRecursive()

IXML_Node * ixmlNode_cloneNodeTreeRecursive | ( | IXML_Node * | nodeptr,
|  | int | deep )

static

Recursive function that clones a node tree of nodeptr.

Returns
  The cloned node/tree.

Parameters

  [in] | nodeptr | Node tree to clone.
  [in] | deep | 1 if you want to clone the tree.

References ixmlNode_cloneAttr(), ixmlNode_cloneCDATASect(), ixmlNode_cloneElement(), ixmlNode_cloneNodeTreeRecursive(), ixmlNode_cloneTextNode(), ixmlNode_newDoc(), and ixmlNode_setSiblingNodesParent().

Referenced by ixmlNode_cloneNodeTree(), and ixmlNode_cloneNodeTreeRecursive().

## ixmlNode_cloneTextNode()

IXML_Node * ixmlNode_cloneTextNode | ( | IXML_Node * | nodeptr | ) |

static

Returns a clone of nodeptr.

Returns
  A cloned node of nodeptr.

Parameters

  [in] | nodeptr | The Node to clone.

References ixmlNode_free(), ixmlNode_init(), ixmlNode_setNodeName(), and ixmlNode_setNodeValue().

Referenced by ixmlNode_cloneNodeTreeRecursive().

## ixmlNode_compare()

int ixmlNode_compare | ( | const IXML_Node * | srcNode,
|  | const IXML_Node * | destNode )

Compare two nodes to see whether they are the same node. Parent, sibling and children node are ignored.

Returns
  - 1, the two nodes are the same.
  - 0, the two nodes are not the same.

Parameters

  [in] | srcNode | The first Node.
  [in] | destNode | The second Node.

Referenced by ixmlElement_findAttributeNode().

## ixmlNode_freeSingleNode()

void ixmlNode_freeSingleNode | ( | IXML_Node * | nodeptr | ) |

static

Frees a node content.

Parameters

  [in] | nodeptr | The node to free.

Referenced by ixmlNode_free().

## ixmlNode_getElementsByTagName()

void ixmlNode_getElementsByTagName | ( | IXML_Node * | n,
|  | const char * | tagname,
|  | IXML_NodeList ** | list )

Returns a nodeList of all descendant Elements with a given tagName, in the order in which they are encountered in a traversal of this element tree.

Parameters

  [in] | n | The Node tree.
  [in] | tagname | The tag name to match.
  [out] | list | The output NodeList.

References ixmlNode_getElementsByTagNameRecursive(), ixmlNode_getFirstChild(), ixmlNode_getNodeName(), ixmlNode_getNodeType(), and ixmlNodeList_addToNodeList().

Referenced by ixmlDocument_getElementsByTagName().

## ixmlNode_getElementsByTagNameNS()

void ixmlNode_getElementsByTagNameNS | ( | IXML_Node * | n,
|  | const char * | namespaceURI,
|  | const char * | localName,
|  | IXML_NodeList ** | list )

Returns a nodeList of all the descendant Elements with a given local name and namespace URI in the order in which they are encountered in a preorder traversal of this Elememt tree.

Parameters

  [in] | n | The Element tree.
  [in] | namespaceURI | The name space to match.
  [in] | localName | The local name to match.
  [out] | list | The output NodeList.

References DOMString, ixmlNode_getElementsByTagNameNSRecursive(), ixmlNode_getFirstChild(), ixmlNode_getLocalName(), ixmlNode_getNamespaceURI(), ixmlNode_getNodeType(), and ixmlNodeList_addToNodeList().

Referenced by ixmlDocument_getElementsByTagNameNS().

## ixmlNode_getElementsByTagNameNSRecursive()

void ixmlNode_getElementsByTagNameNSRecursive | ( | IXML_Node * | n,
|  | const char * | namespaceURI,
|  | const char * | localName,
|  | IXML_NodeList ** | list )

static

Parameters

  [in] | n | .
  [in] | namespaceURI | .
  [in] | localName | .
  [out] | list | .

References DOMString, ixmlNode_getElementsByTagNameNSRecursive(), ixmlNode_getFirstChild(), ixmlNode_getLocalName(), ixmlNode_getNamespaceURI(), ixmlNode_getNextSibling(), ixmlNode_getNodeType(), and ixmlNodeList_addToNodeList().

Referenced by ixmlNode_getElementsByTagNameNS(), and ixmlNode_getElementsByTagNameNSRecursive().

## ixmlNode_getElementsByTagNameRecursive()

void ixmlNode_getElementsByTagNameRecursive | ( | IXML_Node * | n,
|  | const char * | tagname,
|  | IXML_NodeList ** | list )

static

Recursively traverse the whole tree, search for element with the given tagname.

Parameters

  [in] | n | The Node tree.
  [in] | tagname | The tag name to match.
  [out] | list | The output NodeList.

References ixmlNode_getElementsByTagNameRecursive(), ixmlNode_getFirstChild(), ixmlNode_getNextSibling(), ixmlNode_getNodeName(), ixmlNode_getNodeType(), and ixmlNodeList_addToNodeList().

Referenced by ixmlNode_getElementsByTagName(), and ixmlNode_getElementsByTagNameRecursive().

## ixmlNode_init()

void ixmlNode_init | ( | IXML_Node * | nodeptr | ) |

Intializes a node.

Parameters

  [in] | nodeptr | The Node to iniatialize.

Referenced by ixmlDocument_createTextNodeEx(), ixmlNode_cloneTextNode(), and Parser_parseDocument().

## ixmlNode_isAncestor()

int ixmlNode_isAncestor | ( | IXML_Node * | ancestorNode,
|  | IXML_Node * | toFind )

static

Check if ancestorNode is ancestor of toFind.

Returns
  1 or 0.

Parameters

  [in] | ancestorNode | The candidate to ancestor Node.
  [in] | toFind | The Node to check for an ancestor.

References ixmlNode_isAncestor().

Referenced by ixmlNode_appendChild(), ixmlNode_insertBefore(), ixmlNode_isAncestor(), and ixmlNode_replaceChild().

## ixmlNode_isParent()

int ixmlNode_isParent | ( | IXML_Node * | nodeptr,
|  | IXML_Node * | toFind )

static

Check whether toFind is a children of nodeptr.

Returns
  1 or 0.

Parameters

  [in] | nodeptr | The candidate to parent Node.
  [in] | toFind | The Node to check for his parent.

Referenced by ixmlNode_appendChild(), ixmlNode_insertBefore(), ixmlNode_removeChild(), and ixmlNode_replaceChild().

## ixmlNode_newDoc()

IXML_Document * ixmlNode_newDoc | ( | void |  | ) |

static

Returns a new document node.

Currently, the IXML_Document struct is just a node, so this function just mallocs the IXML_Document, sets the node type and name.

Returns
  A new document node.

References ixmlDocument_free(), ixmlDocument_init(), and ixmlNode_setNodeName().

Referenced by ixmlNode_cloneNodeTreeRecursive().

## ixmlNode_setLocalName()

int ixmlNode_setLocalName | ( | IXML_Node * | nodeptr,
|  | const char * | localName )

static

Set the localName of the node.

Returns
  IXML_SUCCESS or failure.

Parameters

  [in] | nodeptr | The pointer to the node.
  [in] | localName | The local name to set.

Referenced by ixmlNode_cloneAttr(), ixmlNode_cloneElement(), and ixmlNode_setNodeProperties().

## ixmlNode_setNamespaceURI()

int ixmlNode_setNamespaceURI | ( | IXML_Node * | nodeptr,
|  | const char * | namespaceURI )

static

Sets the namespace URI of the node.

Parameters

  [in] | nodeptr | The Node on which to operate.
  [in] | namespaceURI | The name space string to set.

Referenced by ixmlNode_cloneAttr(), and ixmlNode_cloneElement().

## ixmlNode_setNodeName()

int ixmlNode_setNodeName | ( | IXML_Node * | node,
|  | const DOMString | qualifiedName )

Returns

Parameters

  [in] | node | The Node.
  [in] | qualifiedName | .

References DOMString, and Parser_setNodePrefixAndLocalName().

Referenced by ixmlDocument_createAttributeNSEx(), ixmlDocument_createElementNSEx(), ixmlNode_cloneAttr(), ixmlNode_cloneCDATASect(), ixmlNode_cloneElement(), ixmlNode_cloneTextNode(), and ixmlNode_newDoc().

## ixmlNode_setNodeProperties()

int ixmlNode_setNodeProperties | ( | IXML_Node * | destNode,
|  | IXML_Node * | src )

Returns

Parameters

  [in] | destNode | .
  [in] | src | .

References ixmlNode_setLocalName(), ixmlNode_setNodeValue(), and ixmlNode_setPrefix().

Referenced by Parser_processAttributeName(), and Parser_processElementName().

## ixmlNode_setPrefix()

int ixmlNode_setPrefix | ( | IXML_Node * | nodeptr,
|  | const char * | prefix )

static

Parameters

  [in] | nodeptr | The Node on which to operate.
  [in] | prefix | The prefix string to set.

Referenced by ixmlNode_cloneAttr(), ixmlNode_cloneElement(), and ixmlNode_setNodeProperties().

## ixmlNode_setSiblingNodesParent()

void ixmlNode_setSiblingNodesParent | ( | IXML_Node * | nodeptr | ) |

static

Sets siblings nodes parent to be the same as this node's.

Parameters

  [in] | nodeptr | The node to operate on.

Referenced by ixmlNode_cloneNodeTreeRecursive().