43
43
/****************************************************************************/
44
/* Simplified GSF based xml import (based on libxml2 SAX) */
45
typedef struct _GsfXMLBlob GsfXMLBlob;
47
typedef struct _GsfXMLIn GsfXMLIn;
48
typedef struct _GsfXMLInDoc GsfXMLInDoc;
49
typedef struct _GsfXMLInNode GsfXMLInNode;
50
typedef struct _GsfXMLInNS GsfXMLInNS;
44
/* Simplified wrapper to SAX based xml import */
45
typedef struct _GsfXMLIn GsfXMLIn;
46
typedef struct _GsfXMLInDoc GsfXMLInDoc;
47
typedef struct _GsfXMLInNode GsfXMLInNode;
48
typedef struct _GsfXMLInNS GsfXMLInNS;
49
typedef struct _GsfXMLBlob GsfXMLBlob;
51
GSF_XML_NO_CONTENT = FALSE,
55
53
GSF_XML_SHARED_CONTENT
55
typedef gboolean (*GsfXMLInUnknownFunc) (GsfXMLIn *xin,
56
xmlChar const *elem, xmlChar const **attrs);
57
typedef void (*GsfXMLInExtDtor) (GsfXMLIn *xin, gpointer old_state);
59
GsfXMLInDoc const *doc; /* init before parsing */
61
/* look but do not change */
62
GsfXMLInNode const *node; /* current node */
65
GsfXMLInNS const *default_ns; /* optionally NULL */
69
gint unknown_depth; /* handle recursive unknown tags */
70
GHashTable *ns_prefixes; /* current ns prefixes */
71
GPtrArray *ns_by_id; /* indexed by id */
60
/* public state : read only */
63
GsfXMLInDoc const *doc;
64
GsfXMLInNode const *node; /* current node (not on the stack) */
65
GSList *node_stack; /* stack of GsfXMLInNode */
74
68
struct _GsfXMLInNode {
69
char const *id; /* unique in the entire tree */
78
72
char const *parent_id;
79
gboolean parent_initialized;
83
gboolean allow_unknown;
84
gboolean check_children_for_ns;
86
void (*start) (GsfXMLIn *state, xmlChar const **attrs);
87
void (*end) (GsfXMLIn *state, GsfXMLBlob *unknown);
73
void (*start) (GsfXMLIn *xin, xmlChar const **attrs);
74
void (*end) (GsfXMLIn *xin, GsfXMLBlob *unknown);
102
93
#define GSF_XML_IN_NS(id, uri) \
105
96
#define GSF_XML_IN_NODE_FULL(parent_id, id, ns, name, has_content, \
106
allow_unknown, check_ns, start, end, user) \
97
share_children_with_parent, check_ns, start, end, user) \
108
#id, ns, name, #parent_id, FALSE, NULL, \
109
has_content, allow_unknown, check_ns, start, end, { user } \
99
#id, ns, name, #parent_id, start, end, { user }, has_content, \
100
check_ns, share_children_with_parent, \
112
103
#define GSF_XML_IN_NODE(parent_id, id, ns, name, has_content, start, end) \
113
104
GSF_XML_IN_NODE_FULL(parent_id, id, ns, name, has_content, \
114
105
FALSE, FALSE, start, end, 0)
116
GsfXMLInDoc *gsf_xml_in_doc_new (GsfXMLInNode *root, GsfXMLInNS *ns);
117
void gsf_xml_in_doc_free (GsfXMLInDoc *doc);
119
gboolean gsf_xml_in_parse (GsfXMLIn *state, GsfInput *input);
120
char const *gsf_xml_in_check_ns (GsfXMLIn const *state, char const *str,
122
gboolean gsf_xml_in_namecmp (GsfXMLIn const *state, char const *str,
123
unsigned int ns_id, char const *name);
106
#define GSF_XML_IN_NODE_END \
107
{ NULL, 0, NULL, NULL, NULL, NULL, { 0 }, GSF_XML_NO_CONTENT, FALSE, FALSE }
109
GsfXMLInDoc *gsf_xml_in_doc_new (GsfXMLInNode const *nodes, GsfXMLInNS const *ns);
110
void gsf_xml_in_doc_free (GsfXMLInDoc *doc);
111
gboolean gsf_xml_in_doc_parse (GsfXMLInDoc *doc, GsfInput *input,
112
gpointer user_state);
113
void gsf_xml_in_doc_set_unknown_handler (GsfXMLInDoc *doc,
114
GsfXMLInUnknownFunc handler);
116
void gsf_xml_in_push_state (GsfXMLIn *xin, GsfXMLInDoc const *doc,
117
gpointer new_state, GsfXMLInExtDtor dtor,
118
xmlChar const **attrs);
120
GsfInput *gsf_xml_in_get_input (GsfXMLIn const *xin);
121
char const *gsf_xml_in_check_ns (GsfXMLIn const *xin, char const *str,
123
gboolean gsf_xml_in_namecmp (GsfXMLIn const *xin, char const *str,
124
unsigned int ns_id, char const *name);
125
126
/****************************************************************************/
126
127
/* Simplified GSF based xml export (does not use libxml) */
161
162
unsigned int r, unsigned int g, unsigned int b);
162
163
void gsf_xml_out_add_base64 (GsfXMLOut *xml, char const *id,
163
164
guint8 const *data, unsigned int len);
165
void gsf_xml_out_add_enum (GsfXMLOut *xml, char const *id,
166
GType etype, gint val);
167
void gsf_xml_out_add_gvalue (GsfXMLOut *xml, char const *id,
165
/* TODO : something for enums ? */
170
/****************************************************************************/
171
/* Some general utilities */
172
gboolean gsf_xml_gvalue_from_str (GValue *res, GType t, char const *str);