[gxml] * implement append_child for Document to make it easier to create a Document from scratch
- From: Richard Hans Schwarting <rschwart src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gxml] * implement append_child for Document to make it easier to create a Document from scratch
- Date: Sun, 17 Jun 2012 18:55:17 +0000 (UTC)
commit e56bfe029197b23d2204a29ff34825d159b00df5
Author: Richard Schwarting <aquarichy gmail com>
Date: Sun Jun 17 14:55:08 2012 -0400
* implement append_child for Document to make it easier to create a Document from scratch
gxml/Document.vala | 24 ++++++++++++++++++++++++
1 files changed, 24 insertions(+), 0 deletions(-)
---
diff --git a/gxml/Document.vala b/gxml/Document.vala
index c8c3dc7..3255990 100644
--- a/gxml/Document.vala
+++ b/gxml/Document.vala
@@ -528,5 +528,29 @@ namespace GXmlDom {
return str;
}
+
+ /*** XNode methods ***/
+
+ /**
+ * Appends new_child to this document. A document can
+ * only have one Element child, the root element, and
+ * one DocumentType.
+ *
+ * @return The newly added child.
+ */
+ public XNode? append_child (XNode new_child) throws DomError {
+ if (new_child.node_type == NodeType.ELEMENT) {
+ if (xmldoc->get_root_element () == null) {
+ xmldoc->set_root_element (((Element)new_child).node);
+ } else {
+ throw new DomError.HIERARCHY_REQUEST ("Document already has a root element. Could not add child element with name '%s'".printf (new_child.node_name));
+ }
+ } else if (new_child.node_type == NodeType.DOCUMENT_TYPE) {
+ GLib.warning ("Appending document_types not yet supported");
+ } else {
+ GLib.warning ("Appending '%s' not yet supported", new_child.node_type.to_string ());
+ }
+ return null;
+ }
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]