[gxml/gsoc2013: 62/150] Implementation.vala, Document.vala: support creation of documents from Implementation



commit 1f2283d7f23d03569d54c63e3c872bc4769a5646
Author: Richard Schwarting <aquarichy gmail com>
Date:   Sat Jul 27 00:01:29 2013 -0400

    Implementation.vala, Document.vala: support creation of documents from Implementation

 gxml/Document.vala       |   25 ++++++++++++++++++++++++-
 gxml/Implementation.vala |   14 ++++++++++++++
 2 files changed, 38 insertions(+), 1 deletions(-)
---
diff --git a/gxml/Document.vala b/gxml/Document.vala
index 6e03748..fc8005a 100644
--- a/gxml/Document.vala
+++ b/gxml/Document.vala
@@ -231,7 +231,30 @@ namespace GXml {
                        this.xmldoc->free ();
                }
 
-               /** Constructor */
+               /** Constructors */
+
+               /**
+                * Creates a Document from a given Implementation, supporting
+                * the {@ GXml.Implementation.create_document} method.  It is
+                * defined here:
+                * http://www.w3.org/TR/DOM-Level-3-Core/core.html#Level-2-Core-DOM-createDocument
+                *
+                * @param impl Implementation creating this Document.
+                * @param namespace_uri URI for the namespace in which this Document belongs, or `null`.
+                * @param qualified_name A qualified name for the Document, or `null`.
+                * @param doctype The type of the document, or `null`.
+                *
+                * @return The new document.
+                */
+               internal Document.with_implementation (Implementation impl, string? namespace_uri, string? 
qualified_name, DocumentType? doctype) {
+                       this ();
+                       this.implementation = impl;
+                       this.namespace_uri = namespace_uri;
+                       /* TODO: find out what should be set to qualified_name; perhaps this.node_name, but 
then that's supposed
+                          to be "#document" according to NodeType definitions in 
http://www.w3.org/TR/DOM-Level-3-Core/core.html */
+                       this.doctype = doctype;
+               }
+
                /**
                 * Creates a Document based on a libxml2 Xml.Doc* object.
                 */
diff --git a/gxml/Implementation.vala b/gxml/Implementation.vala
index 3b3b50a..7751ef6 100644
--- a/gxml/Implementation.vala
+++ b/gxml/Implementation.vala
@@ -38,6 +38,20 @@ namespace GXml {
                }
 
                /**
+                * Creates a Document according to this { link GXml.Implementation}.
+                *
+                * @param namespace_uri URI for the namespace in which this Document belongs, or `null`.
+                * @param qualified_name A qualified name for the Document, or `null`.
+                * @param doctype The type of the document, or `null`.
+                *
+                * @return The new document.
+                */
+               public Document create_document (string? namespace_uri, string? qualified_name, DocumentType? 
doctype) {
+                       Document doc = new Document.with_implementation (this, namespace_uri, qualified_name, 
doctype);
+                       return doc;
+               }
+
+               /**
                 * Reports whether we support a feature at a given version level.
                 *
                 * @param feature A feature we might support, usually something like 'xml' or 'html'.


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