#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/fcntl.h>
#include <sys/mman.h>
#include <unistd.h>
#include "lxml.h"
Include dependency graph for lxml.c:
|
|
|
|
|
|
|
Return the number of attributes of the given element
|
|
Check or set the name of an element
|
|
Store the attributes of an element Together with lxml_convert_tree(), this is second most important/used function in LXML. It is used to convert between the XML attributes of an element and the application specific data representation. For this task, it uses the LXMLstore structure that describes the attributes and where their values are stored in the application specific data representation. This function is typically used from callbacks called by lxml_tree_convert(). When converting from an XML tree (op flag set to LXML_Read), we need to use the attributes values of an element to store them into the application specific data representation. In this case, this function will check the attributes of the element and if it finds an attribute matching one listed in the 'store' LXMLstore array, it convert it according to the LXMLstore::value_type and store it in the associated pointer LXMLstore::dest. If the LXMLstore::dest_type is of type LXML_List, then the value is stored in the list pointed to by LXMLstore::dest. When converting to an XML tree (op flag set to LXML_Write), this function iterates through the array 'store', and if LXMLstore::dest is not NULL and if *LXMLstore::dest is also not NULL, then a new attribute is created with the value of *(LXMLstore::dest) converted to string. The new attribute is then appended to the list of attributes of the element. If the LXMLstore::dest_type is of type LXML_List, then the list traversed and for each data a new attribute is created and appended.
|
|
Close the XML file If the file was opened in LXML_Read mode, it is munmap'ed.
|
|
Open the XML file for reading or writing The file name must have been set with lxml_set_filename() before calling this function
|
|
Read the XML file and convert it to a tree structure The tree structure consist of a tree of nodes. Each node represents an element of the XML file. The tree is a cntree (see cntree.h). Each node points to the associated element and contains a list of its children along with a pointer to its parent. The element is of type LXMLElement and contains the name of the element, a flag to inform whether it has children elements and a list of its attributes.
|
|
Write an XML tree representing the given tree If the encoding was previously set with lxml_set_encoding(), it will be written with the prologue of the XML file. If the DTD was previously set with lxml_set_dtd(), then the document type declaration will be written.
|
|
Free the ressources used by the handle. If lxml_file_open() was called before, you need to call lxml_file_close() yourself
|
|
Return the DTD as read from the file prologue The file must be read with lxml_file_read() before using this function. FIXME: not implemented yet
|
|
Return the encoding as read from the file prologue The file must be read with lxml_file_read() before using this function. FIXME: not implemented yet
|
|
Create a new handle to access an XML file
|
|
Set the DTD of the XML file This is only used in the prolog of the file. This corresponds to a SYSTEM DTD.
|
|
Set the encoding of the XML file This is only used in the prolog of the file. No conversion is done by LXML. Strings are written as they are. FIXME: quotes should be escaped.
|
|
Set the name of the XML file
|
|
Convert between an XML element and application specific data. This function is to be called when convertin from or to an XML tree, depending on the 'op' flag (resp. LXML_Read or LXML_Write). This is the main function of LXML. It is passed a structure containing pointers to callback functions responsible for the actual conversion. When converting from an XML tree (LXML_Read), after an XML file was read, the callbacks functions listed in 'element_cb' are called whenever a corresponding element is matched. The callback function is called with the following arguments: the associated tree node, an associated, a user provided pointer to a pointer, a pointer to NULL and the LXML_Read flag. The callback is responsible to create the application data associated to the element and to initialize it, eventually by using the attributes of the element. When converting to an XML tree, an initial root element (tree) must be provided by the user. That element must have its name set to the root element of the file. Then for each 'element_cb' data that is non NULL or that points to a non-NULL pointer, the associated user callback is called with the following arguments: a newly created tree node with the associated element name, the associated LXMLelement_callbacks::data, a pointer to a pointer pointing initially to NULL and meant to be used by the callback function as an iterator, and the LXML_Write flag. The 'data_iter' is initially set to NULL for each element. The callback function can therefore detect that it was called for the first time. If the application specific data is not a single data but a container, the callback function sets the pointer pointed to be 'data_iter' to the start iterator associated with the container. It then processes the data pointed to by the iterator, then it advances the iterator. If the iterator reaches the end of the container, it must be set to NULL. This is because LXML will continously call the same callback when it detects that the pointer pointed to by data_iter is non NULL, which means that there are still nodes to be created with the same element at that same depth.
|
|
For each node referenced by the given path, call a user provided callback. This is currently not used. This functions traverses the XML tree and for each path matching the given path, it calls the user provided callback.
|
|
Free an XML tree Every resources used by the tree is freeed.
|
Here is the call graph for this function:
|
Free the XML tree but do not the attribute values Currently not used. Deprecated.
|
Here is the call graph for this function:
|
Get the element associated to the current tree
|
Here is the call graph for this function:
|
Create an empty tree with a single unnamed root element
|
Here is the call graph for this function: