xmldoc.c: Fix dump of xml document

The "xmldoc dump" cli command was simply concatenating xml documents
into the output file.  The resulting file had multiple "xml"
processing instructions and multiple root elements which is illegal.
Normally this isn't an issue because Asterisk has only 1 main xml
documentation file but codec_opus has its own file so if it's
downloaded and you do "xmldoc dump", the result is invalid.

* Added 2 new functions to xml.c:
    ast_xml_copy_node_list creates a copy of a list of children.
    ast_xml_add_child_list adds a list to an existing list.

* Modified handle_dump_docs to create a new output document and
  add to it the children from each input file.  It then dumps the
  new document to the output file.

Change-Id: I3f182d38c75776aee76413dadd2d489d54a85c07
This commit is contained in:
George Joseph
2018-07-20 05:20:25 -06:00
parent f4ddc56b9a
commit 58c7b64ed6
3 changed files with 78 additions and 5 deletions

View File

@@ -82,6 +82,23 @@ struct ast_xml_node *ast_xml_new_child(struct ast_xml_node *parent, const char *
*/
struct ast_xml_node *ast_xml_add_child(struct ast_xml_node *parent, struct ast_xml_node *child);
/*!
* \brief Add a list of child nodes, to a specified parent node.
* \param parent Where to add the child node.
* \param child The child list to add.
* \retval NULL on error.
* \retval non-NULL The added child list on success.
*/
struct ast_xml_node *ast_xml_add_child_list(struct ast_xml_node *parent, struct ast_xml_node *child);
/*!
* \brief Create a copy of a n ode list.
* \param list The list to copy.
* \retval NULL on error.
* \retval non-NULL The copied list.
*/
struct ast_xml_node *ast_xml_copy_node_list(struct ast_xml_node *list);
/*!
* \brief Close an already open document and free the used
* structure.