2 * LibAxl: Another XML library
3 * Copyright (C) 2006 Advanced Software Production Line, S.L.
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public License
7 * as published by the Free Software Foundation; either version 2.1 of
8 * the License, or (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this program; if not, write to the Free
17 * Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
20 * You may find a copy of the license under this software is released
21 * at COPYING file. This is LGPL software: you are welcome to
22 * develop proprietary applications using this library without any
23 * royalty or fee but returning back any change, improvement or
24 * addition in the form of source code, project image, documentation
27 * For commercial support on build XML enabled solutions contact us:
30 * Advanced Software Production Line, S.L.
31 * C/ Dr. Michavila NÂș 14
32 * Coslada 28820 Madrid
36 * info@aspl.es - http://fact.aspl.es
38 #ifndef __AXL_NODE_H__
39 #define __AXL_NODE_H__
46 * \addtogroup axl_node_module
50 axlNode
* axl_node_create (const char * name
);
52 axlNode
* axl_node_create_ref (char * name
);
54 axlNode
* axl_node_parse_strings (axlError
** error
, ...);
56 axlNode
* axl_node_parse (axlError
** error
, const char * content
, ...);
58 void axl_node_set_name (axlNode
* node
,
61 void axl_node_set_name_ref (axlNode
* node
,
64 void axl_node_set_name_from_factory (axlNode
* node
,
67 axlNode
* axl_node_copy (axlNode
* node
,
71 axlDoc
* axl_node_get_doc (axlNode
* node
);
73 void axl_node_set_doc (axlNode
* node
,
76 void axl_node_set_attribute (axlNode
* node
,
77 const char * attribute
,
80 void axl_node_set_attribute_ref (axlNode
* node
,
84 void axl_node_set_attribute_from_factory (axlFactory
* factory
,
90 * @brief Macro definition which works as an alias for \ref
91 * axl_node_get_attribute_value.
93 * @param node The node being checked to have an attribute value.
94 * @param attr The attribute that is being check to be present in the node provided.
96 * @return \ref true if the node has the provided attribute, otherwise
97 * \ref false is returned.
99 #define HAS_ATTR(node,attr) axl_node_has_attribute(node,attr)
101 bool axl_node_has_attribute (axlNode
* node
,
102 const char * attribute
);
104 void axl_node_remove_attribute (axlNode
* node
,
105 const char * attribute
);
107 int axl_node_num_attributes (axlNode
* node
);
111 * @brief Macro definition, which works as an alias for \ref
112 * axl_node_get_attribute_value.
114 * @param node The node that is being required to return the content
115 * of a particular node.
117 * @param attr The attribute that is requested.
119 * @return The value assocaited to the attribute value or null if it
120 * fails. See \ref axl_node_get_attribute_value.
122 #define ATTR_VALUE(node,attr) axl_node_get_attribute_value(node, attr)
124 const char * axl_node_get_attribute_value (axlNode
* node
,
125 const char * attribute
);
127 char * axl_node_get_attribute_value_copy (axlNode
* node
,
128 const char * attribute
);
131 * @brief Simple alias definition to \ref axl_node_get_attribute_value_trans function.
133 * @param node The node which contains the attribute requested.
135 * @param attr The attribute key that is being requested.
137 * @return A newly allocated string containing the attribute value,
138 * with known entity references translated.
140 #define ATTR_VALUE_TRANS(node,attr) axl_node_get_attribute_value_trans(node,attr)
142 char * axl_node_get_attribute_value_trans (axlNode
* node
,
143 const char * attribute
);
146 * @brief Allows to get the value associated to the attributed
147 * provided, inside the node selected, removing trailing and ending
148 * white spaces (in the W3C sence: \\n, \\t, \\r, ' ').
150 * This is a macro alias to \ref axl_node_get_attribute_value_trimmed.
152 * @param node The node that is requested to return the associated
153 * value to the attributed.
155 * @param attr The attribute that is being requested.
157 * @return A reference to the attribute value or NULL if it fails.
159 #define ATTR_VALUE_TRIMMED(node,attr) axl_node_get_attribute_value_trimmed(node,attr)
161 const char * axl_node_get_attribute_value_trimmed (axlNode
* node
,
162 const char * attribute
);
165 * @brief Convenience macro wrapping \ref
166 * axl_node_has_attribute_value.
168 #define HAS_ATTR_VALUE(node, attr,value) (axl_node_has_attribute_value (node, attr, value))
170 bool axl_node_has_attribute_value (axlNode
* node
,
171 const char * attribute
,
174 bool axl_node_has_attributes (axlNode
* node
);
181 * \addtogroup axl_node_attribute_cursor
185 /* XML node attribute iteration API provided to traverse all
186 * attributes without knowing them. */
187 axlAttrCursor
* axl_node_attr_cursor_new (axlNode
* node
);
189 void axl_node_attr_cursor_first (axlAttrCursor
* cursor
);
191 void axl_node_attr_cursor_next (axlAttrCursor
* cursor
);
193 bool axl_node_attr_cursor_has_next (axlAttrCursor
* cursor
);
195 bool axl_node_attr_cursor_has_item (axlAttrCursor
* cursor
);
197 const char * axl_node_attr_cursor_get_key (axlAttrCursor
* cursor
);
199 const char * axl_node_attr_cursor_get_value (axlAttrCursor
* cursor
);
201 void axl_node_attr_cursor_free (axlAttrCursor
* cursor
);
203 void axl_node_attr_foreach (axlNode
* node
,
204 axlNodeAttrForeachFunc func
,
214 * \addtogroup axl_node_annotate
218 void axl_node_annotate_data (axlNode
* node
,
222 void axl_node_annotate_data_full (axlNode
* node
,
224 axlDestroyFunc key_destroy
,
226 axlDestroyFunc data_destroy
);
228 axlPointer
axl_node_annotate_get (axlNode
* node
,
230 bool lookup_in_parent
);
232 void axl_node_annotate_int (axlNode
* node
,
236 void axl_node_annotate_string (axlNode
* node
,
238 const char * string_value
);
240 void axl_node_annotate_double (axlNode
* node
,
242 double double_value
);
244 int axl_node_annotate_get_int (axlNode
* node
,
246 bool lookup_in_parent
);
248 char * axl_node_annotate_get_string (axlNode
* node
,
250 bool lookup_in_parent
);
252 double axl_node_annotate_get_double (axlNode
* node
,
254 bool lookup_in_parent
);
262 * \addtogroup axl_node_module
267 * @brief Allows to easily check that the given xml node (\ref
268 * axlNode) have the provided name.
270 * This macro is provided as a convenience to check that a particular
271 * node have a particular name. Check the documentation that this
272 * macro is wrapping to get examples: \ref axl_node_get_name.
274 * <i><b>NOTE:</b> This function isn't XML Namespace aware. You must use \ref axl_ns_node_cmp instead. See \ref axl_ns_doc_validate. </i>
276 * @param node The \ref axlNode where the name will be compared with
277 * the provided value.
279 * @param name The name to compare.
281 * @return \ref true if names are equal or \ref false if not.
283 #define NODE_CMP_NAME(node,name) (axl_cmp ((node != NULL) ? axl_node_get_name(node) : "><", (name != NULL) ? name : "<>"))
285 const char * axl_node_get_name (axlNode
* node
);
287 axlNode
* axl_node_get_parent (axlNode
* node
);
289 axlNode
* axl_node_get_next (axlNode
* node
);
291 axlNode
* axl_node_get_next_called (axlNode
* node
,
294 axlNode
* axl_node_get_previous (axlNode
* node
);
296 axlNode
* axl_node_get_previous_called (axlNode
* node
,
299 axlNode
* axl_node_get_first_child (axlNode
* node
);
301 axlNode
* axl_node_get_last_child (axlNode
* node
);
303 void axl_node_set_child (axlNode
* parent
,
306 void axl_node_set_child_after (axlNode
* reference
,
309 void axl_node_replace (axlNode
* node
,
313 void axl_node_remove (axlNode
* node
,
316 void axl_node_deattach (axlNode
* node
);
319 void axl_node_set_is_empty (axlNode
* node
,
322 bool axl_node_is_empty (axlNode
* node
);
324 const char * axl_node_get_content (axlNode
* node
,
327 char * axl_node_get_content_copy (axlNode
* node
,
330 char * axl_node_get_content_trans (axlNode
* node
,
333 char * axl_node_get_content_trim (axlNode
* node
,
336 void axl_node_set_content (axlNode
* node
,
337 const char * content
,
340 void axl_node_set_content_ref (axlNode
* node
,
344 void axl_node_set_content_from_factory (axlFactory
* factory
,
349 void axl_node_set_cdata_content (axlNode
* node
,
353 void axl_node_set_cdata_content_from_factory (axlFactory
* factory
,
358 void axl_node_set_comment (axlNode
* node
,
362 void axl_node_set_have_childs (axlNode
* node
, bool childs
);
364 bool axl_node_have_childs (axlNode
* node
);
366 axlNode
* axl_node_get_child_called (axlNode
* parent
, char * name
);
368 axlNode
* axl_node_find_called (axlNode
* parent
, char * name
);
370 axlNode
* axl_node_get_child_nth (axlNode
* parent
, int position
);
372 int axl_node_get_child_num (axlNode
* parent
);
374 axlList
* axl_node_get_childs (axlNode
* node
);
376 bool axl_node_are_equal (axlNode
* node
, axlNode
* node2
);
378 void axl_node_add_pi_target (axlNode
* node
,
382 bool axl_node_has_pi_target (axlNode
* node
,
385 char * axl_node_get_pi_target_content (axlNode
* node
,
388 axlList
* axl_node_get_pi_target_list (axlNode
* node
);
390 void axl_node_transfer_childs (axlNode
* old_parent
,
391 axlNode
* new_parent
);
393 bool axl_node_dump (axlNode
* node
,
397 bool axl_node_dump_pretty (axlNode
* node
,
402 bool axl_node_dump_to_file (axlNode
* node
,
405 bool axl_node_dump_pretty_to_file (axlNode
* node
,
409 int axl_node_get_flat_size (axlNode
* node
,
414 int axl_node_dump_at (axlNode
* node
,
421 bool axl_node_has_invalid_chars (const char * content
,
425 char * axl_node_content_copy_and_escape (const char * content
,
427 int additional_size
);
429 void axl_node_free (axlNode
* node
);
431 void axl_node_free_full (axlNode
* node
, bool also_childs
);
437 axlItem
* axl_item_new (AxlItemType type
,
440 axlItem
* axl_item_new_ref (AxlItemType type
,
443 axlDoc
* axl_item_get_doc (axlItem
* item
);
445 void axl_item_set_doc (axlItem
* item
, axlDoc
* doc
);
447 axlNode
* axl_item_get_parent (axlItem
* item
);
449 axlItem
* axl_item_get_next (axlItem
* item
);
451 axlItem
* axl_item_node_next (axlNode
* node
);
453 axlItem
* axl_item_get_previous (axlItem
* item
);
455 axlItem
* axl_item_node_previous (axlNode
* node
);
457 axlItem
* axl_item_node_holder (axlNode
* node
);
459 axlItem
* axl_item_get_first_child (axlNode
* node
);
461 axlItem
* axl_item_get_last_child (axlNode
* node
);
463 AxlItemType
axl_item_get_type (axlItem
* item
);
465 axlPointer
axl_item_get_data (axlItem
* item
);
467 char * axl_item_get_content (axlItem
* item
,
470 void axl_item_set_child (axlNode
* parent
,
474 void axl_item_set_child_ref (axlNode
* parent
,
477 void axl_item_set_after (axlItem
* item
,
481 axlItem
* axl_item_copy (axlItem
* item
,
482 axlNode
* set_parent
);
484 void axl_item_remove (axlItem
* item
,
487 void axl_item_replace (axlItem
* item
,
491 void axl_item_transfer_childs_after (axlNode
* old_parent
,
494 bool axl_item_are_equal (axlItem
* item
,
498 void axl_item_free (axlItem
* item
,
501 axlFactory
* axl_item_factory_create ();
503 axlItem
* axl_item_factory_get (axlFactory
* factory
);
505 axlFactory
* axl_node_factory_create ();
507 axlNode
* axl_node_factory_get (axlFactory
* factory
);
509 axlFactory
* axl_item_content_factory_create ();
511 axlFactory
* axl_item_attr_factory_create ();