|
struct dom_node_list * | add_to_dom_node_list (struct dom_node_list **list_ptr, struct dom_node *node, int position) |
|
void | done_dom_node_list (struct dom_node_list *list) |
|
int | get_dom_node_list_index (struct dom_node *parent, struct dom_node *node) |
|
int | get_dom_node_map_index (struct dom_node_list *list, struct dom_node *node) |
|
struct dom_node * | get_dom_node_prev (struct dom_node *node) |
|
struct dom_node * | get_dom_node_next (struct dom_node *node) |
|
struct dom_node * | get_dom_node_child (struct dom_node *node, uint16_t child_type, int16_t child_subtype) |
|
struct dom_node * | get_dom_node_map_entry (struct dom_node_list *node_map, uint16_t type, uint16_t subtype, struct dom_string *name) |
|
void | done_dom_node (struct dom_node *node) |
|
struct dom_node * | init_dom_node_at (struct dom_node *parent, uint16_t type, struct dom_string *string, int allocated) |
|
static struct dom_node * | add_dom_attribute (struct dom_node *parent, struct dom_string *name, struct dom_string *value) |
|
static struct dom_node * | add_dom_proc_instruction (struct dom_node *parent, struct dom_string *string, struct dom_string *instruction) |
|
int | dom_node_casecmp (struct dom_node *node1, struct dom_node *node2) |
|
struct dom_string * | get_dom_node_name (struct dom_node *node) |
|
struct dom_string * | get_dom_node_value (struct dom_node *node) |
|
struct dom_string * | get_dom_node_type_name (uint16_t type) |
|
static struct dom_node_list ** | get_dom_node_list_by_type (struct dom_node *parent, uint16_t type) |
| Based on the type of the parent and the node type return a proper list or NULL.
|
|
DOM node module.
This module defines the various node and node list data structures and functionality to modify and access them, such as adding a node as a child to a given node and getting the text string of a node as defined by the DOM specification.
- Node hierarchy
DOM documents are represented as a collection of nodes arranged in a hierarchic structure. At the root is either a DOM_NODE_DOCUMENT or DOM_NODE_DOCUMENT_FRAGMENT node, each of which may have multiple child nodes. There is a well-defined order that dictates which child nodes may be descendants of a given type of node. For example, text and attribute nodes can have no children, while elements node may have both attribute and element nodes as children but with each type in different node lists. The hierarchy is somewhat encoded in the type specific node data, however, certain node types also define "custom" node lists for conveniently storing additional "embedded" data, such as processing instruction nodes having an attribute node list for conveniently accessing variable-value pairs given for XML-specific processing instructions:
<?xml version="1.0"?>
- Node lists
There are two types of list: unordered (the default) and alphabetically ordered (also called "maps"). Both types of list stores all contained nodes in the index-oriented dom_node_list data structure.
When inserting a node into a list, first use either get_dom_node_list_index or get_dom_node_map_index (depending on whether the list is unordered or ordered respectively) to calculate the index at which to insert the new node. Then use add_to_dom_node_list to insert the node in the list at the given position. Alternatively (and mostly preferred), simply use add_dom_node to have all of the above done automatically plus some additional checks.
A variety of node list accessors are defined. The node structure does not define any "next" or "previous" members to get siblings due to reduce memory usage (this might have to change –jonas). Instead, use get_dom_node_next and get_dom_node_next to access siblings. To lookup the existence of a node in a sorted node list (map) use get_dom_node_map_entry. If a specific and unique node subtype should be found use get_dom_node_child that given a parent node will find a child node based on a specific child node type and subtype. Finally, list can be iterated in forward and reverse order using foreach_dom_node and foreachback_dom_node.