![]() |
![]() |
![]() |
mialm Reference Manual | ![]() |
---|---|---|---|---|
Top | Description |
XML manipulation of landmarksXML manipulation of landmarks — XML in-and output routines for landmark related data |
#define END_PARSER_TAGS struct ParserState; struct ParserStateStack; struct ParserTags; void (*tag_ch_callback) (ParserState *user_data
,const xmlChar *ch
,int len
); void (*tag_end_callback) (ParserState *user_data
,const gchar *property
); void (*tag_start_callback) (ParserState *user_data
,const xmlChar **attrs
); int xml_sax_parse (const gchar *filename
,const ParserTags *tags
,gpointer pdata
); gboolean xml_write_float (xmlNodePtr root
,xmlNsPtr ns
,const gchar *tag
,gfloat f
); void xmlio_end_float (ParserState *state
,const gchar *property
); void xmlio_end_string (ParserState *state
,const gchar *property
); void xmlio_get_string (ParserState *state
,const xmlChar *ch
,int len
);
The functions provided in tis section are used to load ans store landmarks and related information from and to XML trees.
struct ParserState { ParserStateStack *pss; gpointer data; };
This structure holds the current state when parsing an XML file.
ParserStateStack * |
stack to store the parser states |
gpointer |
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.
gint |
unused field?? |
gint |
xml-tree depth when reading (and discarding an unkown tag) |
GString * |
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 |
gint |
size of following tag-callback map |
const ParserTags * |
table of tag-callback mappings |
GString * |
string to accumulate corrently parsed section |
gpointer |
private data passed to the parser |
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.
const gchar * |
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 |
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.
|
data passd in by the user when calling the SAX parser |
|
character string |
|
length of the incomming character string |
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.
|
data passd in by the user when calling the SAX parser |
|
property identifies this tag corresponds to. |
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.
|
data passd in by the user when calling the SAX parser |
|
attributes of the XML tag that was just opened. |
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.
|
filename of the input XML file |
|
A table of tags with their corresponding callback map |
|
Private data passed to the parser state. [closure] |
Returns : |
0 in the case of success and the error number returned by xmlSAXUserParseFile |
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
|
root node to add thenew data to |
|
XML name space identified |
|
node tag to be used to store the data |
|
floating point value to be stored |
Returns : |
TRUE if successful, FALSE otherwise. |
void xmlio_end_float (ParserState *state
,const gchar *property
);
Store the read floating point value as property in the currently active entity
|
holds the current state of the parser |
|
the property that is currently read from the XML input |
void xmlio_end_string (ParserState *state
,const gchar *property
);
Store the read string as property in the currently active entity
|
holds the current state of the parser |
|
the property that is currently read from the XML input |
void xmlio_get_string (ParserState *state
,const xmlChar *ch
,int len
);
Append the string ch
to the currently read string in the parser state
|
current XML parser state |
|
character string |
|
length of the input character string |