Top | ![]() |
![]() |
![]() |
![]() |
XML manipulation of landmarksXML manipulation of landmarks — XML in-and output routines for landmark related data |
void | (*tag_start_callback) () |
void | (*tag_ch_callback) () |
void | (*tag_end_callback) () |
void | xmlio_end_string () |
void | xmlio_end_float () |
void | xmlio_get_string () |
gboolean | xml_write_float () |
int | xml_sax_parse () |
struct | ParserTags |
#define | END_PARSER_TAGS |
struct | ParserState |
struct | ParserStateStack |
The functions provided in tis section are used to load ans store landmarks and related information from and to XML trees.
void (*tag_start_callback) (ParserState *user_data
,const xmlChar **attrs
);
This is the prototype of the callback funtion that will be called by the SAX parser at the opening of a new XML tag.
void (*tag_ch_callback) (ParserState *user_data
,const xmlChar *ch
,int len
);
This is the prototype of the callback funtion that will be called whenever a chunk of characters is read when handling an XML tag. The contents of a XML tag may come in parts, hence the incoming data should be accumulated.
void (*tag_end_callback) (ParserState *user_data
,const gchar *property
);
This is the prototype of the callback funtion that will be called by the SAX parser at the closing of a XML tag.
void xmlio_end_string (ParserState *state
,const gchar *property
);
Store the read string as property in the currently active entity
void xmlio_end_float (ParserState *state
,const gchar *property
);
Store the read floating point value as property in the currently active entity
void xmlio_get_string (ParserState *state
,const xmlChar *ch
,int len
);
Append the string ch
to the currently read string in the parser state
gboolean xml_write_float (xmlNodePtr root
,xmlNsPtr ns
,const gchar *tag
,gfloat f
);
Store the value f
as new node of root
with tag tag
in namespace ns
int xml_sax_parse (const gchar *filename
,const ParserTags *tags
,gpointer pdata
);
Parse the given XML file by using the given callback table to handle the tags accordingly by calling xmlSAXUserParseFile from the libxml2 library.
struct ParserTags { const gchar *tag_name; tag_start_callback start_callback; tag_ch_callback ch_callback; tag_end_callback end_callback; const ParserTags *parser_tags; };
This table entry describes the handling of a certain XML tag. When the tag opens, it will call the
start_callback
function and push its related the property and ch_callback and end_callback values
on the ParserStateStack
that is used to parse the XML file at hand.
If a new tag is read, that the sub-table will be used to identify the proper handler, and if none is available,
the unknown tag handler will be used to skip over this tag.
name of the XML tag to be handled by this table entry |
||
tag_start_callback |
callback to execute when the tag starts |
|
tag_ch_callback |
callback to execute when string data is read |
|
tag_end_callback |
callback to execute when the tag ends, should handle storing of the read data |
|
const ParserTags * |
sub-table that describes the supported child-tags of this XML tag |
struct ParserState { ParserStateStack *pss; gpointer data; };
This structure holds the current state when parsing an XML file.
ParserStateStack * |
stack to store the parser states |
|
additional user data that is passed to the parser |
struct ParserStateStack { gint tag_id; gint unknown_depth; GString *property; tag_ch_callback ch_callback; tag_end_callback end_callback; gint n_parser_tags; const ParserTags *parser_tags; GString *ch; gpointer data; };
A structure to hold the state of the parser.
unused field?? |
||
xml-tree depth when reading (and discarding an unkown tag) |
||
the property related to the tag that is currently read |
||
tag_ch_callback |
currently active callback function to handle read characters |
|
tag_end_callback |
currently active callback funtion to call when the currently read tag ends |
|
size of following tag-callback map |
||
const ParserTags * |
table of tag-callback mappings |
|
string to accumulate corrently parsed section |
||
private data passed to the parser |