1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
2 /*
3  * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
4  *
5  * This library is free software: you can redistribute it and/or modify it
6  * under the terms of the GNU Lesser General Public License as published by
7  * the Free Software Foundation.
8  *
9  * This library is distributed in the hope that it will be useful, but
10  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
11  * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
12  * for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public License
15  * along with this library. If not, see <http://www.gnu.org/licenses/>.
16  *
17  */
18 
19 #if !defined (__LIBEDATASERVER_H_INSIDE__) && !defined (LIBEDATASERVER_COMPILATION)
20 #error "Only <libedataserver/libedataserver.h> should be included directly."
21 #endif
22 
23 #ifndef E_XML_UTILS_H
24 #define E_XML_UTILS_H
25 
26 #include <glib.h>
27 #include <libxml/parser.h>
28 #include <libxml/xpath.h>
29 
30 G_BEGIN_DECLS
31 
32 void		e_xml_initialize_in_main	(void);
33 
34 xmlDoc *	e_xml_parse_file		(const gchar *filename);
35 gint		e_xml_save_file			(const gchar *filename,
36 						 xmlDoc *doc);
37 xmlNode *	e_xml_get_child_by_name		(const xmlNode *parent,
38 						 const xmlChar *child_name);
39 
40 xmlDoc *	e_xml_parse_data		(gconstpointer data,
41 						 gsize length);
42 xmlXPathContext *
43 		e_xml_new_xpath_context_with_namespaces
44 						(xmlDoc *doc,
45 						 ...) G_GNUC_NULL_TERMINATED;
46 void		e_xml_xpath_context_register_namespaces
47 						(xmlXPathContext *xpath_ctx,
48 						 const gchar *prefix,
49 						 const gchar *href,
50 						 ...) G_GNUC_NULL_TERMINATED;
51 xmlXPathObject *
52 		e_xml_xpath_eval		(xmlXPathContext *xpath_ctx,
53 						 const gchar *format,
54 						 ...) G_GNUC_PRINTF (2, 3);
55 gchar *		e_xml_xpath_eval_as_string	(xmlXPathContext *xpath_ctx,
56 						 const gchar *format,
57 						 ...) G_GNUC_PRINTF (2, 3);
58 gboolean	e_xml_xpath_eval_exists		(xmlXPathContext *xpath_ctx,
59 						 const gchar *format,
60 						 ...) G_GNUC_PRINTF (2, 3);
61 
62 gboolean	e_xml_is_element_name		(xmlNode *node,
63 						 const gchar *ns_href,
64 						 const gchar *name);
65 xmlNode *	e_xml_find_sibling		(xmlNode *sibling,
66 						 const gchar *ns_href,
67 						 const gchar *name);
68 xmlNode *	e_xml_find_next_sibling		(xmlNode *sibling,
69 						 const gchar *ns_href,
70 						 const gchar *name);
71 xmlNode *	e_xml_find_child		(xmlNode *parent,
72 						 const gchar *ns_href,
73 						 const gchar *name);
74 xmlChar *	e_xml_dup_node_content		(const xmlNode *node);
75 xmlChar *	e_xml_find_child_and_dup_content(xmlNode *parent,
76 						 const gchar *ns_href,
77 						 const gchar *name);
78 const xmlChar *	e_xml_get_node_text		(const xmlNode *node);
79 const xmlChar *	e_xml_find_child_and_get_text	(xmlNode *parent,
80 						 const gchar *ns_href,
81 						 const gchar *name);
82 void		e_xml_find_children_nodes	(xmlNode *parent,
83 						 guint count,
84 						 ...);
85 xmlNode *	e_xml_find_in_hierarchy		(xmlNode *parent,
86 						 const gchar *child_ns_href,
87 						 const gchar *child_name,
88 						 ...) G_GNUC_NULL_TERMINATED; /* requires two NULL-s at the end of the arguments */
89 
90 G_END_DECLS
91 
92 #endif /* E_XML_UTILS_H */
93