DTS Application Library
0.2.3
Application library containing referenced objects and interfaces to common libraries
|
Utilities for managing XML documents. More...
Modules | |
XSLT Interface | |
Utilities for managing XML documents. | |
Files | |
file | libxml2.c |
XML Interface. | |
Data Structures | |
struct | xml_attr |
XML attribute name value pair. More... | |
struct | xml_node |
Reference to a XML Node. More... | |
struct | xml_node_iter |
Iterator to traverse nodes in a xpath. More... | |
struct | xml_search |
XML xpath search result. More... | |
Typedefs | |
typedef struct xml_node | xml_node |
Forward decleration of structure. More... | |
typedef struct xml_search | xml_search |
Forward decleration of structure. More... | |
typedef struct xml_doc | xml_doc |
Forward decleration of structure. More... | |
Functions | |
void | xml_free_buffer (void *data) |
Reference destructor for xml_buffer. More... | |
struct xml_doc * | xml_loaddoc (const char *docfile, int validate) |
Load a XML file into XML document and return reference. More... | |
struct xml_doc * | xml_loadbuf (const uint8_t *buffer, uint32_t len, int validate) |
Load a buffer into XML document returning refereence. More... | |
struct xml_node * | xml_getrootnode (struct xml_doc *xmldoc) |
Return reference to the root node. More... | |
struct xml_node * | xml_getfirstnode (struct xml_search *xpsearch, void **iter) |
Return reference to the first node optionally creating a iterator. More... | |
struct xml_node * | xml_getnextnode (void *iter) |
Return the next node. More... | |
struct bucket_list * | xml_getnodes (struct xml_search *xpsearch) |
Return reference to bucket list containing nodes. More... | |
struct xml_search * | xml_xpath (struct xml_doc *xmldata, const char *xpath, const char *attrkey) |
Return a reference to a xpath search result. More... | |
int | xml_nodecount (struct xml_search *xsearch) |
Return the number of nodes in the search path. More... | |
struct xml_node * | xml_getnode (struct xml_search *xsearch, const char *key) |
Return a node in the search matching key. More... | |
const char * | xml_getattr (struct xml_node *xnode, const char *attr) |
Return value of attribute. More... | |
const char * | xml_getrootname (struct xml_doc *xmldoc) |
Return the name of the root node. More... | |
void | xml_modify (struct xml_doc *xmldoc, struct xml_node *xnode, const char *value) |
Modify a XML node. More... | |
void | xml_setattr (struct xml_doc *xmldoc, struct xml_node *xnode, const char *name, const char *value) |
Modify a XML node attribute. More... | |
void | xml_createpath (struct xml_doc *xmldoc, const char *xpath) |
Create a path in XML document. More... | |
void | xml_appendnode (struct xml_doc *xmldoc, const char *xpath, struct xml_node *child) |
Append a node to a path. More... | |
struct xml_node * | xml_addnode (struct xml_doc *xmldoc, const char *xpath, const char *name, const char *value, const char *attrkey, const char *keyval) |
Append a node to a path. More... | |
void | xml_unlink (struct xml_node *xnode) |
Unlink a node from the document. More... | |
void | xml_delete (struct xml_node *xnode) |
Delete a node from document it is not unrefd and should be. More... | |
char * | xml_getbuffer (void *buffer) |
Return the buffer of a xml_buffer structure. More... | |
void * | xml_doctobuffer (struct xml_doc *xmldoc) |
Return a dump of a XML document. More... | |
void | xml_init () |
Initialise/Reference the XML library. More... | |
void | xml_close () |
Unreference the XML library. More... | |
void | xml_savefile (struct xml_doc *xmldoc, const char *file, int format, int compress) |
Save XML document to a file. More... | |
Utilities for managing XML documents.
typedef struct xml_search xml_search |
struct xml_node* xml_addnode | ( | struct xml_doc * | xmldoc, |
const char * | xpath, | ||
const char * | name, | ||
const char * | value, | ||
const char * | attrkey, | ||
const char * | keyval | ||
) |
Append a node to a path.
xmldoc | Reference to XML document. |
xpath | Path to add the node too. |
name | Node name. |
value | Node value. |
attrkey | Attribute to create on node. |
keyval | Attribute value of attrkey. |
Definition at line 651 of file libxml2.c.
References objlock(), objref(), objunlock(), and objunref().
Referenced by xml_createpath().
Append a node to a path.
xmldoc | Reference to XML document. |
xpath | Path to add the node too. |
child | XML node to append to path. |
Definition at line 625 of file libxml2.c.
References xml_node::nodeptr, objlock(), objref(), objunlock(), and objunref().
void xml_close | ( | ) |
Unreference the XML library.
Ideally this should be done after a call to xml_init at shutdown.
Definition at line 758 of file libxml2.c.
References objunref().
void xml_createpath | ( | struct xml_doc * | xmldoc, |
const char * | xpath | ||
) |
Create a path in XML document.
xmldoc | Reference to XML document. |
xpath | Path to create. |
Definition at line 507 of file libxml2.c.
References xml_node::name, objlock(), objref(), objunlock(), objunref(), and xml_addnode().
void xml_delete | ( | struct xml_node * | xnode | ) |
Delete a node from document it is not unrefd and should be.
xnode | Reference to node to delete this must be unreferenced after calling this function. |
Definition at line 701 of file libxml2.c.
References xml_node::nodeptr, objlock(), and objunlock().
void* xml_doctobuffer | ( | struct xml_doc * | xmldoc | ) |
Return a dump of a XML document.
The result can be acessed using xml_getbuffer()
xmldoc | Reference to a XML document. |
Definition at line 726 of file libxml2.c.
References objalloc(), objlock(), objunlock(), and xml_free_buffer().
void xml_free_buffer | ( | void * | data | ) |
Reference destructor for xml_buffer.
Definition at line 46 of file libxml2.c.
Referenced by xml_doctobuffer(), and xslt_apply_buffer().
const char* xml_getattr | ( | struct xml_node * | xnode, |
const char * | attr | ||
) |
Return value of attribute.
xnode | XML node reference. |
attr | Attribute to search for. |
Definition at line 440 of file libxml2.c.
References xml_node::attrs, bucket_list_find_key(), objunref(), and xml_attr::value.
char* xml_getbuffer | ( | void * | buffer | ) |
Return the buffer of a xml_buffer structure.
buffer | Reference to a xml_buffer struct. |
struct xml_node* xml_getfirstnode | ( | struct xml_search * | xpsearch, |
void ** | iter | ||
) |
Return reference to the first node optionally creating a iterator.
Setting the optional iterator and using it on future calls to xml_getnextnode its possible to iterate through the search path.
xpsearch | XML xpath search to find first node. |
iter | Optional iterator created and returned (must be unreferenced) |
Definition at line 295 of file libxml2.c.
References xml_node_iter::cnt, xml_node_iter::curpos, objalloc(), objlock(), objref(), objunlock(), objunref(), xml_nodecount(), and xml_node_iter::xsearch.
struct xml_node* xml_getnextnode | ( | void * | iter | ) |
Return the next node.
iter | Iterator set in call to from xml_getfirstnode. |
Definition at line 322 of file libxml2.c.
References xml_node_iter::cnt, xml_node_iter::curpos, objlock(), objref(), objunlock(), objunref(), and xml_node_iter::xsearch.
struct xml_node* xml_getnode | ( | struct xml_search * | xsearch, |
const char * | key | ||
) |
Return a node in the search matching key.
The key is matched against the index attribute supplied or the value of the node.
xsearch | Reference to xpath search. |
key | Value to use to find node matched aginst the index attribute/value. |
Definition at line 429 of file libxml2.c.
References bucket_list_find_key(), and xml_search::nodes.
struct bucket_list* xml_getnodes | ( | struct xml_search * | xpsearch | ) |
Return reference to bucket list containing nodes.
xpsearch | Reference to xpath search result returned by xml_xpath. |
Definition at line 349 of file libxml2.c.
References xml_search::nodes, and objref().
const char* xml_getrootname | ( | struct xml_doc * | xmldoc | ) |
Return reference to the root node.
xmldoc | XML Document to find root in. |
Definition at line 276 of file libxml2.c.
References objlock(), and objunlock().
void xml_init | ( | ) |
Initialise/Reference the XML library.
Ideally this should be done on application startup but will be started and stoped as needed.
Definition at line 742 of file libxml2.c.
References objalloc(), and objref().
Referenced by xml_loadbuf(), and xml_loaddoc().
struct xml_doc* xml_loadbuf | ( | const uint8_t * | buffer, |
uint32_t | len, | ||
int | validate | ||
) |
Load a buffer into XML document returning refereence.
buffer | Buffer containing the XML. |
len | Size of the buffer. |
validate | Set to non zero value to fail if validation fails. |
Definition at line 168 of file libxml2.c.
References objalloc(), objunref(), and xml_init().
Referenced by curl_buf2xml().
struct xml_doc* xml_loaddoc | ( | const char * | docfile, |
int | validate | ||
) |
Load a XML file into XML document and return reference.
docfile | Pathname to XML file. |
validate | Set to non zero value to fail if validation fails. |
Definition at line 146 of file libxml2.c.
References objalloc(), objunref(), and xml_init().
Modify a XML node.
xmldoc | XML Document node belongs to |
xnode | XML Node to modify. |
value | Value to set. |
Definition at line 469 of file libxml2.c.
References ALLOC_CONST, xml_node::nodeptr, objlock(), objunlock(), and xml_node::value.
int xml_nodecount | ( | struct xml_search * | xsearch | ) |
Return the number of nodes in the search path.
xsearch | Reference to XML xpath search (xml_xpath()) |
Definition at line 413 of file libxml2.c.
References xml_search::xpathObj.
Referenced by xml_getfirstnode().
void xml_savefile | ( | struct xml_doc * | xmldoc, |
const char * | file, | ||
int | format, | ||
int | compress | ||
) |
Save XML document to a file.
xmldoc | Reference to XML document to save. |
file | Filename to write the XML document too. |
format | Formating flag from libxml2. |
compress | Compression level 0[none]-9. |
Definition at line 769 of file libxml2.c.
References objlock(), and objunlock().
void xml_setattr | ( | struct xml_doc * | xmldoc, |
struct xml_node * | xnode, | ||
const char * | name, | ||
const char * | value | ||
) |
Modify a XML node attribute.
xmldoc | XML Document node belongs to |
xnode | XML Node to modify. |
name | Attribute to modify. |
value | Value to set. |
Definition at line 493 of file libxml2.c.
References xml_node::nodeptr, objlock(), and objunlock().
void xml_unlink | ( | struct xml_node * | xnode | ) |
Unlink a node from the document.
xnode | Reference of node to unlink. |
Definition at line 693 of file libxml2.c.
References xml_node::nodeptr, objlock(), and objunlock().
struct xml_search* xml_xpath | ( | struct xml_doc * | xmldata, |
const char * | xpath, | ||
const char * | attrkey | ||
) |
Return a reference to a xpath search result.
xmldata | XML Document to search. |
xpath | Xpath search to apply. |
attrkey | Attribute to index by. |
Definition at line 381 of file libxml2.c.
References xml_search::nodes, objalloc(), objlock(), objref(), objunlock(), objunref(), xml_search::xmldoc, and xml_search::xpathObj.