1 /* 2 * libwbxml, the WBXML Library. 3 * Copyright (C) 2002-2008 Aymerick Jehanne <aymerick@jehanne.org> 4 * Copyright (C) 2011 Michael Bell <michael.bell@opensync.org> 5 * 6 * This library is free software; you can redistribute it and/or 7 * modify it under the terms of the GNU Lesser General Public 8 * License as published by the Free Software Foundation; either 9 * version 2.1 of the License, or (at your option) any later version. 10 * 11 * This library is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 * Lesser General Public License for more details. 15 * 16 * You should have received a copy of the GNU Lesser General Public 17 * License along with this library; if not, write to the Free Software 18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 19 * 20 * LGPL v2.1: http://www.gnu.org/copyleft/lesser.txt 21 * 22 * Contact: aymerick@jehanne.org 23 * Home: http://libwbxml.aymerick.com 24 */ 25 26 /** 27 * @file wbxml_tree.h 28 * @ingroup wbxml_tree 29 * 30 * @author Aymerick Jehanne <aymerick@jehanne.org> 31 * @date 03/02/16 32 * 33 * @brief WBXML Tree 34 */ 35 36 #ifndef WBXML_TREE_H 37 #define WBXML_TREE_H 38 39 #include "wbxml.h" 40 #include "wbxml_elt.h" 41 42 #ifdef __cplusplus 43 extern "C" { 44 #endif /* __cplusplus */ 45 46 #include "wbxml_config.h" 47 48 /** @addtogroup wbxml_tree 49 * @{ 50 */ 51 52 53 /**************************************************** 54 * WBXML Tree Structures 55 */ 56 57 58 /** 59 * @brief WBXML Tree Node Type 60 */ 61 typedef enum WBXMLTreeNodeType_e 62 { 63 WBXML_TREE_ELEMENT_NODE = 0, /**< Element Node */ 64 WBXML_TREE_TEXT_NODE, /**< Text Node */ 65 WBXML_TREE_CDATA_NODE, /**< CDATA Node */ 66 WBXML_TREE_PI_NODE, /**< PI Node */ 67 WBXML_TREE_TREE_NODE /**< WBXML Tree Node */ 68 } WBXMLTreeNodeType; 69 70 /** 71 * @brief WBXML Tree Node structure 72 */ 73 typedef struct WBXMLTreeNode_s 74 { 75 WBXMLTreeNodeType type; /**< Node Type */ 76 WBXMLTag *name; /**< Node Name (if type is 'WBXML_TREE_ELEMENT_NODE') */ 77 WBXMLList *attrs; /**< Node Attributes (if type is 'WBXML_TREE_ELEMENT_NODE') */ 78 WBXMLBuffer *content; /**< Node Content (if type is 'WBXML_TREE_TEXT_NODE') */ 79 struct WBXMLTree_s *tree; /**< Node Tree (if type is 'WBXML_TREE_TREE_NODE') */ 80 81 struct WBXMLTreeNode_s *parent; /**< Parent Node */ 82 struct WBXMLTreeNode_s *children; /**< Children Node */ 83 struct WBXMLTreeNode_s *next; /**< Next sibling Node */ 84 struct WBXMLTreeNode_s *prev; /**< Previous sibling Node */ 85 } WBXMLTreeNode; 86 87 88 /** 89 * @brief WBXML Tree structure 90 * 91 * This structure is created when parsing a WBXML or XML document, thanks to 92 * the functions wbxml_tree_from_wbxml() and wbxml_tree_from_xml(). 93 * 94 * It represents the parsed document, and have this fields: 95 * - lang: the language table of the parsed document (in wbxml_tables.c) 96 * - root: the root element of the Tree representing the parsed document 97 * - orig_charset: the original charset encoding of the parsed document 98 * 99 * @note All the strings inside the WBXML Tree are encoded into UTF-8 100 */ 101 typedef struct WBXMLTree_s 102 { 103 const WBXMLLangEntry *lang; /**< Language Table */ 104 WBXMLTreeNode *root; /**< Root Element */ 105 WBXMLCharsetMIBEnum orig_charset; /**< Charset encoding of original document */ 106 WB_UTINY cur_code_page;/**< Last seen code page */ 107 } WBXMLTree; 108 109 110 /** 111 * WBXML Tree Clb Context Structure 112 * @note Used by WBXML Tree Callbacks ('wbxml_tree_clb_wbxml.h' and 'wbxml_tree_clb_xml.h') 113 */ 114 typedef struct WBXMLTreeClbCtx_s { 115 /* For XML and WBXML Clb */ 116 WBXMLTree *tree; /**< The WBXML Tree we are constructing */ 117 WBXMLTreeNode *current; /**< Current Tree Node */ 118 WBXMLError error; /**< Error while parsing Document */ 119 /* For XML Clb */ 120 WB_ULONG skip_lvl; /**< Used to skip a whole XML node (used for SyncML) */ 121 WB_LONG skip_start; /**< Starting Skipping position in XML Document (used for SyncML) */ 122 WB_UTINY *input_buff; /**< Pointer to Input Buffer */ 123 #if defined( HAVE_EXPAT ) 124 XML_Parser xml_parser; /**< Pointer to Expat XML Parser */ 125 WB_BOOL expat_utf16; /**< Is Expat compiled to output UTF-16 ? */ 126 #endif /* HAVE_EXPAT */ 127 } WBXMLTreeClbCtx; 128 129 130 #if defined ( WBXML_SUPPORT_SYNCML ) 131 /** 132 * SyncML Data Type (the type of data inside <Data> element) 133 */ 134 typedef enum WBXMLSyncMLDataType_e { 135 WBXML_SYNCML_DATA_TYPE_NORMAL = 0, /**< Not specific Data Type */ 136 WBXML_SYNCML_DATA_TYPE_WBXML, /**< application/vnd.syncml-devinf+wbxml (WBXML Document) */ 137 WBXML_SYNCML_DATA_TYPE_CLEAR, /**< text/clear */ 138 WBXML_SYNCML_DATA_TYPE_DIRECTORY_VCARD, /**< text/directory;profile=vCard */ 139 WBXML_SYNCML_DATA_TYPE_VCARD, /**< text/x-vcard */ 140 WBXML_SYNCML_DATA_TYPE_VCALENDAR, /**< text/x-vcalendar */ 141 WBXML_SYNCML_DATA_TYPE_VOBJECT /**< Hack: we assume that any <Data> inside a <Replace> or <Add> Item is a vObjec (vCard / vCal / ...) */ 142 } WBXMLSyncMLDataType; 143 #endif /* WBXML_SUPPORT_SYNCML */ 144 145 146 /**************************************************** 147 * WBXML Tree Building Functions 148 */ 149 150 /** 151 * @brief Parse a WBXML document, using internal callbacks (in wbxml_tree_clb_wbxml.c), and construct a WBXML Tree 152 * @param wbxml [in] The WBXML document to parse 153 * @param wbxml_len [in] The WBXML document length 154 * @param lang [in] Can be used to force parsing of a given Language (set it to WBXML_LANG_UNKNOWN if you don't want to force anything) 155 * @param tree [out] The resulting WBXML Tree 156 * @result Return WBXML_OK if no error, an error code otherwise 157 */ 158 WBXML_DECLARE(WBXMLError) wbxml_tree_from_wbxml(WB_UTINY *wbxml, 159 WB_ULONG wbxml_len, 160 WBXMLLanguage lang, 161 WBXMLCharsetMIBEnum charset, 162 WBXMLTree **tree); 163 164 /** 165 * @brief Convert a WBXML Tree to a WBXML document 166 * @param tree [in] The WBXML Tree to convert 167 * @param wbxml [out] The resulting WBXML document 168 * @param wbxml_len [out] The resulting WBXML document length 169 * @param params [in] Parameters (if NULL, default values are used) 170 * @result Return WBXML_OK if no error, an error code otherwise 171 */ 172 WBXML_DECLARE(WBXMLError) wbxml_tree_to_wbxml(WBXMLTree *tree, 173 WB_UTINY **wbxml, 174 WB_ULONG *wbxml_len, 175 WBXMLGenWBXMLParams *params); 176 177 /** 178 * @brief Parse an XML document, using internal callbacks (in wbxml_tree_clb_xml.c), and construct a WBXML Tree 179 * @param xml [in] The XML document to parse 180 * @param xml_len [in] Length of the XML document 181 * @param tree [out] The resulting WBXML Tree 182 * @result Return WBXML_OK if no error, an error code otherwise 183 * @note Needs 'HAVE_EXPAT' compile flag 184 */ 185 WBXML_DECLARE(WBXMLError) wbxml_tree_from_xml(WB_UTINY *xml, 186 WB_ULONG xml_len, 187 WBXMLTree **tree); 188 189 /** 190 * @brief Convert a WBXML Tree to an XML document 191 * @param tree [in] The WBXML Tree to convert 192 * @param xml [out] The resulting XML document 193 * @param xml_len [out] The resulting XML document length 194 * @param params [in] Parameters (if NULL, default values are used) 195 * @result Return WBXML_OK if no error, an error code otherwise 196 */ 197 WBXML_DECLARE(WBXMLError) wbxml_tree_to_xml(WBXMLTree *tree, 198 WB_UTINY **xml, 199 WB_ULONG *xml_len, 200 WBXMLGenXMLParams *params); 201 202 /** @todo Libxml support ! */ 203 #if defined( HAVE_LIBXML ) 204 205 /** 206 * @brief Parse a LibXML document, and construct the corresponding WBXML Tree 207 * @param libxml_doc [in] The LibXML document to parse 208 * @param tree [out] The resulting WBXML Tree 209 * @result Return WBXML_OK if no error, an error code otherwise 210 * @note Needs 'HAVE_LIBXML' compile flag 211 */ 212 WBXML_DECLARE(WBXMLError) wbxml_tree_from_libxml_doc(xmlDocPtr libxml_doc, 213 WBXMLTree **tree); 214 215 /** 216 * @brief Parse a WBXML Tree, and construct the corresponding LibXML document 217 * @param tree [in] The WBXML Tree to parse 218 * @param libxml_doc [out] The resulting LibXML document 219 * @result Return WBXML_OK if no error, an error code otherwise 220 * @note Needs 'HAVE_LIBXML' compile flag 221 */ 222 WBXML_DECLARE(WBXMLError) wbxml_tree_to_libxml_doc(WBXMLTree *tree, 223 xmlDocPtr *libxml_doc); 224 225 #endif /* HAVE_LIBXML */ 226 227 228 /**************************************************** 229 * WBXML Tree Functions 230 */ 231 232 /** 233 * @brief Create a Tree Node structure 234 * @param type Node type 235 * @return The newly created Tree Node, or NULL if not enough memory 236 */ 237 WBXML_DECLARE(WBXMLTreeNode *) wbxml_tree_node_create(WBXMLTreeNodeType type); 238 239 /** 240 * @brief Destroy a Tree Node structure 241 * @param node The Tree Node structure to destroy 242 * @note The Node is freed, but not extracted from its WBXML Tree (use wbxml_tree_extract_node() before) 243 */ 244 WBXML_DECLARE(void) wbxml_tree_node_destroy(WBXMLTreeNode *node); 245 246 /** 247 * @brief Destroy a Tree Node structure (used for wbxml_list_destroy()) 248 * @param node The Tree Node structure to destroy 249 */ 250 WBXML_DECLARE(void) wbxml_tree_node_destroy_item(void *node); 251 252 /** 253 * @brief Destroy a Tree Node structure, and all its children 254 * @param node The Tree Node structure to destroy 255 * @note The Node (and its sub-tree) is freed, but not extracted from its WBXML Tree (use wbxml_tree_extract_node() before) 256 */ 257 WBXML_DECLARE(void) wbxml_tree_node_destroy_all(WBXMLTreeNode *node); 258 259 /** 260 * @brief Create a Tree Node structure, given the XML node name 261 * @param lang_table Language table 262 * @param name XML node name 263 * @return The newly created Tree Node, or NULL if not enough memory 264 */ 265 WBXML_DECLARE(WBXMLTreeNode *) wbxml_tree_node_create_xml_elt(const WBXMLLangEntry *lang_table, 266 const WB_UTINY *name); 267 268 /** 269 * @brief Create a Tree Node structure, given the XML node name and text content 270 * @param lang_table Language table 271 * @param name XML node name 272 * @param text Text content 273 * @param len Text content length 274 * @return The newly created Tree Node, or NULL if not enough memory 275 */ 276 WBXML_DECLARE(WBXMLTreeNode *) wbxml_tree_node_create_xml_elt_with_text(const WBXMLLangEntry *lang_table, 277 const WB_UTINY *name, 278 const WB_UTINY *text, 279 WB_ULONG len); 280 281 /** 282 * @brief Create a Text Node structure 283 * @param text Text content 284 * @param len Text content length 285 * @return The newly created Tree Node, or NULL if not enough memory 286 */ 287 WBXML_DECLARE(WBXMLTreeNode *) wbxml_tree_node_create_text(const WB_UTINY *text, 288 WB_ULONG len); 289 290 /** 291 * @brief Create a CDATA Node structure 292 * @param text Text content 293 * @param len Text content length 294 * @return The newly created Tree Node, or NULL if not enough memory 295 */ 296 WBXML_DECLARE(WBXMLTreeNode *) wbxml_tree_node_create_cdata(const WB_UTINY *text, 297 WB_ULONG len); 298 299 /** 300 * @brief Create a Tree Node structure 301 * @param root Root node for this Tree 302 * @param lang Language table to use 303 * @param orig_charset Original charset 304 * @return The newly created Tree Node, or NULL if not enough memory 305 */ 306 WBXML_DECLARE(WBXMLTreeNode *) wbxml_tree_node_create_tree(WBXMLTreeNode *root, 307 WBXMLLanguage lang, 308 WBXMLCharsetMIBEnum orig_charset); 309 310 /** 311 * @brief Add a Child node 312 * @param parent Parent node 313 * @param node Child node to add 314 * @return TRUE if added or FALSE if error 315 */ 316 WBXML_DECLARE(WB_BOOL) wbxml_tree_node_add_child(WBXMLTreeNode *parent, 317 WBXMLTreeNode *node); 318 319 /** 320 * @brief Extract a node 321 * @param node Node to extract 322 * @return TRUE if extracted or FALSE if error 323 */ 324 WBXML_DECLARE(WBXMLError) wbxml_tree_node_extract(WBXMLTreeNode *node); 325 326 /** 327 * @brief Add a WBXML Attribute to a Tree Node structure 328 * @param node The Tree Node to modify 329 * @param attr The WBXML Attribute to add 330 * @return WBXML_OK if no error, an error code otherwise 331 * @note This is only meanfull for an element node 332 */ 333 WBXML_DECLARE(WBXMLError) wbxml_tree_node_add_attr(WBXMLTreeNode *node, 334 WBXMLAttribute *attr); 335 336 /** 337 * @brief Add a WBXML Attributes list to a Tree Node structure 338 * @param node The Tree Node to modify 339 * @param attrs The WBXML Attributes to add 340 * @return WBXML_OK if no error, an error code otherwise 341 * @note This is only meanfull for an element node 342 */ 343 WBXML_DECLARE(WBXMLError) wbxml_tree_node_add_attrs(WBXMLTreeNode *node, 344 WBXMLAttribute **attrs); 345 346 /** 347 * @brief Add an XML Attribute to a Tree Node structure 348 * @param lang_table Language table 349 * @param node The Tree Node to modify 350 * @param name The XML Attribute name 351 * @param value The XML Attribute value 352 * @return WBXML_OK if no error, an error code otherwise 353 * @note This is only meanfull for an element node 354 */ 355 WBXML_DECLARE(WBXMLError) wbxml_tree_node_add_xml_attr(const WBXMLLangEntry *lang_table, 356 WBXMLTreeNode *node, 357 const WB_UTINY *name, 358 const WB_UTINY *value); 359 360 /** 361 * @brief Add an XML Attributes list to a Tree Node structure 362 * @param lang_table Language table 363 * @param node The Tree Node to modify 364 * @param attrs The XML Attributes to add 365 * @return WBXML_OK if no error, an error code otherwise 366 * @note This is only meanfull for an element node 367 */ 368 WBXML_DECLARE(WBXMLError) wbxml_tree_node_add_xml_attrs(const WBXMLLangEntry *lang_table, 369 WBXMLTreeNode *node, 370 const WB_UTINY **attrs); 371 372 /** 373 * @brief Get an Element Node, given the Element Name 374 * @param node The Tree Node where to start searching 375 * @param name The Element Name we are searching 376 * @param recurs If FALSE, only search into direct childs of 'node' 377 * @return The found Tree Node, or NULL if not found 378 */ 379 WBXML_DECLARE(WBXMLTreeNode *) wbxml_tree_node_elt_get_from_name(WBXMLTreeNode *node, 380 const char *name, 381 WB_BOOL recurs); 382 383 #if defined ( WBXML_SUPPORT_SYNCML ) 384 385 /** 386 * @brief Get the SyncML Data Type of this Tree Node 387 * @param node The Tree Node 388 * @return The SyncML Data Type of this Tree Node (cf: WBXMLSyncMLDataType enum) 389 * @note If no specific Data Type is found, this function returns 'WBXML_SYNCML_DATA_TYPE_NORMAL' 390 */ 391 WBXML_DECLARE(WBXMLSyncMLDataType) wbxml_tree_node_get_syncml_data_type(WBXMLTreeNode *node); 392 393 #endif /* WBXML_SUPPORT_SYNCML */ 394 395 /** 396 * @brief Check if a node have an Element Node in its children list 397 * @param node The Tree Node 398 * @return YES if one of the node children is an Element, FALSE otherwise 399 */ 400 WBXML_DECLARE(WB_BOOL) wbxml_tree_node_have_child_elt(WBXMLTreeNode *node); 401 402 /** 403 * @brief Get all children from node 404 * @param node The Tree Node 405 * @return A list of all children belonging to this node, or NULL if no children found 406 */ 407 WBXML_DECLARE(WBXMLList*) wbxml_tree_node_get_all_children(WBXMLTreeNode *node); 408 409 410 /** 411 * @brief Create a Tree structure 412 * @param lang Tree Language 413 * @param orig_charset Original tree charset 414 * @return The newly created Tree, or NULL if not enough memory 415 * @note The 'orig_charset' is used for further Tree encoding, it does NOT set 416 * the internal Tree representation charset (UTF8 is always used). 417 */ 418 WBXML_DECLARE(WBXMLTree *) wbxml_tree_create(WBXMLLanguage lang, 419 WBXMLCharsetMIBEnum orig_charset); 420 421 /** 422 * @brief Destroy a Tree structure, and all its nodes 423 * @param tree The Tree structure to destroy 424 */ 425 WBXML_DECLARE(void) wbxml_tree_destroy(WBXMLTree *tree); 426 427 /** 428 * @brief Add a Node to a Tree 429 * @param tree The Tree to modify 430 * @param parent Parent of the new Node (ie: Position where to add the new Node in Tree) 431 * @param node The new Tree Node to add 432 * @return TRUE is added, or FALSE if error. 433 * @note If 'parent' is NULL: if 'tree' already have a Root Element this function returns FALSE, else 'node' becomes the Root Element of 'tree' 434 */ 435 WBXML_DECLARE(WB_BOOL) wbxml_tree_add_node(WBXMLTree *tree, 436 WBXMLTreeNode *parent, 437 WBXMLTreeNode *node); 438 439 /** 440 * @brief Extract a Tree Node from its WBXML Tree 441 * @param tree The Tree to modify 442 * @param node The Tree Node to extract 443 * @return WBXML_OK if no error, an error code otherwise 444 * @note The node is extracted but not freed 445 */ 446 WBXML_DECLARE(WBXMLError) wbxml_tree_extract_node(WBXMLTree *tree, 447 WBXMLTreeNode *node); 448 449 /** 450 * @brief Add an Element Node to Tree, given its WBXML Tag 451 * @param tree The Tree to modify 452 * @param parent Parent of the new Node (ie: Position where to add the new Node in Tree) 453 * @param tag Element to add 454 * @return The newly created node, or NULL if error. 455 * @note If 'parent' is NULL: if 'tree' already have a Root Element this function returns NULL, else 'node' becomes the Root Element of 'tree' 456 */ 457 WBXML_DECLARE(WBXMLTreeNode *) wbxml_tree_add_elt(WBXMLTree *tree, 458 WBXMLTreeNode *parent, 459 WBXMLTag *tag); 460 461 /** 462 * @brief Add a Tag Element Node to Tree, with its WBXML Attributes 463 * @param tree The Tree to modify 464 * @param parent Parent of the new Node (ie: Position where to add the new Node in Tree) 465 * @param tag Element to add 466 * @param attrs Element attributes 467 * @return The newly created node, or NULL if error. 468 * @note If 'parent' is NULL: if 'tree' already have a Root Element this function returns NULL, else 'node' becomes the Root Element of 'tree' 469 */ 470 WBXML_DECLARE(WBXMLTreeNode *) wbxml_tree_add_elt_with_attrs(WBXMLTree *tree, 471 WBXMLTreeNode *parent, 472 WBXMLTag *tag, 473 WBXMLAttribute **attrs); 474 475 /** 476 * @brief Add an Element Node to a Tree, given its XML Name 477 * @param tree The Tree to modify 478 * @param parent Parent of the new Node (ie: Position where to add the new Node in Tree) 479 * @param name XML element name to add 480 * @return The newly created node, or NULL if error. 481 * @note If 'parent' is NULL: if 'tree' already have a Root Element this function returns NULL, else 'node' becomes the Root Element of 'tree' 482 */ 483 WBXML_DECLARE(WBXMLTreeNode *) wbxml_tree_add_xml_elt(WBXMLTree *tree, 484 WBXMLTreeNode *parent, 485 WB_UTINY *name); 486 487 /** 488 * @brief Add an Element Node to Tree, with its WBXML Attributes, given there XML values 489 * @param tree The Tree to modify 490 * @param parent Parent of the new Node (ie: Position where to add the new Node in Tree) 491 * @param name XML element name to add 492 * @param attrs XML element attributes 493 * @return The newly created node, or NULL if error. 494 * @note If 'parent' is NULL: if 'tree' already have a Root Element this function returns NULL, else 'node' becomes the Root Element of 'tree' 495 */ 496 WBXML_DECLARE(WBXMLTreeNode *) wbxml_tree_add_xml_elt_with_attrs(WBXMLTree *tree, 497 WBXMLTreeNode *parent, 498 WB_UTINY *name, 499 const WB_UTINY **attrs); 500 501 /** 502 * @brief Add a Text Node to Tree 503 * @param tree The Tree to modify 504 * @param parent Parent of the new Node (ie: Position where to add the new Node in Tree) 505 * @param text Text to add 506 * @param len Text length 507 * @return The newly created node, or NULL if error. 508 * @note If 'parent' is NULL: if 'tree' already have a Root Element this function returns NULL, else 'node' becomes the Root Element of 'tree' 509 */ 510 WBXML_DECLARE(WBXMLTreeNode *) wbxml_tree_add_text(WBXMLTree *tree, 511 WBXMLTreeNode *parent, 512 const WB_UTINY *text, 513 WB_ULONG len); 514 515 /** 516 * @brief Add CDATA Node to Tree 517 * @param tree The Tree to modify 518 * @param parent Parent of the new Node (ie: Position where to add the new Node in Tree) 519 * @return The newly created node, or NULL if error. 520 * @note If 'parent' is NULL: if 'tree' already have a Root Element this function returns NULL, else 'node' becomes the Root Element of 'tree' 521 */ 522 WBXML_DECLARE(WBXMLTreeNode *) wbxml_tree_add_cdata(WBXMLTree *tree, 523 WBXMLTreeNode *parent); 524 525 /** @todo wbxml_tree_add_cdata_with_text() */ 526 527 /** 528 * @brief Add a Tree Node to Tree 529 * @param tree The Tree to modify 530 * @param parent Parent of the new Node (ie: Position where to add the new Node in Tree) 531 * @param new_tree The new Tree to add (will be freed when destroying the main Tree, so caller must not free it) 532 * @return The newly created node, or NULL if error. 533 * @note If 'parent' is NULL: if 'tree' already have a Root Element this function returns NULL, else 'node' becomes the Root Element of 'tree' 534 */ 535 WBXML_DECLARE(WBXMLTreeNode *) wbxml_tree_add_tree(WBXMLTree *tree, 536 WBXMLTreeNode *parent, 537 WBXMLTree *new_tree); 538 539 /** 540 * @brief Add an Element Node to a Tree, given its XML Name, its attributes and a text content 541 * @param tree The Tree to modify 542 * @param parent Parent of the new Node (ie: Position where to add the new Node in Tree) 543 * @param name XML element name to add 544 * @param attrs XML element attributes 545 * @param text Text content for this new element 546 * @param len Text content length 547 * @return The newly created node, or NULL if error. 548 * @note If 'parent' is NULL: if 'tree' already have a Root Element this function returns NULL, else 'node' becomes the Root Element of 'tree' 549 */ 550 WBXML_DECLARE(WBXMLTreeNode *) wbxml_tree_add_xml_elt_with_attrs_and_text(WBXMLTree *tree, 551 WBXMLTreeNode *parent, 552 WB_UTINY *name, 553 const WB_UTINY **attrs, 554 const WB_UTINY *text, 555 WB_ULONG len); 556 557 /** @} */ 558 559 #ifdef __cplusplus 560 } 561 #endif /* __cplusplus */ 562 563 #endif /* WBXML_TREE_H */ 564