[gxml/gsoc2013] examples/js: rename examples



commit a5bd04b73f16c5a50c22645dfa1fc7bee4c5d547
Author: Richard Schwarting <aquarichy gmail com>
Date:   Tue Aug 20 16:21:43 2013 -0400

    examples/js: rename examples

 examples/js/document_create.js                     |   64 ++++++++++----------
 examples/js/document_factory.js                    |   36 -----------
 examples/js/document_new.js                        |   34 ++++++++++
 ...eate_from_file.js => document_new_from_file.js} |    0
 ...eate_from_path.js => document_new_from_path.js} |    0
 ..._from_string.js => document_new_from_string.js} |    0
 6 files changed, 67 insertions(+), 67 deletions(-)
---
diff --git a/examples/js/document_create.js b/examples/js/document_create.js
index ee07b23..49a62f2 100755
--- a/examples/js/document_create.js
+++ b/examples/js/document_create.js
@@ -1,34 +1,36 @@
 #!/usr/bin/gjs
 
 const GXml = imports.gi.GXml;
-const Gio = imports.gi.Gio;
-
-function create_a_document () {
-    var authors = [ "John Green", "Jane Austen", "J.D. Salinger" ];
-    var titles = [ "The Fault in Our Stars", "Pride & Prejudice", "Nine Stories" ];
-
-    try {
-       let doc = GXml.Document.new ();
-       let root = doc.create_element ("Bookshelf");
-       doc.append_child (root);
-       let owner = doc.create_element ("Owner");
-       root.append_child (owner);
-       owner.set_attribute ("fullname", "John Green");
-
-       let books = doc.create_element ("Books");
-       root.append_child (books);
-
-       for (var i = 0; i < authors.length; i++) {
-           let book = doc.create_element ("Book");
-           book.set_attribute ("author", authors[i]);
-           book.set_attribute ("title", titles[i]);
-           books.append_child (book);
-       }
-
-       print ("create_a_document:\n" + doc.to_string (true, 4));
-    } catch (error) {
-       print (error.message);
-    }
-}
-
-create_a_document ();
+
+let doc = GXml.Document.new ();
+
+/* <book></book> */
+let elem = doc.create_element ("book");
+print ("Book element: " + elem.to_string (false, 0));
+
+let docfragment = doc.create_document_fragment ();
+print ("Fragment: " + docfragment.to_string (false, 0));
+
+/* <book>Between the book tags is text!</book> */
+let text = doc.create_text_node ("Between the book tags is text!");
+print ("Text: " + text.to_string (false, 0));
+
+/* <book><!-- comment: I really like this book -->The fault in our stars</book> */
+let comment = doc.create_comment ("comment: I really like this book");
+print ("Comment: " + comment.to_string (false, 0));
+
+/* <![CDATA[non-XML data like code or special entities]]> */
+let cdata = doc.create_cdata_section ("non-XML data like code or special entities");
+print ("CDATA section: " + cdata.to_string (false, 0));
+
+/* <?xml href="style.xsl" type="text/xml"?> */
+let pi = doc.create_processing_instruction ("xml", "href=\"style.xsl\" type=\"text/xml\"");
+print ("Processing Instruction: " + pi.to_string (false, 0));
+
+/* <element id=""> */
+let attr = doc.create_attribute ("id");
+print ("Attribute: " + attr.to_string (false, 0));
+
+/* &apos;   (for an apostrophe, ') */
+let entref = doc.create_entity_reference ("apos");
+print ("Entity reference: " + entref.to_string (false, 0));
diff --git a/examples/js/document_new.js b/examples/js/document_new.js
new file mode 100755
index 0000000..ee07b23
--- /dev/null
+++ b/examples/js/document_new.js
@@ -0,0 +1,34 @@
+#!/usr/bin/gjs
+
+const GXml = imports.gi.GXml;
+const Gio = imports.gi.Gio;
+
+function create_a_document () {
+    var authors = [ "John Green", "Jane Austen", "J.D. Salinger" ];
+    var titles = [ "The Fault in Our Stars", "Pride & Prejudice", "Nine Stories" ];
+
+    try {
+       let doc = GXml.Document.new ();
+       let root = doc.create_element ("Bookshelf");
+       doc.append_child (root);
+       let owner = doc.create_element ("Owner");
+       root.append_child (owner);
+       owner.set_attribute ("fullname", "John Green");
+
+       let books = doc.create_element ("Books");
+       root.append_child (books);
+
+       for (var i = 0; i < authors.length; i++) {
+           let book = doc.create_element ("Book");
+           book.set_attribute ("author", authors[i]);
+           book.set_attribute ("title", titles[i]);
+           books.append_child (book);
+       }
+
+       print ("create_a_document:\n" + doc.to_string (true, 4));
+    } catch (error) {
+       print (error.message);
+    }
+}
+
+create_a_document ();
diff --git a/examples/js/document_create_from_file.js b/examples/js/document_new_from_file.js
similarity index 100%
rename from examples/js/document_create_from_file.js
rename to examples/js/document_new_from_file.js
diff --git a/examples/js/document_create_from_path.js b/examples/js/document_new_from_path.js
similarity index 100%
rename from examples/js/document_create_from_path.js
rename to examples/js/document_new_from_path.js
diff --git a/examples/js/document_create_from_string.js b/examples/js/document_new_from_string.js
similarity index 100%
rename from examples/js/document_create_from_string.js
rename to examples/js/document_new_from_string.js


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