[gxml] Added GXml.Document.create_comment()



commit 495876e6e616d91fbdc5ecc7d06ac4e2132b7a7e
Author: Daniel Espinosa <esodan gmail com>
Date:   Mon May 4 12:25:50 2015 -0500

    Added GXml.Document.create_comment()
    
    * Implemented in xDocument
    * Renamed xDocument.create_comment to xDocument.create_managed_comment()
    * Updated Unit Tests

 gxml/Document.vala        |    7 +++++++
 gxml/libxml-Document.vala |   12 ++++++++++--
 test/DocumentTest.vala    |    6 +++---
 test/NodeTest.vala        |    8 ++++----
 4 files changed, 24 insertions(+), 9 deletions(-)
---
diff --git a/gxml/Document.vala b/gxml/Document.vala
index ab75099..4a9d5b0 100644
--- a/gxml/Document.vala
+++ b/gxml/Document.vala
@@ -50,4 +50,11 @@ public interface GXml.Document : Object, GXml.Node
    * { link GXml.Node}, like a { link GXml.Element} node.
    */
   public abstract GXml.Node create_text (string text);
+  /**
+   * Creates a new { link GXml.Text}.
+   *
+   * Is a matter of you to add as a child to any other
+   * { link GXml.Node}, like a { link GXml.Element} node.
+   */
+  //public abstract GXml.Node create_comment (string text);
 }
diff --git a/gxml/libxml-Document.vala b/gxml/libxml-Document.vala
index 86cb353..f4139da 100644
--- a/gxml/libxml-Document.vala
+++ b/gxml/libxml-Document.vala
@@ -666,7 +666,11 @@ namespace GXml {
                 * Creates an XML comment with data.  Its memory is
                 * freed when its owner document is freed.
                 *
-                * XML example: {{{<!-- data -->}}}
+                * XML example:
+                *
+                * {{{
+                *  <!-- data -->
+                * }}}
                 *
                 * Version: DOM Level 1 Core<<BR>>
                 * URL: [[http://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html#method-createComment]]
@@ -676,7 +680,7 @@ namespace GXml {
                 * @return A new { link GXml.Comment} containing the
                 * supplied data; this should not be freed
                 */
-               public unowned xComment create_comment (string comment_data) {
+               public unowned xComment create_managed_comment (string comment_data) {
                        // TODO: should we be passing around Xml.Node* like this?
                        xComment comment = new xComment (this.xmldoc->new_comment (comment_data), this);
                        unowned xComment ret = comment;
@@ -1013,5 +1017,9 @@ namespace GXml {
                public GLib.File file { get; set; }
                public virtual GXml.Node root { get { return document_element; } }
                public GXml.Node create_text (string str) { return (GXml.Node) this.create_text_node (str); }
+               public GXml.Node create_comment (string text)
+               {
+                       return create_managed_comment (text);
+               }
        }
 }
diff --git a/test/DocumentTest.vala b/test/DocumentTest.vala
index 487129b..7d2eac1 100644
--- a/test/DocumentTest.vala
+++ b/test/DocumentTest.vala
@@ -323,10 +323,10 @@ class DocumentTest : GXmlTest {
                        });
                Test.add_func ("/gxml/document/create_comment", () => {
                                xDocument doc = get_doc ();
-                               xComment comment = doc.create_comment ("Ever since the day we promised.");
+                               Comment comment = (GXml.Comment) doc.create_comment ("Ever since the day we 
promised.");
 
-                               assert (comment.node_name == "#comment");
-                               assert (comment.node_value == "Ever since the day we promised.");
+                               assert (comment.name == "#comment");
+                               assert (comment.str == "Ever since the day we promised.");
                        });
                Test.add_func ("/gxml/document/create_cdata_section", () => {
                                xDocument doc = get_doc ();
diff --git a/test/NodeTest.vala b/test/NodeTest.vala
index 9c6bbac..f6a9e51 100644
--- a/test/NodeTest.vala
+++ b/test/NodeTest.vala
@@ -60,8 +60,8 @@ class NodeTest : GXmlTest {
                                node = doc.create_processing_instruction ("target", "data");
                                assert (node.node_name == "target");
 
-                               node = doc.create_comment ("some comment");
-                               assert (node.node_name == "#comment");
+                               node = (xNode) doc.create_comment ("some comment");
+                               assert (node.name == "#comment");
 
                                assert (doc.node_name == "#document");
 
@@ -101,7 +101,7 @@ class NodeTest : GXmlTest {
                                node = doc.create_processing_instruction ("target", "data");
                                assert (node.node_type == NodeType.PROCESSING_INSTRUCTION);
 
-                               node = doc.create_comment ("some comment");
+                               node = (xNode) doc.create_comment ("some comment");
                                assert (node.node_type == NodeType.COMMENT);
 
                                assert (doc.node_type == NodeType.DOCUMENT);
@@ -145,7 +145,7 @@ class NodeTest : GXmlTest {
                                node = doc.create_processing_instruction ("target", "proc inst data");
                                assert (node.node_value == "proc inst data");
 
-                               node = doc.create_comment ("some comment");
+                               node = (xNode) doc.create_comment ("some comment");
                                assert (node.node_value == "some comment");
 
                                assert (doc.node_value == null);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]