[libxml++] Move add_child() methods from Node to Element
- From: Kjell Ahlstedt <kjellahl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libxml++] Move add_child() methods from Node to Element
- Date: Mon, 28 Sep 2015 14:06:35 +0000 (UTC)
commit fb20606fb058d3d1048ccf616475a163a5ea742c
Author: Kjell Ahlstedt <kjell ahlstedt bredband net>
Date: Mon Sep 28 16:01:57 2015 +0200
Move add_child() methods from Node to Element
* libxml++/nodes/element.[h|cc]:
* libxml++/nodes/node.[h|cc]: Move all add_child*() methods to Element and
rename them to add_child_element*().
* examples/dom_build/main.cc:
* examples/dom_update_namespace/main.cc:
* examples/dtdvalidation/main.cc:
* examples/sax_parser_build_dom/svgparser.cc: Change add_child() to
add_child_element(). Bug #754673.
examples/dom_build/main.cc | 9 +--
examples/dom_update_namespace/main.cc | 10 +-
examples/dtdvalidation/main.cc | 7 +-
examples/sax_parser_build_dom/svgparser.cc | 4 +-
libxml++/nodes/element.cc | 135 +++++++++++++++++++++++++++-
libxml++/nodes/element.h | 109 ++++++++++++++++++++++-
libxml++/nodes/node.cc | 135 ----------------------------
libxml++/nodes/node.h | 108 ----------------------
8 files changed, 250 insertions(+), 267 deletions(-)
---
diff --git a/examples/dom_build/main.cc b/examples/dom_build/main.cc
index c1409bd..f22b493 100644
--- a/examples/dom_build/main.cc
+++ b/examples/dom_build/main.cc
@@ -1,5 +1,3 @@
-// -*- C++ -*-
-
/* main.cc
*
* Copyright (C) 2002 The libxml++ development team
@@ -48,7 +46,7 @@ main(int /* argc */, char** /* argv */)
nodeRoot->set_namespace_declaration("http://foobar", "foobar"); //Also associate this prefix with this
namespace:
nodeRoot->set_child_text("\n");
- auto nodeChild = nodeRoot->add_child("examplechild");
+ auto nodeChild = nodeRoot->add_child_element("examplechild");
//Associate prefix with namespace:
nodeChild->set_namespace_declaration("http://bar", "bar");
@@ -62,9 +60,9 @@ main(int /* argc */, char** /* argv */)
nodeChild->add_child_text("\n");
nodeChild->add_child_processing_instruction("application1", "This is an example node");
nodeChild->add_child_text("\n");
- nodeChild->add_child("child_of_child", "bar");
+ nodeChild->add_child_element("child_of_child", "bar");
- nodeChild = nodeRoot->add_child("examplechild", "foobar"); //foobar is the namespace prefix
+ nodeChild = nodeRoot->add_child_element("examplechild", "foobar"); //foobar is the namespace prefix
nodeChild->set_attribute("id", "2", "foobar"); //foobar is the namespace prefix.
auto whole = document.write_to_string();
@@ -79,4 +77,3 @@ main(int /* argc */, char** /* argv */)
return EXIT_SUCCESS;
}
-
diff --git a/examples/dom_update_namespace/main.cc b/examples/dom_update_namespace/main.cc
index 9a733c2..ed46041 100644
--- a/examples/dom_update_namespace/main.cc
+++ b/examples/dom_update_namespace/main.cc
@@ -100,10 +100,10 @@ void TestNamespace::test_create_new_node_with_default_namespace()
"Input file shouldn't have any child in alternate default namespace");
// Add child nodes in default namespace and check document again
- auto child = root_->add_child("child");
+ auto child = root_->add_child_element("child");
child->set_namespace_declaration(nsmap_["ns1"], "");
root_->add_child_text("\n");
- root_->add_child_with_new_ns("child", nsmap_["ns1"]);
+ root_->add_child_element_with_new_ns("child", nsmap_["ns1"]);
root_->add_child_text("\n");
std::cout << " File " << filename << " after modification" << std::endl
@@ -128,12 +128,12 @@ void TestNamespace::test_create_new_node_using_existing_namespace_prefix()
"Input file shouldn't have any child in child namespace");
// Add child nodes with specific namespace and check document again
- auto child = root_->add_child("child", "ns0");
+ auto child = root_->add_child_element("child", "ns0");
child->set_namespace_declaration(nsmap_["ns1"], "");
root_->add_child_text("\n");
- root_->add_child_with_new_ns("child", nsmap_["ns1"]);
+ root_->add_child_element_with_new_ns("child", nsmap_["ns1"]);
root_->add_child_text("\n");
- root_->add_child_with_new_ns("child", nsmap_["ns1"], "ns3");
+ root_->add_child_element_with_new_ns("child", nsmap_["ns1"], "ns3");
root_->add_child_text("\n");
std::cout << " File " << filename << " after modification" << std::endl
diff --git a/examples/dtdvalidation/main.cc b/examples/dtdvalidation/main.cc
index d5e594f..6c10acc 100644
--- a/examples/dtdvalidation/main.cc
+++ b/examples/dtdvalidation/main.cc
@@ -1,5 +1,3 @@
-// -*- C++ -*-
-
/* main.cc
*
* Copyright (C) 2002 The libxml++ development team
@@ -61,9 +59,9 @@ int main(int argc, char* argv[])
}
/* auto nodeRoot2 = */document.create_root_node("example");
- auto child = document.get_root_node()->add_child("examplechild");
+ auto child = document.get_root_node()->add_child_element("examplechild");
child->set_attribute("id", "an_id");
- child->add_child("child_of_child");
+ child->add_child_element("child_of_child");
try
{
@@ -85,4 +83,3 @@ int main(int argc, char* argv[])
}
return return_code;
}
-
diff --git a/examples/sax_parser_build_dom/svgparser.cc b/examples/sax_parser_build_dom/svgparser.cc
index 6e474a7..b90592e 100644
--- a/examples/sax_parser_build_dom/svgparser.cc
+++ b/examples/sax_parser_build_dom/svgparser.cc
@@ -1,5 +1,3 @@
-// -*- C++ -*-
-
/* svgparser.cc
*
* By Dan Dennedy <dan dennedy org>
@@ -69,7 +67,7 @@ void Parser::on_start_element(const Glib::ustring& name,
else
{
// Create the other elements as child nodes of the last nodes:
- element_normal = m_context.top()->add_child(elementName);
+ element_normal = m_context.top()->add_child_element(elementName);
}
// TODO: The following is a hack because it leverages knowledge of libxml++
diff --git a/libxml++/nodes/element.cc b/libxml++/nodes/element.cc
index ea97f6b..d6b1df9 100644
--- a/libxml++/nodes/element.cc
+++ b/libxml++/nodes/element.cc
@@ -10,6 +10,22 @@
#include <libxml/tree.h>
+namespace // anonymous
+{
+// Common part of all add_child_element*() methods.
+xmlpp::Element* add_child_element_common(const Glib::ustring& name, xmlNode* child, xmlNode* node)
+{
+ if (!node)
+ {
+ xmlFreeNode(child);
+ throw xmlpp::internal_error("Could not add child element node " + name);
+ }
+ xmlpp::Node::create_wrapper(node);
+ return static_cast<xmlpp::Element*>(node->_private);
+}
+
+} // anonymous namespace
+
namespace xmlpp
{
@@ -128,6 +144,123 @@ void Element::remove_attribute(const Glib::ustring& name, const Glib::ustring& n
}
}
+Element* Element::add_child_element(const Glib::ustring& name,
+ const Glib::ustring& ns_prefix)
+{
+ auto child = create_new_child_element_node(name, ns_prefix);
+ auto node = xmlAddChild(cobj(), child);
+ return add_child_element_common(name, child, node);
+}
+
+Element* Element::add_child_element(xmlpp::Node* previous_sibling,
+ const Glib::ustring& name, const Glib::ustring& ns_prefix)
+{
+ if (!previous_sibling)
+ return 0;
+
+ auto child = create_new_child_element_node(name, ns_prefix);
+ auto node = xmlAddNextSibling(previous_sibling->cobj(), child);
+ return add_child_element_common(name, child, node);
+}
+
+Element* Element::add_child_element_before(xmlpp::Node* next_sibling,
+ const Glib::ustring& name, const Glib::ustring& ns_prefix)
+{
+ if (!next_sibling)
+ return 0;
+
+ auto child = create_new_child_element_node(name, ns_prefix);
+ auto node = xmlAddPrevSibling(next_sibling->cobj(), child);
+ return add_child_element_common(name, child, node);
+}
+
+Element* Element::add_child_element_with_new_ns(const Glib::ustring& name,
+ const Glib::ustring& ns_uri, const Glib::ustring& ns_prefix)
+{
+ auto child = create_new_child_element_node_with_new_ns(name, ns_uri, ns_prefix);
+ auto node = xmlAddChild(cobj(), child);
+ return add_child_element_common(name, child, node);
+}
+
+Element* Element::add_child_element_with_new_ns(xmlpp::Node* previous_sibling,
+ const Glib::ustring& name,
+ const Glib::ustring& ns_uri, const Glib::ustring& ns_prefix)
+{
+ if (!previous_sibling)
+ return 0;
+
+ auto child = create_new_child_element_node_with_new_ns(name, ns_uri, ns_prefix);
+ auto node = xmlAddNextSibling(previous_sibling->cobj(), child);
+ return add_child_element_common(name, child, node);
+}
+
+Element* Element::add_child_element_before_with_new_ns(xmlpp::Node* next_sibling,
+ const Glib::ustring& name,
+ const Glib::ustring& ns_uri, const Glib::ustring& ns_prefix)
+{
+ if (!next_sibling)
+ return 0;
+
+ auto child = create_new_child_element_node_with_new_ns(name, ns_uri, ns_prefix);
+ auto node = xmlAddPrevSibling(next_sibling->cobj(), child);
+ return add_child_element_common(name, child, node);
+}
+
+_xmlNode* Element::create_new_child_element_node(const Glib::ustring& name,
+ const Glib::ustring& ns_prefix)
+{
+ xmlNs* ns = nullptr;
+
+ if (cobj()->type != XML_ELEMENT_NODE)
+ throw internal_error("You can only add child nodes to element nodes");
+
+ if (ns_prefix.empty())
+ {
+ //Retrieve default namespace if it exists
+ ns = xmlSearchNs(cobj()->doc, cobj(), 0);
+ }
+ else
+ {
+ //Use the existing namespace if one exists:
+ ns = xmlSearchNs(cobj()->doc, cobj(), (const xmlChar*)ns_prefix.c_str());
+ if (!ns)
+ throw exception("The namespace prefix (" + ns_prefix + ") has not been declared.");
+ }
+
+ return xmlNewNode(ns, (const xmlChar*)name.c_str());
+}
+
+_xmlNode* Element::create_new_child_element_node_with_new_ns(const Glib::ustring& name,
+ const Glib::ustring& ns_uri, const Glib::ustring& ns_prefix)
+{
+ if (cobj()->type != XML_ELEMENT_NODE)
+ throw internal_error("You can only add child nodes to element nodes.");
+
+ auto child = xmlNewNode(0, (const xmlChar*)name.c_str());
+ if (!child)
+ throw internal_error("Could not create new element node.");
+
+ auto ns = xmlNewNs(child, (const xmlChar*)(ns_uri.empty() ? 0 : ns_uri.c_str()),
+ (const xmlChar*)(ns_prefix.empty() ? 0 : ns_prefix.c_str()) );
+ // xmlNewNs() does not create a namespace node for the predefined xml prefix.
+ // It's usually defined in the document and not in any specific node.
+ if (!ns && ns_prefix == "xml")
+ {
+ ns = xmlSearchNs(cobj()->doc, cobj(), (const xmlChar*)ns_prefix.c_str());
+ if (ns && (ns_uri != (ns->href ? (const char*)ns->href : "")))
+ ns = nullptr;
+ }
+ if (!ns)
+ {
+ xmlFreeNode(child);
+ throw internal_error("Could not create new namespace node.");
+ }
+
+ xmlSetNs(child, ns);
+
+ return child;
+}
+
const TextNode* Element::get_child_text() const
{
// FIXME: return only the first content node
@@ -272,7 +405,6 @@ Glib::ustring Element::get_namespace_uri_for_prefix(const Glib::ustring& ns_pref
return result;
}
-
CommentNode* Element::add_child_comment(const Glib::ustring& content)
{
auto child = xmlNewComment((const xmlChar*)content.c_str());
@@ -288,7 +420,6 @@ CommentNode* Element::add_child_comment(const Glib::ustring& content)
return static_cast<CommentNode*>(node->_private);
}
-
CdataNode* Element::add_child_cdata(const Glib::ustring& content)
{
auto child = xmlNewCDataBlock(cobj()->doc, (const xmlChar*)content.c_str(), content.bytes());
diff --git a/libxml++/nodes/element.h b/libxml++/nodes/element.h
index 5bb1aa3..472c402 100644
--- a/libxml++/nodes/element.h
+++ b/libxml++/nodes/element.h
@@ -108,15 +108,110 @@ public:
void remove_attribute(const Glib::ustring& name,
const Glib::ustring& ns_prefix = Glib::ustring());
+ /** Add a child element to this node.
+ *
+ * @newin{3,0} Replaces Node::add_child()
+ *
+ * @param name The new node name
+ * @param ns_prefix The namespace prefix. If the prefix has not been declared then this method will throw
an exception.
+ * @returns The newly-created element
+ * @throws xmlpp::exception If a namespace prefix is specified, but has not been declared.
+ * @throws xmlpp::internal_error If this node is not an element node,
+ * or the child node cannot be created.
+ */
+ Element* add_child_element(const Glib::ustring& name,
+ const Glib::ustring& ns_prefix = Glib::ustring());
+
+ /** Add a child element to this node after the specified existing child node.
+ *
+ * @newin{3,0} Replaces Node::add_child()
+ *
+ * @param previous_sibling An existing child node.
+ * @param name The new node name
+ * @param ns_prefix The namespace prefix. If the prefix has not been declared then this method will throw
an exception.
+ * @returns The newly-created element
+ * @throws xmlpp::exception If a namespace prefix is specified, but has not been declared.
+ * @throws xmlpp::internal_error If this node is not an element node,
+ * or the child node cannot be created.
+ */
+ Element* add_child_element(xmlpp::Node* previous_sibling, const Glib::ustring& name,
+ const Glib::ustring& ns_prefix = Glib::ustring());
+
+ /** Add a child element to this node before the specified existing child node.
+ *
+ * @newin{3,0} Replaces Node::add_child_before()
+ *
+ * @param next_sibling An existing child node.
+ * @param name The new node name
+ * @param ns_prefix The namespace prefix. If the prefix has not been declared then this method will throw
an exception.
+ * @returns The newly-created element
+ * @throws xmlpp::exception If a namespace prefix is specified, but has not been declared.
+ * @throws xmlpp::internal_error If this node is not an element node,
+ * or the child node cannot be created.
+ */
+ Element* add_child_element_before(xmlpp::Node* next_sibling, const Glib::ustring& name,
+ const Glib::ustring& ns_prefix = Glib::ustring());
+
+ /** Add a child element to this node.
+ *
+ * @newin{3,0} Replaces Node::add_child_with_new_ns()
+ *
+ * @param name The new node name.
+ * @param ns_uri The namespace to associate with the prefix,
+ * or to use as the default namespace if no prefix is specified.
+ * @param ns_prefix The prefix of the node's namespace. If no prefix is specified
+ * then the namespace URI will be the default namespace.
+ * @returns The newly-created element.
+ * @throws xmlpp::internal_error If this node is not an element node,
+ * or the child node or the namespace node cannot be created.
+ */
+ Element* add_child_element_with_new_ns(const Glib::ustring& name,
+ const Glib::ustring& ns_uri, const Glib::ustring& ns_prefix = Glib::ustring());
+
+ /** Add a child element to this node after the specified existing child node.
+ *
+ * @newin{3,0} Replaces Node::add_child_with_new_ns()
+ *
+ * @param previous_sibling An existing child node.
+ * @param name The new node name.
+ * @param ns_uri The namespace to associate with the prefix,
+ * or to use as the default namespace if no prefix is specified.
+ * @param ns_prefix The prefix of the node's namespace. If no prefix is specified
+ * then the namespace URI will be the default namespace.
+ * @returns The newly-created element.
+ * @throws xmlpp::internal_error If this node is not an element node,
+ * or the child node or the namespace node cannot be created.
+ */
+ Element* add_child_element_with_new_ns(xmlpp::Node* previous_sibling, const Glib::ustring& name,
+ const Glib::ustring& ns_uri, const Glib::ustring& ns_prefix = Glib::ustring());
+
+ /** Add a child element to this node before the specified existing child node.
+ *
+ * @newin{3,0} Replaces Node::add_child_before_with_new_ns()
+ *
+ * @param next_sibling An existing child node.
+ * @param name The new node name.
+ * @param ns_uri The namespace to associate with the prefix,
+ * or to use as the default namespace if no prefix is specified.
+ * @param ns_prefix The prefix of the node's namespace. If no prefix is specified
+ * then the namespace URI will be the default namespace.
+ * @returns The newly-created element.
+ * @throws xmlpp::internal_error If this node is not an element node,
+ * or the child node or the namespace node cannot be created.
+ */
+ Element* add_child_element_before_with_new_ns(xmlpp::Node* next_sibling, const Glib::ustring& name,
+ const Glib::ustring& ns_uri, const Glib::ustring& ns_prefix = Glib::ustring());
/** Get the first child text content node.
- * This is a convenience method, meant as an alternative to iterating over all the child nodes to find the
first suitable node then and getting the text directly.
+ * This is a convenience method, meant as an alternative to iterating over all the
+ * child nodes to find the first suitable node then and getting the text directly.
* @returns The first text node, if any.
*/
TextNode* get_child_text();
/** Get the first child text content node.
- * This is a convenience method, meant as an alternative to iterating over all the child nodes to find the
first suitable node then and getting the text directly.
+ * This is a convenience method, meant as an alternative to iterating over all the
+ * child nodes to find the first suitable node then and getting the text directly.
* @returns The first text node, if any.
*/
const TextNode* get_child_text() const;
@@ -205,8 +300,16 @@ public:
ProcessingInstructionNode* add_child_processing_instruction(
const Glib::ustring& name, const Glib::ustring& content);
-protected:
+private:
Glib::ustring get_namespace_uri_for_prefix(const Glib::ustring& ns_prefix) const;
+
+ ///Create the C instance ready to be added to the parent node.
+ _xmlNode* create_new_child_element_node(const Glib::ustring& name,
+ const Glib::ustring& ns_prefix);
+
+ ///Create the C instance ready to be added to the parent node.
+ _xmlNode* create_new_child_element_node_with_new_ns(const Glib::ustring& name,
+ const Glib::ustring& ns_uri, const Glib::ustring& ns_prefix);
};
} // namespace xmlpp
diff --git a/libxml++/nodes/node.cc b/libxml++/nodes/node.cc
index d9ba465..d8f54e6 100644
--- a/libxml++/nodes/node.cc
+++ b/libxml++/nodes/node.cc
@@ -213,18 +213,6 @@ Glib::ustring eval_common_to_string(const Glib::ustring& xpath,
return Glib::ustring();
}
-// Common part of all add_child*() methods.
-xmlpp::Element* add_child_common(const Glib::ustring& name, xmlNode* child, xmlNode* node)
-{
- if (!node)
- {
- xmlFreeNode(child);
- throw xmlpp::internal_error("Could not add child element node " + name);
- }
- xmlpp::Node::create_wrapper(node);
- return static_cast<xmlpp::Element*>(node->_private);
-}
-
} // anonymous namespace
namespace xmlpp
@@ -315,128 +303,6 @@ Node::const_NodeList Node::get_children(const Glib::ustring& name) const
return get_children_common<const_NodeList>(name, impl_->children);
}
-Element* Node::add_child(const Glib::ustring& name,
- const Glib::ustring& ns_prefix)
-{
- auto child = create_new_child_node(name, ns_prefix);
- auto node = xmlAddChild(impl_, child);
- return add_child_common(name, child, node);
-}
-
-Element* Node::add_child(xmlpp::Node* previous_sibling,
- const Glib::ustring& name,
- const Glib::ustring& ns_prefix)
-{
- if (!previous_sibling)
- return 0;
-
- auto child = create_new_child_node(name, ns_prefix);
- auto node = xmlAddNextSibling(previous_sibling->cobj(), child);
- return add_child_common(name, child, node);
-}
-
-Element* Node::add_child_before(xmlpp::Node* next_sibling,
- const Glib::ustring& name,
- const Glib::ustring& ns_prefix)
-{
- if (!next_sibling)
- return 0;
-
- auto child = create_new_child_node(name, ns_prefix);
- auto node = xmlAddPrevSibling(next_sibling->cobj(), child);
- return add_child_common(name, child, node);
-}
-
-Element* Node::add_child_with_new_ns(const Glib::ustring& name,
- const Glib::ustring& ns_uri, const Glib::ustring& ns_prefix)
-{
- auto child = create_new_child_node_with_new_ns(name, ns_uri, ns_prefix);
- auto node = xmlAddChild(impl_, child);
- return add_child_common(name, child, node);
-}
-
-Element* Node::add_child_with_new_ns(xmlpp::Node* previous_sibling,
- const Glib::ustring& name,
- const Glib::ustring& ns_uri, const Glib::ustring& ns_prefix)
-{
- if (!previous_sibling)
- return 0;
-
- auto child = create_new_child_node_with_new_ns(name, ns_uri, ns_prefix);
- auto node = xmlAddNextSibling(previous_sibling->cobj(), child);
- return add_child_common(name, child, node);
-}
-
-Element* Node::add_child_before_with_new_ns(xmlpp::Node* next_sibling,
- const Glib::ustring& name,
- const Glib::ustring& ns_uri, const Glib::ustring& ns_prefix)
-{
- if (!next_sibling)
- return 0;
-
- auto child = create_new_child_node_with_new_ns(name, ns_uri, ns_prefix);
- auto node = xmlAddPrevSibling(next_sibling->cobj(), child);
- return add_child_common(name, child, node);
-}
-
-_xmlNode* Node::create_new_child_node(const Glib::ustring& name, const Glib::ustring& ns_prefix)
-{
- xmlNs* ns = nullptr;
-
- if(impl_->type != XML_ELEMENT_NODE)
- {
- throw internal_error("You can only add child nodes to element nodes");
- }
-
- if(ns_prefix.empty())
- {
- //Retrieve default namespace if it exists
- ns = xmlSearchNs(impl_->doc, impl_, 0);
- }
- else
- {
- //Use the existing namespace if one exists:
- ns = xmlSearchNs(impl_->doc, impl_, (const xmlChar*)ns_prefix.c_str());
- if (!ns)
- {
- throw exception("The namespace prefix (" + ns_prefix + ") has not been declared.");
- }
- }
-
- return xmlNewNode(ns, (const xmlChar*)name.c_str());
-}
-
-_xmlNode* Node::create_new_child_node_with_new_ns(const Glib::ustring& name,
- const Glib::ustring& ns_uri, const Glib::ustring& ns_prefix)
-{
- if (impl_->type != XML_ELEMENT_NODE)
- throw internal_error("You can only add child nodes to element nodes.");
-
- auto child = xmlNewNode(0, (const xmlChar*)name.c_str());
- if (!child)
- throw internal_error("Could not create new element node.");
-
- auto ns = xmlNewNs(child, (const xmlChar*)(ns_uri.empty() ? 0 : ns_uri.c_str()),
- (const xmlChar*)(ns_prefix.empty() ? 0 : ns_prefix.c_str()) );
- // xmlNewNs() does not create a namespace node for the predefined xml prefix.
- // It's usually defined in the document and not in any specific node.
- if (!ns && ns_prefix == "xml")
- {
- ns = xmlSearchNs(impl_->doc, impl_, (const xmlChar*)ns_prefix.c_str());
- if (ns && (ns_uri != (ns->href ? (const char*)ns->href : "")))
- ns = nullptr;
- }
- if (!ns)
- {
- xmlFreeNode(child);
- throw internal_error("Could not create new namespace node.");
- }
-
- xmlSetNs(child, ns);
-
- return child;
-}
-
void Node::remove_child(Node* node)
{
//TODO: Allow a node to be removed without deleting it, to allow it to be moved?
@@ -788,5 +654,4 @@ void Node::free_wrappers(xmlNode* node)
free_wrappers(reinterpret_cast<xmlNode*>(attr));
}
-
} //namespace xmlpp
diff --git a/libxml++/nodes/node.h b/libxml++/nodes/node.h
index f5b6e55..02084eb 100644
--- a/libxml++/nodes/node.h
+++ b/libxml++/nodes/node.h
@@ -23,9 +23,7 @@ extern "C" {
namespace xmlpp
{
-class TextNode;
class Element;
-class Attribute;
// xmlpp::XPathResultType is similar to xmlXPathObjectType in libxml2.
/** An XPath expression is evaluated to yield a result, which
@@ -153,103 +151,6 @@ public:
*/
const_NodeList get_children(const Glib::ustring& name = Glib::ustring()) const;
- /** Add a child element to this node.
- * This node must be an element node.
- * @param name The new node name
- * @param ns_prefix The namespace prefix. If the prefix has not been declared then this method will throw
an exception.
- * @returns The newly-created element
- * @throws xmlpp::exception If a namespace prefix is specified, but has not been declared.
- * @throws xmlpp::internal_error If this node is not an element node,
- * or the child node cannot be created.
- */
- Element* add_child(const Glib::ustring& name,
- const Glib::ustring& ns_prefix = Glib::ustring());
-
- /** Add a child element to this node after the specified existing child node.
- * This node must be an element node.
- *
- * @newin{2,24}
- *
- * @param previous_sibling An existing child node.
- * @param name The new node name
- * @param ns_prefix The namespace prefix. If the prefix has not been declared then this method will throw
an exception.
- * @returns The newly-created element
- * @throws xmlpp::exception If a namespace prefix is specified, but has not been declared.
- * @throws xmlpp::internal_error If this node is not an element node,
- * or the child node cannot be created.
- */
- Element* add_child(xmlpp::Node* previous_sibling, const Glib::ustring& name,
- const Glib::ustring& ns_prefix = Glib::ustring());
-
- /** Add a child element to this node before the specified existing child node.
- * This node must be an element node.
- *
- * @newin{2,24}
- *
- * @param next_sibling An existing child node.
- * @param name The new node name
- * @param ns_prefix The namespace prefix. If the prefix has not been declared then this method will throw
an exception.
- * @returns The newly-created element
- * @throws xmlpp::exception If a namespace prefix is specified, but has not been declared.
- * @throws xmlpp::internal_error If this node is not an element node,
- * or the child node cannot be created.
- */
- Element* add_child_before(xmlpp::Node* next_sibling, const Glib::ustring& name,
- const Glib::ustring& ns_prefix = Glib::ustring());
-
- /** Add a child element to this node.
- * This node must be an element node.
- *
- * @newin{2,38}
- *
- * @param name The new node name.
- * @param ns_uri The namespace to associate with the prefix,
- * or to use as the default namespace if no prefix is specified.
- * @param ns_prefix The prefix of the node's namespace. If no prefix is specified
- * then the namespace URI will be the default namespace.
- * @returns The newly-created element.
- * @throws xmlpp::internal_error If this node is not an element node,
- * or the child node or the namespace node cannot be created.
- */
- Element* add_child_with_new_ns(const Glib::ustring& name,
- const Glib::ustring& ns_uri, const Glib::ustring& ns_prefix = Glib::ustring());
-
- /** Add a child element to this node after the specified existing child node.
- * This node must be an element node.
- *
- * @newin{2,38}
- *
- * @param previous_sibling An existing child node.
- * @param name The new node name.
- * @param ns_uri The namespace to associate with the prefix,
- * or to use as the default namespace if no prefix is specified.
- * @param ns_prefix The prefix of the node's namespace. If no prefix is specified
- * then the namespace URI will be the default namespace.
- * @returns The newly-created element.
- * @throws xmlpp::internal_error If this node is not an element node,
- * or the child node or the namespace node cannot be created.
- */
- Element* add_child_with_new_ns(xmlpp::Node* previous_sibling, const Glib::ustring& name,
- const Glib::ustring& ns_uri, const Glib::ustring& ns_prefix = Glib::ustring());
-
- /** Add a child element to this node before the specified existing child node.
- * This node must be an element node.
- *
- * @newin{2,38}
- *
- * @param next_sibling An existing child node.
- * @param name The new node name.
- * @param ns_uri The namespace to associate with the prefix,
- * or to use as the default namespace if no prefix is specified.
- * @param ns_prefix The prefix of the node's namespace. If no prefix is specified
- * then the namespace URI will be the default namespace.
- * @returns The newly-created element.
- * @throws xmlpp::internal_error If this node is not an element node,
- * or the child node or the namespace node cannot be created.
- */
- Element* add_child_before_with_new_ns(xmlpp::Node* next_sibling, const Glib::ustring& name,
- const Glib::ustring& ns_uri, const Glib::ustring& ns_prefix = Glib::ustring());
-
/** Remove the child node.
* @param node The child node to remove. This Node will be deleted and therefore unusable after calling
this method.
*/
@@ -421,15 +322,6 @@ public:
*/
static void free_wrappers(_xmlNode* node);
-protected:
-
- ///Create the C instance ready to be added to the parent node.
- _xmlNode* create_new_child_node(const Glib::ustring& name, const Glib::ustring& ns_prefix);
-
- ///Create the C instance ready to be added to the parent node.
- _xmlNode* create_new_child_node_with_new_ns(const Glib::ustring& name,
- const Glib::ustring& ns_uri, const Glib::ustring& ns_prefix);
-
private:
_xmlNode* impl_;
};
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]