[gxml/serialization] Merged 'master' and 'serialization' branches



commit db53456376d84d63af379e6de83bcd9b5b5118a4
Author: Daniel Espinosa <esodan gmail com>
Date:   Wed Oct 23 21:51:32 2013 -0500

    Merged 'master' and 'serialization' branches

 README                     |   33 ++++
 gxml/Attr.vala             |   32 ++--
 gxml/BackedNode.vala       |    1 +
 gxml/CDATASection.vala     |    3 +-
 gxml/CharacterData.vala    |   18 +-
 gxml/Comment.vala          |    3 +-
 gxml/Document.vala         |  413 +++++++++++++++++++++++++++++++++-----------
 gxml/DocumentFragment.vala |    2 +-
 gxml/DocumentType.vala     |    8 +-
 gxml/DomException.vala     |   13 +-
 gxml/Element.vala          |   74 +++++---
 gxml/Entity.vala           |    6 +-
 gxml/Error.vala            |   12 ++
 gxml/Implementation.vala   |   22 ++--
 gxml/Makefile.am           |    1 +
 gxml/Node.vala             |  143 +++++++++-------
 gxml/NodeList.vala         |   21 ++-
 gxml/Notation.vala         |    4 +-
 gxml/Serializable.vala     |    4 +-
 gxml/Text.vala             |    4 +-
 test/DocumentTest.vala     |  148 ++++++++++++++--
 test/GXmlTest.vala         |    8 +-
 vapi/glib-2.0.vapi         |  116 ++++++------
 vapi/libxml-2.0.vapi       |   44 +++++-
 24 files changed, 798 insertions(+), 335 deletions(-)
---
diff --git a/README b/README
index d8dff3d..b1dab74 100644
--- a/README
+++ b/README
@@ -24,3 +24,36 @@ Test: You can run the test suite, which is gxml_test, which you may
 
   $ cd test/
   $ ./gxml_test
+
+
+
+Writing documentation
+
+  We use Valadoc, http://www.valadoc.org/, which is probably the best
+  solution to generate both valadoc documentation and HTML gtk-doc
+  documentation.
+
+  Some notes:
+
+  - Documentation for overriding functions/methods is shown in
+    valadoc, but not in gtkdoc.  For gtkdoc, you can only go up to the
+    original superclass to see what's been available, even if it's
+    been overriden.  (Would we want this to be any different for
+    gtkdoc?)
+
+  - We don't get an Object Hierarchy in our gtkdoc with valadoc :(
+    TODO: write a patch to valadoc :D
+
+  - We can't highlight special macro values like NULL/null, TRUE/true,
+    or FALSE/false consistently.  For gtkdoc, you can use #NULL, but
+    then in the vala code, we see "#NULL" instead of "null", and the
+    reverse.
+    TODO: write a patch to valadoc :D
+
+  - Multiline descriptions will only have the first line appear in
+    valadoc.
+
+  - For the gtkdoc to be visible in devhelp and you're installing into
+    an abnormal prefix, consider placing a symlink to your prefix
+    installed gtk-doc in /usr/share/gtk-doc/html/.  For example,
+    $ ln -s ~/.local/share/gtk-doc/html/gxml /usr/share/gtk-doc/html
diff --git a/gxml/Attr.vala b/gxml/Attr.vala
index c5ed1da..ee4e1c2 100644
--- a/gxml/Attr.vala
+++ b/gxml/Attr.vala
@@ -38,19 +38,22 @@
 [CCode (gir_namespace = "GXml", gir_version = "0.3")]
 namespace GXml {
        /**
-        * Represents an XML Attr node, a name=value pair.
+        * An XML Attr node, which represents a name="value" pair.
+        *
+        * These represent name="value" attributes associated with XML Elements
+        * (see { link GXml.Element}). Values are often represented as strings but can
+        * also be more complex subtrees for some nodes.
         *
         * To create one, use { link GXml.Document.create_attribute}.
         *
-        * These represent name=value attributes associated with XML
-        * { link GXml.Element}s. Values are often represented as strings but can
-        * also be more complex subtrees for some nodes.
+        * XML Example: Here, we have an Attr with the name 'flavour'
+        * and the value 'pumpkin'. {{{<pie flavour="pumpkin" />}}}
         *
-        * XML Example: {{{<pie flavour="pumpkin" />}}} Here, we have
-        * an Attr with the name 'flavour' and the value 'pumpkin'.
+        * Version: DOM Level 1 Core<<BR>>
         *
-        * Version: DOM Level 1 Core
         * URL: [[http://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html#ID-637646024]]
+        *
+        * @see GXml.Node
         */
        public class Attr : Node {
                /**
@@ -58,14 +61,11 @@ namespace GXml {
                 */
                public override string? namespace_uri {
                        get {
-                               // TODO: there can be multiple NSes on a node, using ->next, right now we 
just return the first.  What should we do?!?!
                                if (this.node->ns == null) {
                                        return null;
                                } else {
                                        return this.node->ns->href;
                                }
-                               // TODO: handle null ns_def
-                               // TODO: figure out when node->ns is used, as opposed to ns_def
                        }
                        internal set {
                        }
@@ -108,8 +108,14 @@ namespace GXml {
 
                /* Public properties (Node general) */
 
+               /* TODO: find out how to get these to appear in GtkDocs, since they're
+                  overriding a base class.  Figure out how to get that multiple lines to
+                  appear in the generated valadoc */
                /**
                 * The node_name of an attribute is the attribute's name.
+                *
+                * Do not free this.  It's memory will be released
+                * when the owning { link GXml.Document} is freed.
                 */
                public override string node_name {
                        get {
@@ -171,7 +177,7 @@ namespace GXml {
                /**
                 * The name of the attribute's name=value pair.
                 *
-                * Version: DOM Level 1 Core
+                * Version: DOM Level 1 Core<<BR>>
                 * URL: [[http://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html#ID-1112119403]]
                 */
                public string name {
@@ -188,7 +194,7 @@ namespace GXml {
                 * underlying document. If the attribute is changed,
                 * it is set to false.
                 *
-                * Version: DOM Level 1 Core
+                * Version: DOM Level 1 Core<<BR>>
                 * URL: [[http://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html#ID-862529273]]
                 */
                /* @todo: this requires support from the DTD, and
@@ -206,7 +212,7 @@ namespace GXml {
                 * also be accessed as a tree node structure of
                 * child_nodes.
                 *
-                * Version: DOM Level 1 Core
+                * Version: DOM Level 1 Core<<BR>>
                 * URL: [[http://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html#ID-221662474]]
                 */
                public string value {
diff --git a/gxml/BackedNode.vala b/gxml/BackedNode.vala
index 4fd861b..07f885d 100644
--- a/gxml/BackedNode.vala
+++ b/gxml/BackedNode.vala
@@ -72,6 +72,7 @@ namespace GXml {
                 */
                public override string? namespace_uri {
                        get {
+                               // TODO: there can be multiple NSes on a node, using ->next, right now we 
just return the first.  What should we do?!?!
                                if (this.node->ns == null) {
                                        return null;
                                } else {
diff --git a/gxml/CDATASection.vala b/gxml/CDATASection.vala
index 906b9e2..a27b8e3 100644
--- a/gxml/CDATASection.vala
+++ b/gxml/CDATASection.vala
@@ -33,8 +33,7 @@ namespace GXml {
         * To create one, use { link GXml.Document.create_cdata_section}.
         *
         * An XML example would be like:
-        * {{{ <![CDATA[Here contains non-XML data, like code, or something that
-        * requires a lot of special XML entities.]]>. }}}
+        * {{{ <![CDATA[Here contains non-XML data, like code, or something that requires a lot of special 
XML entities.]]>.}}}
         * It is a type of Text node. For more, see: 
[[http://www.w3.org/TR/DOM-Level-1/level-one-core.html#ID-667469212]]
         */
        public class CDATASection : Text {
diff --git a/gxml/CharacterData.vala b/gxml/CharacterData.vala
index e0f7d3d..d28330f 100644
--- a/gxml/CharacterData.vala
+++ b/gxml/CharacterData.vala
@@ -30,7 +30,7 @@ namespace GXml {
         * It is used by the { link GXml.CDATASection},
         * { link GXml.Text}, and { link GXml.Comment} node types.
         *
-        * Version: DOM Level 1 Core
+        * Version: DOM Level 1 Core<<BR>>
         * URL: [[http://www.w3.org/TR/DOM-Level-1/level-one-core.html#ID-FF21A306]]
         */
        public class CharacterData : BackedNode {
@@ -38,7 +38,7 @@ namespace GXml {
                 * The character data in string form for the node.
                 * Generally equivalent to node_value.
                 *
-                * Version: DOM Level 1 Core
+                * Version: DOM Level 1 Core<<BR>>
                 * URL: [[http://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html#ID-72AB8359]]
                 */
                public string data {
@@ -54,7 +54,7 @@ namespace GXml {
                /**
                 * The number of characters.
                 *
-                * Version: DOM Level 1 Core
+                * Version: DOM Level 1 Core<<BR>>
                 * URL: [[http://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html#ID-7D61178C]]
                 */
                public ulong length {
@@ -70,7 +70,7 @@ namespace GXml {
                        // TODO: if this was this (), it would recurse infinitely, maybe valac could detect 
that
                }
 
-               protected bool check_index_size (string method, int length, ulong offset, ulong? count) {
+               internal bool check_index_size (string method, int length, ulong offset, ulong? count) {
                        if (offset < 0) {
                                GXml.warning (DomException.INDEX_SIZE, "%s called with offset '%lu' for data 
of length '%lu'".printf (method, offset, length));
                                return false;
@@ -99,7 +99,7 @@ namespace GXml {
                 * count-characters long, starting from the character
                 * at offset.
                 *
-                * Version: DOM Level 1 Core
+                * Version: DOM Level 1 Core<<BR>>
                 * URL: [[http://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html#ID-6531BCCF]]
                 */
                public string substring_data (ulong offset, ulong count) {
@@ -112,7 +112,7 @@ namespace GXml {
                /**
                 * Appends `new_segment` to the end of the character data.
                 *
-                * Version: DOM Level 1 Core
+                * Version: DOM Level 1 Core<<BR>>
                 * URL: [[http://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html#ID-32791A2F]]
                 *
                 * @param new_segment The new data that will be appended at the end
@@ -124,7 +124,7 @@ namespace GXml {
                /**
                 * Inserts `new_segment` into the character data at `offset`.
                 *
-                * Version: DOM Level 1 Core
+                * Version: DOM Level 1 Core<<BR>>
                 * URL: [[http://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html#ID-3EDB695F]]
                 *
                 * @param offset The index where the new data will be inserted
@@ -144,7 +144,7 @@ namespace GXml {
                /**
                 * Deletes a range of characters, `count`-characters long, starting from `offset`.
                 *
-                * Version: DOM Level 1 Core
+                * Version: DOM Level 1 Core<<BR>>
                 * URL: [[http://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html#ID-7C603781]]
                 *
                 * @param offset The index of the first character in the range to be deleted
@@ -162,7 +162,7 @@ namespace GXml {
                 * Replaces a range of characters, `count`-characters
                 * long, starting at `offset`, with `new_segment`.
                 *
-                * Version: DOM Level 1 Core
+                * Version: DOM Level 1 Core<<BR>>
                 * URL: [[http://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html#ID-E5CBA7FB]]
                 *
                 * @param offset The index of the first character in the range that will be replaced
diff --git a/gxml/Comment.vala b/gxml/Comment.vala
index f972026..b1a5148 100644
--- a/gxml/Comment.vala
+++ b/gxml/Comment.vala
@@ -30,8 +30,7 @@
  *
  * To create one, use { link GXml.Document.create_comment}.
  *
- * An XML example looks like: {{{
- * <someNode>
+ * An XML example looks like: {{{  <someNode>
  *    <!-- this is a comment -->
  *    text in the node
  *  </someNode> }}}
diff --git a/gxml/Document.vala b/gxml/Document.vala
index 8d49864..62ddcbd 100644
--- a/gxml/Document.vala
+++ b/gxml/Document.vala
@@ -67,11 +67,11 @@ namespace GXml {
        /**
         * Represents an XML Document as a tree of { link GXml.Node}s.
         *
-        * The Document has a document element, which is the root of
-        * the tree. A Document can have its type defined by a
+        * The Document has a root document element { link GXml.Element}.
+        * A Document's schema can be defined through its
         * { link GXml.DocumentType}.
         *
-        * Version: DOM Level 1 Core
+        * Version: DOM Level 1 Core<<BR>>
         * URL: [[http://www.w3.org/TR/DOM-Level-1/level-one-core.html#i-Document]]
         */
        public class Document : Node {
@@ -181,9 +181,9 @@ namespace GXml {
 
                // TODO: DTD, sort of works
                /**
-                * The Document Type Definition (DTD) defining this document. This may be `null`.
+                * The Document Type Definition (DTD) defining this document. This may be %NULL.
                 *
-                * Version: DOM Level 1 Core
+                * Version: DOM Level 1 Core<<BR>>
                 * URL: [[http://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html#attribute-doctype]]
                 */
                public DocumentType? doctype {
@@ -194,7 +194,7 @@ namespace GXml {
                /**
                 * Describes the features of the DOM implementation behind this document.
                 *
-                * Version: DOM Level 1 Core
+                * Version: DOM Level 1 Core<<BR>>
                 * URL: [[http://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html#attribute-implementation]]
                 */
                public Implementation implementation {
@@ -205,7 +205,7 @@ namespace GXml {
                /**
                 * The root node of the document's node tree.
                 *
-                * Version: DOM Level 1 Core
+                * Version: DOM Level 1 Core<<BR>>
                 * URL: [[http://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html#attribute-documentElement]]
                 */
                public Element document_element {
@@ -250,15 +250,15 @@ namespace GXml {
                 * Creates a Document from a given Implementation, supporting
                 * the {@ GXml.Implementation.create_document} method.
                 *
-                * Version: DOM Level 3 Core
+                * Version: DOM Level 3 Core<<BR>>
                 * URL: [[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`.
+                * @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.
+                * @return The new document; this must be freed with { link GLib.Object.unref}
                 */
                internal Document.with_implementation (Implementation impl, string? namespace_uri, string? 
qualified_name, DocumentType? doctype) {
                        this ();
@@ -276,6 +276,11 @@ namespace GXml {
 
                /**
                 * Creates a Document based on a libxml2 Xml.Doc* object.
+                *
+                * @param doc A { link Xml.Doc} from libxml2
+                * @param require_root A flag to indicate whether we should require a root node, which the 
DOM normally expects
+                *
+                * @return A new { link GXml.Document} wrapping the provided { link Xml.Doc}; this must be 
freed with { link GLib.Object.unref}
                 */
                public Document.from_libxml2 (Xml.Doc *doc, bool require_root = true) {
                        /* All other constructors should call this one,
@@ -296,7 +301,6 @@ namespace GXml {
                        // TODO: consider passing root as a base node?
                        base.for_document ();
 
-
                        this.owner_document = this; // must come after base ()
                        this.xmldoc = doc;
                        if (doc->int_subset == null && doc->ext_subset == null) {
@@ -307,18 +311,36 @@ namespace GXml {
                        }
                        this.implementation = new Implementation ();
                }
+
                /**
                 * Creates a Document from the file at file_path.
+                *
+                * @param file_path A path to an XML document
+                *
+                * @return A { link GXml.Document} for the given `file_path`; this must be freed with { link 
GLib.Object.unref}
+                *
+                * @throws GXml.Error A { link GXml.Error} if an error occurs while loading
                 */
-               public Document.from_path (string file_path) {
-                       // TODO: might want to check that the file_path exists
-                       // consider using Xml.Parser.read_file
-                       Xml.Doc *doc = Xml.Parser.parse_file (file_path);
+               public Document.from_path (string file_path) throws GXml.Error {
+                       Xml.ParserCtxt ctxt;
+                       Xml.Doc *doc;
+                       Xml.Error *e;
+
+                       ctxt = new Xml.ParserCtxt ();
+                       doc = ctxt.read_file (file_path, null /* encoding */, 0 /* options */);
+
+                       if (doc == null) {
+                               e = ctxt.get_last_error ();
+                               GXml.warning (DomException.INVALID_DOC, "Could not load document from path: 
%s".printf (e->message));
+                               throw new GXml.Error.PARSER (GXml.libxml2_error_to_string (e));
+                       }
+
                        this.from_libxml2 (doc);
                }
 
-               // TODO: can we make this private?
+               /* For { link GXml.Document.save_to_stream}, to write the document in chunks. */
                internal static int _iowrite (void *ctx, char[] buf, int len) {
+                       // TODO: can we make this private?
                        OutputStreamBox *box = (OutputStreamBox*)ctx;
                        OutputStream outstream = box->str;
                        int bytes_writ = -1;
@@ -334,8 +356,10 @@ namespace GXml {
 
                        return bytes_writ;
                }
-               // TODO: can we make this private?
+
+               /* For { link GXml.Document.from_stream}, to read the document in chunks. */
                internal static int _iooutclose (void *ctx) {
+                       // TODO: can we make this private?
                        OutputStreamBox *box = (OutputStreamBox*)ctx;
                        OutputStream outstream = box->str;
                        int success = -1;
@@ -353,6 +377,7 @@ namespace GXml {
 
                        return success;
                }
+
                // TODO: can we make this private?
                internal static int _ioread (void *ctx, char[] buf, int len) {
                        InputStreamBox *box = (InputStreamBox*)ctx;
@@ -370,6 +395,7 @@ namespace GXml {
 
                        return bytes_read;
                }
+
                // TODO: can we make this private?
                internal static int _ioinclose (void *ctx) {
                        InputStreamBox *box = (InputStreamBox*)ctx;
@@ -389,11 +415,20 @@ namespace GXml {
 
                        return success;
                }
+
                /**
-                * Creates a Document from the File fin.
+                * Creates a Document for the { link GLib.File} `fin`.
+                *
+                * @param fin The { link GLib.File} containing the document
+                * @param can A { link GLib.Cancellable} to let you cancel opening the file, or %NULL
+                *
+                * @return A new { link GXml.Document} for `fin`; this must be freed with { link 
GLib.Object.unref}
+                *
+                * @throws GLib.Error A { link GLib.Error} if an error cocurs while reading the { link 
GLib.File}
+                * @throws GXml.Error A { link GXml.Error} if an error occurs while reading the file as a 
stream
                 */
-               public Document.from_gfile (File fin, Cancellable? can = null) {
-                       // TODO: accept cancellable
+               public Document.from_gfile (File fin, Cancellable? can = null) throws GXml.Error, GLib.Error {
+                       // TODO: actually handle cancellable
                        InputStream instream;
 
                        try {
@@ -401,42 +436,85 @@ namespace GXml {
                                this.from_stream (instream, can);
                                instream.close ();
                        } catch (GLib.Error e) {
-                               GXml.warning (DomException.INVALID_DOC, "Could not load document from GFile: 
%s".printf (e.message));
+                               GXml.warning (DomException.INVALID_DOC, "Could not load document from GFile: 
" + e.message);
+                               throw e;
                        }
                }
+
                /**
-                * Creates a Document from data provided through the InputStream instream.
+                * Creates a { link GXml.Document} from data provided
+                * through a { link GLib.InputStream}.
+                *
+                * @param instream A { link GLib.InputStream} providing our document
+                * @param can      A { link GLib.Cancellable} object allowing the caller
+                *                 to interrupt and cancel this operation, or %NULL
+                *
+                * @return A new { link GXml.Document} built from the contents of instream;
+                *         this must be freed with { link GLib.Object.unref}
+                *
+                * @throws GXml.Error A { link GXml.Error} if an error occurs while reading the stream
                 */
-               public Document.from_stream (InputStream instream, Cancellable? can = null) {
-                       // TODO: accept Cancellable
-                       // Cancellable can = new Cancellable ();
+               public Document.from_stream (InputStream instream, Cancellable? can = null) throws GXml.Error 
{
                        InputStreamBox box = { instream, can };
                        Xml.Doc *doc;
-                       Xml.TextReader reader = new Xml.TextReader.for_io ((Xml.InputReadCallback)_ioread,
-                                                                          (Xml.InputCloseCallback)_ioinclose,
-                                                                          &box, "", null, 0);
-                       reader.read ();
-                       reader.expand ();
-                       doc = reader.current_doc ();
-                       reader.close ();
+                       /* TODO: provide Cancellable as user data so we can actually
+                          cancel these */
+                       Xml.TextReader reader;
+                       Xml.Error *e;
+                       string errmsg = null;
+
+                       reader = new Xml.TextReader.for_io ((Xml.InputReadCallback)_ioread,
+                                                           (Xml.InputCloseCallback)_ioinclose,
+                                                           &box, "", null, 0);
+                       if (-1 == reader.read ()) {
+                               errmsg = "Error reading from stream";
+                       } else if (null == reader.expand ()) {
+                               errmsg = "Error expanding from stream";
+                       } else {
+                               // yay
+                               doc = reader.current_doc ();
+                               reader.close ();
+                               this.from_libxml2 (doc);
 
-                       this.from_libxml2 (doc);
+                               return;
+                       }
+
+                       // uh oh
+                       e = Xml.Error.get_last_error ();
+                       if (e != null) {
+                               errmsg += ".  " + libxml2_error_to_string (e);
+                       }
+                       GXml.warning (DomException.INVALID_DOC, errmsg);
+                       throw new GXml.Error.PARSER (errmsg);
                }
+
                /**
                 * Creates a Document from data found in memory.
+                *
+                * @param xml A string representing an XML document
+                *
+                * @return A new { link GXml.Document} from `memory`; this must be freed with { link 
GLib.Object.unref}
                 */
-               public Document.from_string (string memory) {
+               public Document.from_string (string xml) {
+                       Xml.Doc *doc;
+
                        /* TODO: consider breaking API to support
                         * xmlParserOptions, encoding, and base URL
                         * from xmlReadMemory */
-                       Xml.Doc *doc = Xml.Parser.parse_memory (memory, (int)memory.length);
+
+                       doc = Xml.Parser.parse_memory (xml, (int)xml.length);
                        this.from_libxml2 (doc);
                }
+
                /**
                 * Creates an empty document.
+                *
+                * @return A new, empty { link GXml.Document}; this must be freed with { link 
GLib.Object.unref}
                 */
                public Document () {
-                       Xml.Doc *doc = new Xml.Doc ();
+                       Xml.Doc *doc;
+
+                       doc = new Xml.Doc ();
                        this.from_libxml2 (doc, false);
                }
 
@@ -450,7 +528,7 @@ namespace GXml {
                 * should sync.
                 */
                internal void sync_dirty_elements () {
-                       Xml.Node * tmp_node;
+                       Xml.Node *tmp_node;
 
                        // TODO: test that adding attributes works with stringification and saving
                        if (this.dirty_elements.length () > 0) {
@@ -468,13 +546,36 @@ namespace GXml {
 
                /**
                 * Saves a Document to the file at path file_path
+                *
+                * @param file_path A path on the local system to save the document to
+                *
+                * @throws GXml.Error A { link GXml.Error} if an error occurs while writing
                 */
                // TODO: is this a simple Unix file path, or does libxml2 do networks, too?
-               public void save_to_path (string file_path) {
+               public void save_to_path (string file_path) throws GXml.Error {
+                       string errmsg;
+                       Xml.Error *e;
+
                        sync_dirty_elements ();
 
                        // TODO: change this to a GIO file so we can save to in a cool way
-                       this.xmldoc->save_file (file_path);
+
+                       if (-1 == this.xmldoc->save_file (file_path)) {
+                               errmsg = "Failed to write file to path '%s'".printf (file_path);
+                       } else {
+                               // yay!
+                               return;
+                       }
+
+                       // uh oh
+                       e = Xml.Error.get_last_error ();
+                       if (e != null) {
+                               errmsg += ".  " + libxml2_error_to_string (e);
+                       }
+
+                       // TODO: use xmlGetLastError to get the real error message
+                       GXml.warning (DomException.X_OTHER, errmsg);
+                       throw new GXml.Error.WRITER (errmsg);
                }
 
                /* TODO: consider adding a save_to_file, but then we
@@ -484,33 +585,65 @@ namespace GXml {
 
                /**
                 * Saves a Document to the OutputStream outstream.
+                *
+                * @param outstream A destination { link GLib.OutputStream} to save the XML file to
+                * @param can A { link GLib.Cancellable} to cancel saving with, or %NULL
+                *
+                * @throws GXml.Error A { link GXml.Error} is thrown if saving encounters an error
                 */
-               public void save_to_stream (OutputStream outstream, Cancellable? can = null) {
+               public void save_to_stream (OutputStream outstream, Cancellable? can = null) throws 
GXml.Error {
                        OutputStreamBox box = { outstream, can };
+                       string errmsg = null;
+                       Xml.Error *e;
 
                        sync_dirty_elements ();
 
-                       // TODO: make sure libxml2's vapi gets patched
-                       Xml.SaveCtxt *ctxt = new Xml.SaveCtxt.to_io ((Xml.OutputWriteCallback)_iowrite,
-                                                                    (Xml.OutputCloseCallback)_iooutclose,
-                                                                    &box, null, 0);
-                       ctxt->save_doc (this.xmldoc);
-                       ctxt->flush ();
-                       ctxt->close ();
+                       /* TODO: provide Cancellable as user data and let these check it
+                                so we can actually be interruptible */
+                       Xml.SaveCtxt *ctxt;
+                       ctxt = new Xml.SaveCtxt.to_io ((Xml.OutputWriteCallback)_iowrite,
+                                                      (Xml.OutputCloseCallback)_iooutclose,
+                                                      &box, null, 0);
+                       if (ctxt == null) {
+                               errmsg = "Failed to create serialization context when saving to stream";
+                       } else if (-1 == ctxt->save_doc (this.xmldoc)) {
+                               errmsg = "Failed to save document";
+                       } else if (-1 == ctxt->flush ()) {
+                               errmsg = "Failed to flush remainder of document while saving to stream";
+                       } else if (-1 == ctxt->close ()) {
+                               errmsg = "Failed to close saving context when saving to stream";
+                       } else {
+                               /* success! */
+                               return;
+                       }
+
+                       /* uh oh */
+                       e = Xml.Error.get_last_error ();
+                       if (e != null) {
+                               errmsg += ".  " + libxml2_error_to_string (e);
+                       }
+
+                       GXml.warning (DomException.X_OTHER, errmsg);
+                       throw new GXml.Error.WRITER (errmsg);
                }
 
                /* Public Methods */
+
                /**
-                * Creates an empty Element node with the tag name
-                * tag_name, which must be a
+                * Creates an empty { link GXml.Element} node with the tag name
+                * `tag_name`, which must be a
                 * [[http://www.w3.org/TR/REC-xml/#NT-Name|valid XML name]].
                 * Its memory is freed when its owner document is
                 * freed.
                 *
                 * XML example: {{{<Person></Person>}}}
                 *
-                * Version: DOM Level 1 Core
+                * Version: DOM Level 1 Core<<BR>>
                 * URL: [[http://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html#method-createElement]]
+
+                * @param tag_name The name of the new { link GXml.Element}
+                *
+                * @return A new { link GXml.Element}; this should not be freed
                 */
                public unowned Element create_element (string tag_name) {
                        // TODO: what should we be passing for ns other than old_ns?  Figure it out; needed 
for level 2+ support
@@ -528,14 +661,16 @@ namespace GXml {
                        return ret;
                }
                /**
-                * Creates a DocumentFragment.
+                * Creates a { link GXml.DocumentFragment}.
                 *
                 * Document fragments do not can contain a subset of a
                 * document, without being a complete tree.  Its
                 * memory is freed when its owner document is freed.
                 *
-                * Version: DOM Level 1 Core
+                * Version: DOM Level 1 Core<<BR>>
                 * URL: 
[[http://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html#method-createDocumentFragment]]
+                *
+                * @return A { link GXml.DocumentFragment}; this should not be freed
                 */
                public unowned DocumentFragment create_document_fragment () {
                        DocumentFragment fragment = new DocumentFragment (this.xmldoc->new_fragment (), this);
@@ -545,17 +680,22 @@ namespace GXml {
                }
 
                /**
-                * Creates a text node containing the text in data.
+                * Creates a { link GXml.Text} node containing the text in data.
                 * Its memory is freed when its owner document is freed.
                 *
                 * XML example:
                 * {{{<someElement>Text is contained here.</someElement>}}}
                 *
-                * Version: DOM Level 1 Core
+                * Version: DOM Level 1 Core<<BR>>
                 * URL: [[http://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html#method-createTextNode]]
+                *
+                * @param text_data The textual data for the { link GXml.Text} node
+                *
+                * @return A new { link GXml.Text} node containing
+                * the supplied data; this should not be freed
                 */
-               public unowned Text create_text_node (string data) {
-                       Text text = new Text (this.xmldoc->new_text (data), this);
+               public unowned Text create_text_node (string text_data) {
+                       Text text = new Text (this.xmldoc->new_text (text_data), this);
                        unowned Text ret = text;
                        this.nodes_to_free.append (text);
                        return ret;
@@ -567,12 +707,17 @@ namespace GXml {
                 *
                 * XML example: {{{<!-- data -->}}}
                 *
-                * Version: DOM Level 1 Core
+                * Version: DOM Level 1 Core<<BR>>
                 * URL: [[http://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html#method-createComment]]
+                *
+                * @param comment_data The content of the comment
+                *
+                * @return A new { link GXml.Comment} containing the
+                * supplied data; this should not be freed
                 */
-               public unowned Comment create_comment (string data) {
+               public unowned Comment create_comment (string comment_data) {
                        // TODO: should we be passing around Xml.Node* like this?
-                       Comment comment = new Comment (this.xmldoc->new_comment (data), this);
+                       Comment comment = new Comment (this.xmldoc->new_comment (comment_data), this);
                        unowned Comment ret = comment;
                        this.nodes_to_free.append (comment);
                        return ret;
@@ -584,35 +729,62 @@ namespace GXml {
                 * These do not apply to HTML doctype documents.  Its
                 * memory is freed when its owner document is freed.
                 *
-                * XML example: {{{ <![CDATA[Here contains non-XML
-                * data, like code, or something that requires a lot
-                * of special XML entities.]]>. }}}
+                * XML example:
+                * {{{ <![CDATA[Here contains non-XML data, like code, or something that requires a lot of 
special XML entities.]]>. }}}
                 *
-                * Version: DOM Level 1 Core
+                * Version: DOM Level 1 Core<<BR>>
                 * URL: [[http://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html#method-createCDATASection]]
+                *
+                * @param cdata_data The content for the CDATA section
+                *
+                * @return A new { link GXml.CDATASection} with the
+                * supplied data; this should not be freed
                 */
-               public unowned CDATASection create_cdata_section (string data) {
+               public unowned CDATASection create_cdata_section (string cdata_data) {
                        check_not_supported_html ("CDATA section");
 
-                       CDATASection cdata = new CDATASection (this.xmldoc->new_cdata_block (data, 
(int)data.length), this);
+                       CDATASection cdata = new CDATASection (this.xmldoc->new_cdata_block (cdata_data, 
(int)cdata_data.length), this);
                        unowned CDATASection ret = cdata;
                        this.nodes_to_free.append (cdata);
                        return ret;
                }
 
                /**
-                * Creates a Processing Instructions.
+                * Creates a new { link GXml.ProcessingInstruction}.
+                *
+                * Its memory is freed when its owner document is
+                * freed.
+                *
+                * XML example:
+                * {{{ <?pi_target processing instruction data?>
+                * <?xml-stylesheet href="style.xsl" type="text/xml"?>}}}
                 *
-                * XML example: {{{<?pi_target processing instruction
-                * data?> <?xml-stylesheet href="style.xsl"
-                * type="text/xml"?>}}}
+                * In the above example, the Processing Instruction's
+                * target is 'xml-stylesheet' and its content data is
+                * 'href="style.xsl" type="text/xml"'.
                 *
-                * Version: DOM Level 1 Core
+                * Version: DOM Level 1 Core<<BR>>
                 * URL: 
[[http://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html#method-createProcessingInstruction]]
+                *
+                * @param target The target of the instruction
+                * @param data The content of the instruction
+                *
+                * @return A new { link GXml.ProcessingInstruction}
+                * for the given target; this should not be freed
                 */
-               /* TODO: this is not backed by a libxml2 structure, and is not stored in the NodeDict, so we 
don't know
-                  when it will be freed :(  Figure it out */
                public ProcessingInstruction create_processing_instruction (string target, string data) {
+                       /* TODO: this is not backed by a libxml2 structure,
+                          and is not stored in the NodeDict, so we don't know
+                          when it will be freed :( Figure it out.
+
+                          It looks like so far this GXmlProcessingInstruction node doesn't
+                          get recorded by its owner_document at all, so the reference
+                          is probably lost.
+
+                          We want to manage it with the GXmlDocument, though, and not
+                          make the developer manage it, because that would be inconsistent
+                          with the rest of the tree (even if the user doesn't insert
+                          this PI into a Document at all.  */
                        check_not_supported_html ("processing instructions");
                        check_invalid_characters (target, "processing instruction");
 
@@ -621,33 +793,62 @@ namespace GXml {
 
                        return pi;
                }
-               // TODO: Consider creating a convenience method for create_attribute_with_value (name, value)
+
                /**
-                * Creates an Attr attribute with `name`, usually to be associated with an Element.
+                * Creates an { link GXml.Attr} attribute with `name`, usually to be associated with an 
Element.
                 *
                 * XML example: {{{<element attributename="attributevalue">content</element>}}}
                 *
-                * Version: DOM Level 1 Core
+                * Version: DOM Level 1 Core<<BR>>
                 * URL: [[http://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html#method-createAttribute]]
+                *
+                * @param name The `name` of the attribute
+                *
+                * @return A new { link GXml.Attr} with the given `name`; this should not be freed
                 */
-               /* TODO: figure out memory for this; its a Node, not a BackedNode and thus not in nodedict */
                public Attr create_attribute (string name) {
+                       /* TODO: figure out memory for this; its a
+                        * Node, not a BackedNode and thus not in
+                        * nodedict.  It's like Processing Instruction
+                        * in that regard.
+                        *
+                        * That said, we might be able to make it a
+                        * BackedNode after all depending on how
+                        * comfortable we are treating libxml2
+                        * xmlAttrs as xmlNodes. :D
+                        */
                        check_invalid_characters (name, "attribute");
 
                        return new Attr (this.xmldoc->new_prop (name, ""), this);
-                       // TODO: should we pass something other than "" for the unspecified value?  probably 
not, "" is working fine so far
+
+                       /* TODO: should we pass something other than
+                          "" for the unspecified value?  probably
+                          not, "" is working fine so far.
+
+                          Actually, this introduces troublesome
+                          compatibility issues when porting libxml2
+                          code to GXml, because in GXml, an
+                          unspecified value is also "" (because of
+                          the spec) whereas in libxml2 it is NULL. */
+
+                       /* TODO: want to create a convenience method
+                          to create a new Attr with name and value
+                          spec'd, like create_attribute_with_value
+                          (), make sure that's not already spec'd in
+                          later DOM levels. */
                }
+
                /**
                 * Creates an entity reference.
                 *
                 * XML example: {{{&name;}}}, for example an apostrophe has the name 'apos', so in XML it 
appears as {{{&apos;}}}
                 *
-                * Version: DOM Level 1 Core
+                * Version: DOM Level 1 Core<<BR>>
                 * URL: 
[[http://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html#method-createEntityReference]]
                 *
-                * @param name The 'name' of the entity reference.
+                * @param name The 'name' of the entity reference
                 *
-                * @return An EntityReference for `name`
+                * @return An { link GXml.EntityReference} for `name`; this should not be freed
                 */
                public EntityReference create_entity_reference (string name) {
                        check_not_supported_html ("entity reference");
@@ -658,19 +859,31 @@ namespace GXml {
                }
 
                /**
-                * Obtains a list of ELements with the given tag name
-                * `tag_name` contained within this document.
+                * Obtains a list of { link GXml.Element}s, each with
+                * the given tag name `tag_name`, contained within
+                * this document.
                 *
-                * This list is updated as new elements are added to
-                * the document.
+                * Note that the list is live, updated as new elements
+                * are added to the document.
                 *
-                * TODO: verify that that last statement is true
+                * Unlike a { link GXml.Node} and its subclasses,
+                * { link GXml.NodeList} are not part of the document
+                * tree, and thus their memory is not managed for the
+                * user, so the user must explicitly free them.
                 *
-                * Version: DOM Level 1 Core
+                * Version: DOM Level 1 Core<<BR>>
                 * URL: 
[[http://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html#method-getElementsByTagName]]
+                *
+                * @param tag_name The { link GXml.Element} tag name we matching for
+                *
+                * @return A { link GXml.NodeList} of
+                * { link GXml.Element}s; this must be freed with
+                * { link GLib.Object.unref}.
                 */
                public NodeList get_elements_by_tag_name (string tag_name) {
+                       // TODO: verify that it is still live :D
                        // TODO: does this ensure that the root element is also included?
+                       // TODO: determine whether the use needs to free these lists
                        return this.document_element.get_elements_by_tag_name (tag_name);
                }
 
@@ -728,13 +941,13 @@ namespace GXml {
                /**
                 * Replaces `old_child` with `new_child` in this node's list of children.
                 *
-                * Version: DOM Level 1 Core
+                * Version: DOM Level 1 Core<<BR>>
                 * URL: [[http://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html#method-replaceChild]]
                 *
                 * @param new_child The child we will replace `old_child` with
                 * @param old_child The child being replaced
                 *
-                * @return The removed node `old_child`.
+                * @return The removed node `old_child`; this should not be freed
                 */
                public override unowned Node? replace_child (Node new_child, Node old_child) {
                        if (new_child.node_type == NodeType.ELEMENT ||
@@ -751,12 +964,12 @@ namespace GXml {
                 * Removes `old_child` from this document's list of
                 * children.
                 *
-                * Version: DOM Level 1 Core
+                * Version: DOM Level 1 Core<<BR>>
                 * URL: [[http://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html#method-removeChild]]
                 *
-                * @param old_child The child we wish to remove.
+                * @param old_child The child we wish to remove
                 *
-                * @return The removed node `old_child`.
+                * @return The removed node `old_child`; this should not be freed
                 */
                public override unowned Node? remove_child (Node old_child) {
                        return this.child_nodes.remove_child (old_child);
@@ -769,13 +982,13 @@ namespace GXml {
                 * { link GXml.Element} child (the root element) and
                 * one { link GXml.DocumentType}.
                 *
-                * Version: DOM Level 1 Core
+                * Version: DOM Level 1 Core<<BR>>
                 * URL: [[http://www.w3.org/TR/DOM-Level-3-Core/core.html#ID-952280727]]
                 *
-                * @param new_child The new node to insert into the document.
-                * @param ref_child The existing child of the document that new_child will precede.
+                * @param new_child The new node to insert into the document
+                * @param ref_child The existing child of the document that new_child will precede, or %NULL
                 *
-                * @return The newly inserted child.
+                * @return The newly inserted child; this should not be freed
                 */
                public override unowned Node? insert_before (Node new_child, Node? ref_child) {
                        if (new_child.node_type == NodeType.ELEMENT ||
@@ -794,12 +1007,12 @@ namespace GXml {
                 * only have one { link GXml.Element} child, the root
                 * element, and one { link GXml.DocumentType}.
                 *
-                * Version: DOM Level 1 Core
+                * Version: DOM Level 1 Core<<BR>>
                 * URL: [[http://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html#method-appendChild]]
                 *
                 * @param new_child The child we're appending
                 *
-                * @return The newly added child.
+                * @return The newly added child; this should not be freed
                 */
                public override unowned Node? append_child (Node new_child) {
                        this.check_wrong_document (new_child);
diff --git a/gxml/DocumentFragment.vala b/gxml/DocumentFragment.vala
index c97ba58..a699d46 100644
--- a/gxml/DocumentFragment.vala
+++ b/gxml/DocumentFragment.vala
@@ -49,7 +49,7 @@ namespace GXml {
         * another node, become that nodes' children, without the
         * DocumentFragment itself existing as a child.
         *
-        * Version: DOM Level 1 Core
+        * Version: DOM Level 1 Core<<BR>>
         * URL: [[http://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html#ID-B63ED1A3]]
         */
        public class DocumentFragment : BackedNode {
diff --git a/gxml/DocumentType.vala b/gxml/DocumentType.vala
index a7d56ba..4a6a182 100644
--- a/gxml/DocumentType.vala
+++ b/gxml/DocumentType.vala
@@ -49,11 +49,9 @@ namespace GXml {
                 * That which follows DOCTYPE in the XML doctype
                 * declaration, like 'xml' or 'html'. For example, the
                 * document type name is 'html' for a document with
-                * the XML doctype declaration of {{{ <!DOCTYPE
-                * HTML PUBLIC "-//W3C//DTD HTML 4.01
-                * Transitional//EN"
-                * "http://www.w3.org/TR/html4/loose.dtd";> }}}
-               */
+                * the XML doctype declaration of
+                * {{{ <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 
"http://www.w3.org/TR/html4/loose.dtd";> }}}
+                */
                public string name {
                        get {
                                // TODO: is it possible for int_subset and ext_subset to have different names?
diff --git a/gxml/DomException.vala b/gxml/DomException.vala
index ac7e034..ec707b2 100644
--- a/gxml/DomException.vala
+++ b/gxml/DomException.vala
@@ -33,7 +33,7 @@ namespace GXml {
        /**
         * Describes various error states. For more, see
         *
-        * Version: DOM Level 1 Core
+        * Version: DOM Level 1 Core<<BR>>
         * URL: [[http://www.w3.org/TR/DOM-Level-1/level-one-core.html#ID-BBACDC08]]
         */
        public enum DomException {
@@ -103,10 +103,17 @@ namespace GXml {
                /**
                 * There was an issue with the namespace.  A qualified name's prefix may have disagreed with 
the corresponding namespace or vice versa.
                 *
-                * Version: DOM Level 3 Core
+                * Version: DOM Level 3 Core<<BR>>
                 * URL: [[http://www.w3.org/TR/DOM-Level-3-Core/core.html#DOMException-NAMESPACE_ERR]]
                 */
-               NAMESPACE;
+               NAMESPACE,
+
+               /**
+                * Non-DOM error
+                *
+                * TODO: consider better naming for this
+                */
+               X_OTHER;
        }
 }
 
diff --git a/gxml/Element.vala b/gxml/Element.vala
index 2713cfe..3781037 100644
--- a/gxml/Element.vala
+++ b/gxml/Element.vala
@@ -38,7 +38,7 @@ namespace GXml {
         * attributes, as an alternative to manipulating the
         * attributes HashMap directly.
         *
-        * Version: DOM Level 1 Core
+        * Version: DOM Level 1 Core<<BR>>
         * URL: [[http://www.w3.org/TR/DOM-Level-1/level-one-core.html#ID-745549614]]
         */
        public class Element : BackedNode {
@@ -48,13 +48,13 @@ namespace GXml {
                /**
                 * The element's tag_name. Multiple elements can have
                 * the same tag name in a document. XML example:
-                * {{{&lt;photos>
-                *   &lt;img src="..." />
-                *   &lt;img src="..." />
-                * &lt;/photos>}}}
+                * {{{<photos>
+                *   <img src="..." />
+                *   <img src="..." />
+                * </photos>}}}
                 * In this example, photos and img are tag names.
                 *
-                * Version: DOM Level 1 Core
+                * Version: DOM Level 1 Core<<BR>>
                 * URL: [[http://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html#ID-104682815]]
                 */
                public string tag_name {
@@ -222,10 +222,10 @@ namespace GXml {
                 * attribute associated with this element with the
                 * name name.
                 *
-                * Version: DOM Level 1 Core
+                * Version: DOM Level 1 Core<<BR>>
                 * URL: [[http://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html#ID-666EE0F9]]
                 *
-                * @param name The name of the attribute whose value to retrieve.
+                * @param name The name of the attribute whose value to retrieve
                 *
                 * @return The value of the named attribute, or "" if
                 * no such attribute is set.
@@ -243,11 +243,11 @@ namespace GXml {
                 * Set the value of this element's attribute named
                 * name to the string value.
                 *
-                * Version: DOM Level 1 Core
+                * Version: DOM Level 1 Core<<BR>>
                 * URL: [[http://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html#ID-F68F082]]
                 *
-                * @param name Name of the attribute whose value to set.
-                * @param value The value to set.
+                * @param name Name of the attribute whose value to set
+                * @param value The value to set
                 */
                public void set_attribute (string name, string value) {
                        // don't need to use insert
@@ -270,10 +270,10 @@ namespace GXml {
                /**
                 * Remove the attribute named name from this element.
                 *
-                * Version: DOM Level 1 Core
+                * Version: DOM Level 1 Core<<BR>>
                 * URL: [[http://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html#ID-6D6AC0F9]]
                 *
-                * @param name The name of the attribute to unset.
+                * @param name The name of the attribute to unset
                 */
                public void remove_attribute (string name) {
                        this.check_read_only (); // TODO: check all this.check_*, and see if we should be 
aborting the current functions on failure or just warn, like here
@@ -284,12 +284,12 @@ namespace GXml {
                /**
                 * Get the Attr node representing this element's attribute named name.
                 *
-                * Version: DOM Level 1 Core
+                * Version: DOM Level 1 Core<<BR>>
                 * URL: [[http://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html#ID-217A91B8]]
                 *
-                * @param name The name of the Attr node to retrieve.
+                * @param name The name of the Attr node to retrieve
                 *
-                * @return The Attr node named by name for this element, or null if none is set.
+                * @return The Attr node named by name for this element, or %NULL if none is set
                 */
                public Attr? get_attribute_node (string name) {
                        // TODO: verify that attributes returns null with unknown name
@@ -298,14 +298,14 @@ namespace GXml {
                /**
                 * Set the attribute in Attr for this element.
                 *
-                * Version: DOM Level 1 Core
+                * Version: DOM Level 1 Core<<BR>>
                 * URL: [[http://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html#ID-887236154]]
                 *
-                * @param new_attr The attribute to set.
+                * @param new_attr The attribute to set
                 *
                 * @return If an Attr with the same name exists, it
                 * is replaced and the old Attr is returned.
-                * Elsewise, null is returned.
+                * Elsewise, %NULL is returned.
                 */
                public Attr set_attribute_node (Attr new_attr) {
                        // TODO: INUSE_ATTRIBUTE_ERR if new_attr already belongs to another element
@@ -325,10 +325,10 @@ namespace GXml {
                 * Remove Attr old_attr from this element, if it was
                 * set.
                 *
-                * Version: DOM Level 1 Core
+                * Version: DOM Level 1 Core<<BR>>
                 * URL: [[http://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html#ID-D589198]]
                 *
-                * @param old_attr The Attr we are removing.
+                * @param old_attr The Attr we are removing
                 *
                 * @return The old_attr we wanted to remove, even if
                 * it wasn't found.
@@ -377,22 +377,38 @@ namespace GXml {
                }
 
                /* ** Node methods ** */
+
+               /**
+                * { inheritDoc}
+                */
                public override unowned Node? insert_before (Node new_child, Node? ref_child) {
                        unowned Node ret = base.insert_before (new_child, ref_child);
                        check_add_tag_name (this, new_child);
                        return ret;
                }
+
+               /**
+                * { inheritDoc}
+                */
                public override unowned Node? replace_child (Node new_child, Node old_child) {
                        check_remove_tag_name (this, old_child);
                        unowned Node ret = base.replace_child (new_child, old_child);
                        check_add_tag_name (this, new_child);
                        return ret;
                }
+
+               /**
+                * { inheritDoc}
+                */
                public override unowned Node? remove_child (Node old_child) {
                        check_remove_tag_name (this, old_child);
                        unowned Node ret = base.remove_child (old_child);
                        return ret;
                }
+
+               /**
+                * { inheritDoc}
+                */
                public override unowned Node? append_child (Node new_child) {
                        unowned Node ret = base.append_child (new_child);
                        check_add_tag_name (this, new_child);
@@ -473,12 +489,12 @@ namespace GXml {
                 * matches. The returned list is updated as necessary
                 * as the tree changes.
                 *
-                * Version: DOM Level 1 Core
+                * Version: DOM Level 1 Core<<BR>>
                 * URL: [[http://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html#ID-1938918D]]
                 *
-                * @param tag_name The tag name to match for.
+                * @param tag_name The tag name to match for
                 *
-                * @return A NOdeList containing the matching descendants.
+                * @return A NodeList containing the matching descendants
                 */
                /*TODO: make sure we want to include the current
                 * element, I think probably not.
@@ -515,7 +531,7 @@ namespace GXml {
                 * are not distinguishable in XML when stored outside
                 * of the DOM.
                 *
-                * Version: DOM Level 1 Core
+                * Version: DOM Level 1 Core<<BR>>
                 * URL: [[http://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html#ID-162CF083]]
                 */
                public void normalize () {
@@ -542,9 +558,11 @@ namespace GXml {
                /**
                 * This is a convenience property for Elements, useful
                 * when you want to see Text descendents of an
-                * element. With the XML example {{{<shops><shop
-                * id="1">Eeylops Owl Emporium</shop><shop
-                * id="2">Obscurus Books</shop></shops>}}} taking the
+                * element. With the XML example
+                * {{{<shops>
+                *   <shop id="1">Eeylops Owl Emporium</shop>
+                *   <shop id="2">Obscurus Books</shop>
+                * </shops>}}} taking the
                 * node for the shop element with id 1 and using this
                 * method, you would get back "Eeylops Owl Emporiums".
                 * If you used it on the shops element, you'd get
diff --git a/gxml/Entity.vala b/gxml/Entity.vala
index 4a2f6c1..a7f3131 100644
--- a/gxml/Entity.vala
+++ b/gxml/Entity.vala
@@ -33,7 +33,7 @@ namespace GXml {
                private Xml.Entity *entity;
 
                /**
-                * A public identifier for the entity. `null` when unspecified.
+                * A public identifier for the entity. %NULL when unspecified.
                 */
                public string public_id {
                        get {
@@ -44,7 +44,7 @@ namespace GXml {
                        }
                }
                /**
-                * A system identifier for the entity. `null` when unspecified.
+                * A system identifier for the entity. %NULL when unspecified.
                 */
                public string system_id {
                        get {
@@ -56,7 +56,7 @@ namespace GXml {
                }
                /**
                 * The notation name for this entity if it is
-                * unparsed. This is `null` if the entity is parsed.
+                * unparsed. This is %NULL if the entity is parsed.
                 */
                public string notation_name {
                        get {
diff --git a/gxml/Error.vala b/gxml/Error.vala
new file mode 100644
index 0000000..f0d6405
--- /dev/null
+++ b/gxml/Error.vala
@@ -0,0 +1,12 @@
+namespace GXml {
+       public errordomain Error {
+               PARSER, WRITER;
+       }
+
+       internal static string libxml2_error_to_string (Xml.Error *e) {
+               return "%s:%s:%d: %s:%d: %s".printf (
+                       e->level.to_string ().substring (8 /* skipping XML_ERR_ */),
+                       e->domain.to_string ().substring (9 /* skipping XML_FROM_ */),
+                       e->code, e->file == null ? "<io>" : e->file, e->line, e->message);
+       }
+}
\ No newline at end of file
diff --git a/gxml/Implementation.vala b/gxml/Implementation.vala
index 58323d0..7f22dc6 100644
--- a/gxml/Implementation.vala
+++ b/gxml/Implementation.vala
@@ -32,7 +32,7 @@ namespace GXml {
         * version, it can tell the client whether it is here
         * implemented.
         *
-        * Version: DOM Level 1 Core
+        * Version: DOM Level 1 Core<<BR>>
         * URL: [[http://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html#ID-102161490]]
         */
        public class Implementation : GLib.Object {
@@ -68,7 +68,7 @@ namespace GXml {
                }
 
                // Not using Node's, because this doctype shouldn't have ANY owner yet
-               protected void check_wrong_document (DocumentType? doctype) {
+               internal void check_wrong_document (DocumentType? doctype) {
                        if (doctype != null && doctype.owner_document != null) {
                                GXml.warning (DomException.WRONG_DOCUMENT, "The supplied doctype is already 
connected to an existing document.");
                        }
@@ -78,14 +78,14 @@ namespace GXml {
                /**
                 * Creates a Document according to this { link GXml.Implementation}.
                 *
-                * Version: DOM Level 3 Core
+                * Version: DOM Level 3 Core<<BR>>
                 * URL: [[http://www.w3.org/TR/DOM-Level-3-Core/core.html#Level-2-Core-DOM-createDocument]]
 
-                * @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`.
+                * @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.
+                * @return The new document
                 */
                public Document create_document (string? namespace_uri, string? qualified_name, DocumentType? 
doctype) {
                        Document doc;
@@ -101,15 +101,15 @@ namespace GXml {
                /**
                 * Reports whether we support a feature at a given version level.
                 *
-                * Version: DOM Level 1 Core
+                * Version: DOM Level 1 Core<<BR>>
                 * URL: [[http://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html#method-hasFeature]]
                 *
                 * TODO: implement more of this, using libxml2's parser.h's xmlGetFeature, xmlHasFeature, etc.
                 *
-                * @param feature A feature we might support, usually something like 'xml' or 'html'.
-                * @param version A possible version of the feature, or null if any version will do.
+                * @param feature A feature we might support, usually something like 'xml' or 'html'
+                * @param version A possible version of the feature, or %NULL if any version will do
                 *
-                * @return true if we support the specified feature, false otherwise.
+                * @return true if we support the specified feature, false otherwise
                 */
                public bool has_feature (string feature, string? version = null) {
                        /* Level 1 is limited to "xml" and "html" (icase) */
diff --git a/gxml/Makefile.am b/gxml/Makefile.am
index bb40117..37c7a6c 100644
--- a/gxml/Makefile.am
+++ b/gxml/Makefile.am
@@ -52,6 +52,7 @@ libgxml_la_SOURCES = \
        Element.vala \
        Entity.vala \
        EntityReference.vala \
+       Error.vala \
        Implementation.vala \
        NamespaceAttr.vala \
        NodeList.vala \
diff --git a/gxml/Node.vala b/gxml/Node.vala
index 6883996..711eef1 100644
--- a/gxml/Node.vala
+++ b/gxml/Node.vala
@@ -32,7 +32,7 @@ namespace GXml {
         * { link GXml.Document}s are { link GXml.Node}s, and are
         * composed of a tree of { link GXml.Node}s.
         *
-        * Version: DOM Level 1 Core
+        * Version: DOM Level 1 Core<<BR>>
         * URL: [[http://www.w3.org/TR/DOM-Level-1/level-one-core.html#ID-1950641247]]
         */
        public class Node : GLib.Object {
@@ -48,7 +48,7 @@ namespace GXml {
 
                /* Utility methods */
 
-               protected void check_wrong_document (Node node) {
+               internal void check_wrong_document (Node node) {
                        Document this_doc;
 
                        if (this.node_type == NodeType.DOCUMENT) {
@@ -63,7 +63,7 @@ namespace GXml {
                }
 
 
-               protected bool check_read_only () {
+               internal bool check_read_only () {
                        // TODO: protected methods appear in the generated gxml.h and in the GtkDoc, do we 
want that?
                        // TODO: introduce a concept of read-only-ness, perhaps
                        // if read-only, raise NO_MODIFICATION_ALLOWED_ERR
@@ -71,7 +71,7 @@ namespace GXml {
                }
 
 
-               public void dbg_inspect () {
+               internal void dbg_inspect () {
                        message ("node: %s", this.node_name);
                        message ("  ns (prefix: %s, uri: %s)", this.prefix, this.namespace_uri);
                        if (this.attributes != null) {
@@ -117,7 +117,7 @@ namespace GXml {
                 * Do not free this.  It's memory will be released
                 * when the owning { link GXml.Document} is freed.
                 *
-                * Version: DOM Level 2 Core
+                * Version: DOM Level 2 Core<<BR>>
                 * URL: [[http://www.w3.org/TR/DOM-Level-2-Core/core.html#ID-NodeNSname]]
                 */
                public virtual string? namespace_uri {
@@ -136,7 +136,7 @@ namespace GXml {
                 * Do not free this.  It's memory will be released
                 * when the owning { link GXml.Document} is freed.
                 *
-                * Version: DOM Level 2 Core
+                * Version: DOM Level 2 Core<<BR>>
                 * URL: [[http://www.w3.org/TR/DOM-Level-2-Core/core.html#ID-NodeNSPrefix]]
                 */
                public virtual string? prefix {
@@ -155,7 +155,7 @@ namespace GXml {
                 * Do not free this.  It's memory will be released
                 * when the owning { link GXml.Document} is freed.
                 *
-                * Version: DOM Level 2 Core
+                * Version: DOM Level 2 Core<<BR>>
                 * URL: [[http://www.w3.org/TR/DOM-Level-2-Core/core.html#ID-NodeNSLocalN]]
                 */
                public virtual string? local_name {
@@ -174,8 +174,8 @@ namespace GXml {
                 * Do not free this.  It's memory will be released
                 * when the owning { link GXml.Document} is freed.
                 *
-                * Version: DOM Level 1 Core
-                * URL: [[http://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html#attribute-nodeName]]
+                * Version: DOM Level 1 Core<<BR>>
+                * URL: [[http://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html#ID-F68D095]]
                 */
                public virtual string node_name {
                        get; internal set;
@@ -184,13 +184,13 @@ namespace GXml {
                /**
                 * Stores the value of the Node. The nature of
                 * node_value varies based on the type of node. This
-                * can be null.
+                * can be %NULL.
                 *
                 * Do not free this.  It's memory will be released
                 * when the owning { link GXml.Document} is freed.
                 *
-                * Version: DOM Level 1 Core
-                * URL: [[http://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html#attribute-nodeValue]]
+                * Version: DOM Level 1 Core<<BR>>
+                * URL: [[http://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html#ID-F68D080]]
                 */
                public virtual string? node_value {
                        get {
@@ -204,11 +204,13 @@ namespace GXml {
                private NodeType _node_type;
                /**
                 * Stores the type of node. Most XML structures are
-                * nodes of different types, like Document, Attr,
-                * Element, etc.
+                * nodes of different types, like { link GXml.Document}
+                * as a { link GXml.NodeType.DOCUMENT}, { link GXml.Attr}
+                * as a { link GXml.NodeType.ATTRIBUTE}, Element as a
+                * { link GXml.NodeType.ELEMENT}, etc.
                 *
-                * Version: DOM Level 1 Core
-                * URL: [[http://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html#attribute-nodeType]]
+                * Version: DOM Level 1 Core<<BR>>
+                * URL: [[http://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html#ID-111237558]]
                 */
                public virtual NodeType node_type {
                        get {
@@ -222,7 +224,7 @@ namespace GXml {
                }
 
                /**
-                * A link to the parent of this node. For example,
+                * A link to the parent_node of this node. For example,
                 * with elements, the immediate, outer element is the parent.
                 *
                 * XML example: {{{<parent><child></child></parent>}}}
@@ -230,8 +232,8 @@ namespace GXml {
                 * Do not free this.  It's memory will be released
                 * when the owning { link GXml.Document} is freed.
                 *
-                * Version: DOM Level 1 Core
-                * URL: [[http://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html#attribute-parentNode]]
+                * Version: DOM Level 1 Core<<BR>>
+                * URL: [[http://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html#ID-1060184317]]
                 */
                public virtual Node? parent_node {
                        get { return null; }
@@ -240,9 +242,10 @@ namespace GXml {
 
                /**
                 * List of child nodes to this node. These sometimes
-                * represent the value of a node as a tree of values,
-                * whereas node_value represents it as a string. This
-                * can be null for node types that have no children.
+                * represent the value of a node as a tree of
+                * { link GXml.Node}, whereas node_value represents
+                * it as a string. This can be %NULL for node types
+                * that have no children.
                 *
                 * The { link GXml.NodeList} is live, in that changes to this
                 * node's children will be reflected in an
@@ -252,8 +255,8 @@ namespace GXml {
                 * the list when it is done with it.  The lists are
                 * constructed dynamically.
                 *
-                * Version: DOM Level 1 Core
-                * URL: [[http://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html#attribute-childNodes]]
+                * Version: DOM Level 1 Core<<BR>>
+                * URL: [[http://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html#ID-1451460987]]
                 */
                /*
                 * @todo: identify node types that use children for values, like attribute
@@ -266,13 +269,13 @@ namespace GXml {
 
                /**
                 * Links to the first child. If there are no
-                * children, it returns null.
+                * children, it returns %NULL.
                 *
                 * Do not free this.  It's memory will be released
                 * when the owning { link GXml.Document} is freed.
                 *
-                * Version: DOM Level 1 Core
-                * URL: [[http://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html#attribute-firstChild]]
+                * Version: DOM Level 1 Core<<BR>>
+                * URL: [[http://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html#ID-169727388]]
                 */
                public virtual Node? first_child {
                        get { return null; }
@@ -281,13 +284,13 @@ namespace GXml {
 
                /**
                 * Links to the last child. If there are no
-                * children, it returns null.
+                * children, it returns %NULL.
                 *
                 * Do not free this.  It's memory will be released
                 * when the owning { link GXml.Document} is freed.
                 *
-                * Version: DOM Level 1 Core
-                * URL: [[http://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html#attribute-lastChild]]
+                * Version: DOM Level 1 Core<<BR>>
+                * URL: [[http://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html#ID-61AD09FB]]
                 */
                public virtual Node? last_child {
                        get { return null; }
@@ -296,14 +299,14 @@ namespace GXml {
 
                /**
                 * Links to this node's preceding sibling. If there
-                * are no previous siblings, it returns null. Note
+                * are no previous siblings, it returns %NULL. Note
                 * that the children of a node are ordered.
                 *
                 * Do not free this.  It's memory will be released
                 * when the owning { link GXml.Document} is freed.
                 *
-                * Version: DOM Level 1 Core
-                * URL: [[http://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html#attribute-previousSibling]]
+                * Version: DOM Level 1 Core<<BR>>
+                * URL: [[http://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html#ID-640FB3C8]]
                 */
                public virtual Node? previous_sibling {
                        get { return null; }
@@ -312,14 +315,14 @@ namespace GXml {
 
                /**
                 * Links to this node's next sibling. If there is no
-                * next sibling, it returns null. Note that the
+                * next sibling, it returns %NULL. Note that the
                 * children of a node are ordered.
                 *
                 * Do not free this.  It's memory will be released
                 * when the owning { link GXml.Document} is freed.
                 *
-                * Version: DOM Level 1 Core
-                * URL: [[http://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html#attribute-nextSibling]]
+                * Version: DOM Level 1 Core<<BR>>
+                * URL: [[http://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html#ID-6AC54C2F]]
                 */
                public virtual Node? next_sibling {
                        get { return null; }
@@ -336,8 +339,8 @@ namespace GXml {
                 * Do not free this.  It's memory will be released
                 * when the owning { link GXml.Document} is freed.
                 *
-                * Version: DOM Level 1 Core
-                * URL: [[http://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html#attribute-attributes]]
+                * Version: DOM Level 1 Core<<BR>>
+                * URL: [[http://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html#ID-84CF09]]
                 */
                public virtual HashTable<string,Attr>? attributes {
                        get { return null; }
@@ -351,8 +354,8 @@ namespace GXml {
                 * memory owned by the { link GXml.Document}, including this
                 * { link GXml.Node}.
                 *
-                * Version: DOM Level 1 Core
-                * URL: [[http://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html#attribute-ownerDocument]]
+                * Version: DOM Level 1 Core<<BR>>
+                * URL: [[http://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html#node-ownerDoc]]
                 */
                public weak Document owner_document {
                        get;
@@ -366,16 +369,19 @@ namespace GXml {
                 * @TODO: want to throw other relevant errors */
 
                /**
-                * Insert `new_child` as a child to this node, and place
-                * it in the list before `ref_child`.
+                * Insert { link new_child} as a child to this node, and place
+                * it in the list before { link ref_child}.
                 *
-                * If `ref_child` is `null`, `new_child` is appended to the
+                * If { link ref_child} is %NULL, { link new_child} is appended to the
                 * list of children instead.
                 *
-                * Version: DOM Level 1 Core
+                * Version: DOM Level 1 Core<<BR>>
                 * URL: [[http://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html#method-insertBefore]]
                 *
-                * @return `new_child`, the node that has been
+                * @param new_child A new { link GXml.Node} that will become a child of the current one
+                * @param ref_child The child that { link new_child} will be placed ahead of
+                *
+                * @return { link new_child}, the node that has been
                 * inserted.  Do not free it, its memory will be
                 * released when the owning { link GXml.Document} is
                 * freed.
@@ -385,12 +391,15 @@ namespace GXml {
                }
 
                /**
-                * Replaces `old_child` with `new_child` in this node's list of children.
+                * Replaces { link old_child} with { link new_child} in this node's list of children.
                 *
-                * Version: DOM Level 1 Core
+                * Version: DOM Level 1 Core<<BR>>
                 * URL: [[http://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html#method-replaceChild]]
                 *
-                * @return The removed node `old_child`.  Do not free it, its memory will be
+                * @param new_child A new { link GXml.Node} that will become a child of the current one
+                * @param old_child A { link GXml.Node} that will be removed and replaced by { link new_child}
+                *
+                * @return The removed node { link old_child}.  Do not free it, its memory will be
                 * released when the owning { link GXml.Document} is
                 * freed.
                 */
@@ -399,26 +408,34 @@ namespace GXml {
                }
 
                /**
-                * Removes `old_child` from this node's list of children.
+                * Removes { link old_child} from this node's list of children,
+                * { link GXml.Node.child_nodes}.
                 *
-                * Version: DOM Level 1 Core
+                * Version: DOM Level 1 Core<<BR>>
                 * URL: [[http://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html#method-removeChild]]
                 *
-                * @return The removed node `old_child`.  Do not free it, its memory will be
+                * @param old_child The { link GXml.Node} child to remove from the current one
+                *
+                * @return The removed node { link old_child}.  Do not free it, its memory will be
                 * released when the owning { link GXml.Document} is
-                * freed.
+                * freed
                 */
                public virtual unowned Node? remove_child (Node old_child) {
                        return null;
                }
 
                /**
-                * Appends `new_child` to the end of this node's list of children.
+                * Appends { link new_child} to the end of this node's list of children,
+                * { link GXml.Node.child_nodes}.
+                *
+                * Version: DOM Level 1 Core<<BR>>
                 *
-                * Version: DOM Level 1 Core
                 * URL: [[http://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html#method-appendChild]]
                 *
-                * @return The newly added child.  Do not free it, its memory will be
+                * @param new_child A new { link GXml.Node} that will
+                * become the last child of this current node
+                *
+                * @return The newly added child, { link new_child}.  Do not free it, its memory will be
                 * released when the owning { link GXml.Document} is
                 * freed.
                 */
@@ -429,10 +446,11 @@ namespace GXml {
                /**
                 * Indicates whether this node has children.
                 *
-                * Version: DOM Level 1 Core
+                * Version: DOM Level 1 Core<<BR>>
+                *
                 * URL: [[http://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html#method-hasChildNodes]]
                 *
-                * @return `true` if this node has children, `false` if not
+                * @return %TRUE if this node has children, %FALSE if not
                 */
                public virtual bool has_child_nodes () {
                        return false;
@@ -441,10 +459,11 @@ namespace GXml {
                /**
                 * Creates a parentless copy of this node.
                 *
-                * Version: DOM Level 1 Core
+                * Version: DOM Level 1 Core<<BR>>
+                *
                 * URL: [[http://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html#method-cloneNode]]
                 *
-                * @param deep If `true`, descendants are cloned as well. If `false`, they are not.
+                * @param deep If %TRUE, descendants are cloned as well. If %FALSE, they are not
                 *
                 * @return A parentless clone of this node.  Do not
                 * free it, its memory will be released when the owning
@@ -461,12 +480,12 @@ namespace GXml {
                 * CDATA section, or an EntityRef, it will not be
                 * formatted, since the current implementation with
                 * libxml2 will not handle that case.  (See libxml2's
-                * xmlNodeDumpOutputInternal to understand more.)
+                * xmlNodeDumpOutput internals to understand more.)
                 *
-                * @param format false: no formatting, true: formatted, with indentation.
+                * @param format %FALSE: no formatting, %TRUE: formatted, with indentation
                 * @param level Indentation level
                 *
-                * @return XML string for node.  The caller must free
+                * @return XML string for node, which must be free
                 * this.
                 */
                // TODO: ask Colin Walters about storing docs in GIR files (might have not been him)
diff --git a/gxml/NodeList.vala b/gxml/NodeList.vala
index 39abf97..56ce709 100644
--- a/gxml/NodeList.vala
+++ b/gxml/NodeList.vala
@@ -38,7 +38,7 @@ namespace GXml {
         * iteration in supporting languages (like Vala) nice and
         * easy.
         *
-        * Version: DOM Level 1 Core
+        * Version: DOM Level 1 Core<<BR>>
         * URL: [[http://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html#ID-536297177]]
         */
        public interface NodeList : Gee.Iterable<Node> {
@@ -50,7 +50,7 @@ namespace GXml {
                /**
                 * The number of nodes contained within this list
                 *
-                * Version: DOM Level 1 Core
+                * Version: DOM Level 1 Core<<BR>>
                 * URL: [[http://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html#attribute-length]]
                 */
                public abstract ulong length {
@@ -63,7 +63,7 @@ namespace GXml {
                /**
                 * Access the idx'th item in the list.
                 *
-                * Version: DOM Level 1 Core
+                * Version: DOM Level 1 Core<<BR>>
                 * URL: [[http://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html#method-item]]
                 */
                public abstract Node item (ulong idx);
@@ -120,8 +120,8 @@ namespace GXml {
                 * Obtain the item n places before pivot in the list.
                 * Like { link GLib.List.nth_prev}.
                 *
-                * @param pivot A reference point in the list, from which we'll count back.
-                * @param n How many nodes to count back from the reference point.
+                * @param pivot A reference point in the list, from which we'll count back
+                * @param n How many nodes to count back from the reference point
                 *
                 * @return The node that is `n` nodes before `pivot` in the list
                 */
@@ -153,7 +153,7 @@ namespace GXml {
                 *
                 * @param target A node in the list
                 *
-                * @return The position of `target` in the list.
+                * @return The position of `target` in the list
                 */
                public abstract int position (Node target);
 
@@ -173,9 +173,9 @@ namespace GXml {
                 *
                 * #todo: write a test
                 *
-                * @param in_line Whether to parse and expand entities or not.
+                * @param in_line Whether to parse and expand entities or not
                 *
-                * @return The list as an XML string.
+                * @return The list as an XML string
                 */
                /*
                 * @todo: write a test
@@ -734,7 +734,7 @@ namespace GXml {
 
                /**
                 * Obtain the current Node in the iteration.
-                * Returns null if there is none, which occurs
+                * Returns %NULL if there is none, which occurs
                 * if the list is empty or if iteration has
                 * not started (next () has never been
                 * called).
@@ -743,7 +743,8 @@ namespace GXml {
                        if (this.valid) {
                                return this.get_current ();
                        } else {
-                               // TODO: file bug, Iterator wants Node, not Node?, but it wants us to be able 
to return null.
+                               /* TODO: file bug, Iterator wants Node, not Node?, but it
+                                  wants us to be able to return null. */
                                return null;
                        }
                }
diff --git a/gxml/Notation.vala b/gxml/Notation.vala
index c96ee48..8697028 100644
--- a/gxml/Notation.vala
+++ b/gxml/Notation.vala
@@ -47,7 +47,7 @@ namespace GXml {
                        }
                }
                /**
-                * The public identifier for the notation, or null if not set.
+                * The public identifier for the notation, or %NULL if not set.
                 */
                public string? public_id {
                        get {
@@ -57,7 +57,7 @@ namespace GXml {
                        }
                }
                /**
-                * The system identifier for the notation, or null if not set.
+                * The system identifier for the notation, or %NULL if not set.
                 */
                public string? system_id {
                        get {
diff --git a/gxml/Serializable.vala b/gxml/Serializable.vala
index dd018cb..a663a0f 100644
--- a/gxml/Serializable.vala
+++ b/gxml/Serializable.vala
@@ -135,7 +135,7 @@ namespace GXml {
                 * @param property_name string name of a property to serialize.
                 * @param spec the { link GLib.ParamSpec} describing the property.
                 * @param doc the { link GXml.Document} the returned { link GXml.Node} should belong to
-                * @return a new { link GXml.Node}, or `null`
+                * @return a new { link GXml.Node}, or %NULL
                 */
                public abstract GXml.Node? serialize_property (Element element,
                                                               GLib.ParamSpec prop)
@@ -327,7 +327,7 @@ namespace GXml {
                /*
                 * Get a string version of the specified property
                 *
-                * @param spec The property we're retrieving as a string.
+                * @param spec The property we're retrieving as a string
                 *
                 * { link GXml.Serialization} uses { link GLib.Object.get_property} (as
                 * well as { link GLib.ObjectClass.find_property},
diff --git a/gxml/Text.vala b/gxml/Text.vala
index fdb7e45..aafe232 100644
--- a/gxml/Text.vala
+++ b/gxml/Text.vala
@@ -38,7 +38,7 @@ namespace GXml {
         * so some functionality for Text, like split_text, will not
         * work completely as expected.
         *
-        * Version: DOM Level 1 Core
+        * Version: DOM Level 1 Core<<BR>>
         * URL: [[http://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html#ID-1312295772]]
         */
        public class Text : CharacterData {
@@ -68,7 +68,7 @@ namespace GXml {
                 * change in the future to comply with the DOM Level 1
                 * Core spec.
                 *
-                * Version: DOM Level 1 Core
+                * Version: DOM Level 1 Core<<BR>>
                 * URL: [[http://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html#ID-38853C1D]]
                 *
                 * @param offset The point at which to split the Text,
diff --git a/test/DocumentTest.vala b/test/DocumentTest.vala
index 30cc373..e3da9ce 100644
--- a/test/DocumentTest.vala
+++ b/test/DocumentTest.vala
@@ -39,13 +39,45 @@ class DocumentTest : GXmlTest {
 
                                check_contents (doc);
                        });
+               Test.add_func ("/gxml/document/construct_from_path_error", () => {
+                               Document doc;
+                               try {
+                                       // file does not exist
+                                       doc = new Document.from_path ("/tmp/asdfjlkansdlfjl");
+                                       assert_not_reached ();
+                               } catch (GXml.Error e) {
+                                       assert (e is GXml.Error.PARSER);
+                               }
+                               test_error (DomException.INVALID_DOC);
+
+                               try {
+                                       // file exists, but is not XML (it's a directory!)
+                                       doc = new Document.from_path ("/tmp/");
+                                       assert_not_reached ();
+                               } catch (GXml.Error e) {
+                                       assert (e is GXml.Error.PARSER);
+                               }
+                               test_error (DomException.INVALID_DOC);
+
+                               try {
+                                       doc = new Document.from_path ("test_invalid.xml");
+                                       assert_not_reached ();
+                               } catch (GXml.Error e) {
+                                       assert (e is GXml.Error.PARSER);
+                               }
+                               test_error (DomException.INVALID_DOC);
+                       });
                Test.add_func ("/gxml/document/construct_from_stream", () => {
+                               File fin;
+                               InputStream instream;
+                               Document doc;
+
                                try {
-                                       File fin = File.new_for_path (GXmlTest.get_test_dir () + "/test.xml");
-                                       InputStream instream = fin.read (null);
-                                       // TODO use cancellable
+                                       fin = File.new_for_path (GXmlTest.get_test_dir () + "/test.xml");
+                                       instream = fin.read (null);
+                                       /* TODO: test GCancellable */
 
-                                       Document doc = new Document.from_stream (instream);
+                                       doc = new Document.from_stream (instream);
 
                                        check_contents (doc);
                                } catch (GLib.Error e) {
@@ -53,50 +85,126 @@ class DocumentTest : GXmlTest {
                                        assert_not_reached ();
                                }
                        });
+               Test.add_func ("/gxml/document/construct_from_stream_error", () => {
+                               File fin;
+                               InputStream instream;
+                               FileIOStream iostream;
+                               Document doc;
+
+                               try {
+                                       fin = File.new_tmp ("gxml.XXXXXX", out iostream);
+                                       instream = fin.read (null);
+                                       doc = new Document.from_stream (instream);
+                                       assert_not_reached ();
+                               } catch (GXml.Error e) {
+                                       assert (e is GXml.Error.PARSER);
+                               } catch (GLib.Error e) {
+                                       stderr.printf ("Test encountered unexpected error '%s'\n", e.message);
+                                       assert_not_reached ();
+                               }
+                               test_error (DomException.INVALID_DOC);
+                       });
                Test.add_func ("/gxml/document/construct_from_string", () => {
-                               string xml = "<Fruits><Apple></Apple><Orange></Orange></Fruits>";
-                               Document doc = new Document.from_string (xml);
+                               string xml;
+                               Document doc;
+                               GXml.Node root;
 
-                               GXml.Node root = doc.document_element;
+                               xml = "<Fruits><Apple></Apple><Orange></Orange></Fruits>";
+                               doc = new Document.from_string (xml);
+
+                               root = doc.document_element;
                                assert (root.node_name == "Fruits");
                                assert (root.has_child_nodes () == true);
                                assert (root.first_child.node_name == "Apple");
                                assert (root.last_child.node_name == "Orange");
                        });
                Test.add_func ("/gxml/document/save", () => {
-                               try {
-                                       Document doc = get_doc ();
-                                       int exit_status;
-                                       doc.save_to_path (GLib.Environment.get_tmp_dir () + 
"/test_out_path.xml"); // TODO: /tmp because of 'make distcheck' being readonly, want to use 
GXmlTest.get_test_dir () if readable, though
+                               Document doc;
+                               int exit_status;
 
-                                       Process.spawn_sync (null,  { "/usr/bin/diff", 
GLib.Environment.get_tmp_dir () + "/test_out_path.xml", GXmlTest.get_test_dir () + 
"/test_out_path_expected.xml" }, null, 0, null, null /* stdout */, null /* stderr */, out exit_status);
+                               try {
+                                       doc = get_doc ();
+                                       /* TODO: /tmp because of 'make distcheck' being
+                                          readonly, want to use GXmlTest.get_test_dir () if
+                                          readable, though */
+                                       doc.save_to_path (GLib.Environment.get_tmp_dir () + 
"/test_out_path.xml");
+
+                                       Process.spawn_sync (null,
+                                                           { "/usr/bin/diff",
+                                                             GLib.Environment.get_tmp_dir () + 
"/test_out_path.xml",
+                                                             GXmlTest.get_test_dir () + 
"/test_out_path_expected.xml" },
+                                                           null, 0, null, null /* stdout */, null /* stderr 
*/, out exit_status);
                                        assert (exit_status == 0);
                                } catch (GLib.Error e) {
                                        Test.message ("%s", e.message);
                                        assert_not_reached ();
                                }
                        });
+               Test.add_func ("/gxml/document/save_error", () => {
+                               Document doc;
+
+                               try {
+                                       doc = get_doc ();
+                                       doc.save_to_path ("/tmp/a/b/c/d/e/f/g/h/i");
+                                       assert_not_reached ();
+                               } catch (GXml.Error e) {
+                                       assert (e is GXml.Error.WRITER);
+                               }
+                               test_error (DomException.X_OTHER);
+                       });
+
                Test.add_func ("/gxml/document/save_to_stream", () => {
                                try {
-                                       File fin = File.new_for_path (GXmlTest.get_test_dir () + "/test.xml");
-                                       InputStream instream = fin.read (null);
+                                       File fin;
+                                       File fout;
+                                       InputStream instream;
+                                       OutputStream outstream;
+                                       Document doc;
+                                       int exit_status;
 
-                                       File fout = File.new_for_path (GLib.Environment.get_tmp_dir () + 
"/test_out_stream.xml");
-                                       // OutputStream outstream = fout.create 
(FileCreateFlags.REPLACE_DESTINATION, null); // REPLACE_DESTINATION doesn't work like I thought it would?
-                                       OutputStream outstream = fout.replace (null, true, 
FileCreateFlags.REPLACE_DESTINATION, null);
+                                       fin = File.new_for_path (GXmlTest.get_test_dir () + "/test.xml");
+                                       instream = fin.read (null);
 
-                                       Document doc = new Document.from_stream (instream);
-                                       int exit_status;
+                                       fout = File.new_for_path (GLib.Environment.get_tmp_dir () + 
"/test_out_stream.xml");
+                                       // OutputStream outstream = fout.create 
(FileCreateFlags.REPLACE_DESTINATION, null); // REPLACE_DESTINATION doesn't work like I thought it would?
+                                       outstream = fout.replace (null, true, 
FileCreateFlags.REPLACE_DESTINATION, null);
 
+                                       doc = new Document.from_stream (instream);
                                        doc.save_to_stream (outstream);
 
-                                       Process.spawn_sync (null,  { "/usr/bin/diff", 
GLib.Environment.get_tmp_dir () + "/test_out_stream.xml", GXmlTest.get_test_dir () + 
"/test_out_stream_expected.xml" }, null, 0, null, null /* stdout */, null /* stderr */, out exit_status);
+                                       Process.spawn_sync (null,
+                                                           { "/usr/bin/diff",
+                                                             GLib.Environment.get_tmp_dir () + 
"/test_out_stream.xml",
+                                                             GXmlTest.get_test_dir () + 
"/test_out_stream_expected.xml" },
+                                                           null, 0, null, null /* stdout */, null /* stderr 
*/, out exit_status);
+
                                        assert (exit_status == 0);
                                } catch (GLib.Error e) {
                                        Test.message ("%s", e.message);
                                        assert_not_reached ();
                                }
                        });
+               Test.add_func ("/gxml/document/save_to_stream_error", () => {
+                               try {
+                                       File fout;
+                                       FileIOStream iostream;
+                                       OutputStream outstream;
+                                       Document doc;
+                                       int exit_status;
+
+                                       doc = GXmlTest.get_doc ();
+
+                                       fout = File.new_tmp ("gxml.XXXXXX", out iostream);
+                                       outstream = fout.replace (null, true, 
FileCreateFlags.REPLACE_DESTINATION, null);
+                                       outstream.close ();
+
+                                       doc.save_to_stream (outstream);
+                                       assert_not_reached ();
+                               } catch (GXml.Error e) {
+                                       assert (e is GXml.Error.WRITER);
+                               }
+                               test_error (DomException.X_OTHER);
+                       });
                Test.add_func ("/gxml/document/create_element", () => {
                                Document doc = get_doc ();
                                Element elem = null;
diff --git a/test/GXmlTest.vala b/test/GXmlTest.vala
index ef242a1..978a2b6 100644
--- a/test/GXmlTest.vala
+++ b/test/GXmlTest.vala
@@ -8,6 +8,7 @@ class GXmlTest {
 
        internal static void test_error (GXml.DomException expected) {
                if (expected != GXml.last_error) {
+                       stderr.printf ("Expected last error [%s] but found [%s]", expected.to_string (), 
GXml.last_error.to_string ());
                        Test.message ("Expected last error [%s] but found [%s]", expected.to_string (), 
GXml.last_error.to_string ());
                        Test.fail ();
                }
@@ -45,7 +46,12 @@ class GXmlTest {
 
        internal static Document get_doc () {
                Document doc = null;
-               doc = new Document.from_path (get_test_dir () + "/test.xml");
+               try {
+                       doc = new Document.from_path (get_test_dir () + "/test.xml");
+               } catch (GXml.Error e) {
+                       GLib.warning (e.message);
+                       assert_not_reached ();
+               }
                return doc;
        }
 
diff --git a/vapi/glib-2.0.vapi b/vapi/glib-2.0.vapi
index 869c25b..8538395 100644
--- a/vapi/glib-2.0.vapi
+++ b/vapi/glib-2.0.vapi
@@ -21,7 +21,7 @@
  * As a special exception, if you use inline functions from this file, this
  * file does not by itself cause the resulting executable to be covered by
  * the GNU Lesser General Public License.
- * 
+ *
  * Author:
  *     Jürg Billeter <j bitron ch>
  *     Raffaele Sandrini <rasa gmx ch>
@@ -1194,7 +1194,7 @@ public class string {
        public bool validate (ssize_t max_len = -1, out char* end = null);
        [CCode (cname = "g_utf8_normalize")]
        public string normalize (ssize_t len = -1, NormalizeMode mode = NormalizeMode.DEFAULT);
-       
+
        [CCode (cname = "g_utf8_strup")]
        public string up (ssize_t len = -1);
        [CCode (cname = "g_utf8_strdown")]
@@ -1210,7 +1210,7 @@ public class string {
 
        [CCode (cname = "g_locale_to_utf8")]
        public string locale_to_utf8 (ssize_t len, out size_t bytes_read, out size_t bytes_written, out 
GLib.Error error = null);
-  
+
        [CCode (cname = "g_strchomp")]
        public unowned string _chomp();
        public string chomp () {
@@ -1242,10 +1242,10 @@ public class string {
                result._delimit (delimiters, new_delimiter);
                return result;
        }
-       
+
        [CCode (cname = "g_str_hash")]
        public uint hash ();
-       
+
        [Deprecated (replacement = "int.parse")]
        [CCode (cname = "atoi")]
        public int to_int ();
@@ -1429,7 +1429,7 @@ namespace GLib {
        namespace Math {
                [CCode (cname = "G_E")]
                public const double E;
-               
+
                [CCode (cname = "G_PI")]
                public const double PI;
 
@@ -1641,7 +1641,7 @@ namespace GLib {
                public bool is_running ();
                public unowned MainContext get_context ();
        }
-       
+
        namespace Priority {
                public const int HIGH;
                public const int DEFAULT;
@@ -1688,7 +1688,7 @@ namespace GLib {
                public void invoke (owned SourceFunc function, [CCode (pos = 0.1)] int priority = 
Priority.DEFAULT);
                public void invoke_full (int priority, owned SourceFunc function);
        }
-       
+
        [CCode (has_target = false)]
        public delegate int PollFunc (PollFD[] ufds, int timeout_);
 
@@ -1725,18 +1725,18 @@ namespace GLib {
        }
 
        public delegate void ChildWatchFunc (Pid pid, int status);
-       
+
        [CCode (cname = "GSource")]
        public class ChildWatchSource : Source {
                public ChildWatchSource (Pid pid);
        }
-       
+
        namespace ChildWatch {
                [CCode (cname = "g_child_watch_add_full")]
                public static uint add (Pid pid, owned ChildWatchFunc function, [CCode (pos = 0.1)] int 
priority = Priority.DEFAULT_IDLE);
                public static uint add_full (int priority, Pid pid, owned ChildWatchFunc function);
        }
-       
+
        public struct PollFD {
                public int fd;
                public IOCondition events;
@@ -1799,7 +1799,7 @@ namespace GLib {
                public SourceCallbackUnrefFunc unref;
                public SourceCallbackGetFunc @get;
        }
-       
+
        public delegate bool SourceFunc ();
 
        public errordomain ThreadError {
@@ -1810,7 +1810,7 @@ namespace GLib {
 
        public delegate G ThreadFunc<G> ();
        public delegate void Func<G> (G data);
-       
+
        [CCode (has_type_id = false)]
        public enum ThreadPriority {
                LOW,
@@ -1818,7 +1818,7 @@ namespace GLib {
                HIGH,
                URGENT
        }
-       
+
        [Compact]
 #if GLIB_2_32
        [CCode (ref_function = "g_thread_ref", unref_function = "g_thread_unref")]
@@ -1947,7 +1947,7 @@ namespace GLib {
                public bool timed_wait (Mutex mutex, TimeVal abs_time);
                public bool wait_until (Mutex mutex, int64 end_time);
        }
-       
+
        /* Thread Pools */
 
        [Compact]
@@ -1967,7 +1967,7 @@ namespace GLib {
                public static void set_max_idle_time (uint interval);
                public static uint get_max_idle_time ();
        }
-       
+
        /* Asynchronous Queues */
 
        [Compact]
@@ -1995,7 +1995,7 @@ namespace GLib {
        }
 
        /* Memory Allocation */
-       
+
        public static void* malloc (size_t n_bytes);
        public static void* malloc0 (size_t n_bytes);
        public static void* realloc (void* mem, size_t n_bytes);
@@ -2003,7 +2003,7 @@ namespace GLib {
        public static void* try_malloc (size_t n_bytes);
        public static void* try_malloc0 (size_t n_bytes);
        public static void* try_realloc (void* mem, size_t n_bytes);
-       
+
        public static void free (void* mem);
 
        public class MemVTable {
@@ -2100,7 +2100,7 @@ namespace GLib {
                SET,
                END
        }
-       
+
        [CCode (has_type_id = false)]
        public enum IOStatus {
                ERROR,
@@ -2161,7 +2161,7 @@ namespace GLib {
                public int code;
                public string message;
        }
-       
+
        /* Message Output and Debugging Functions */
 
        [PrintfFormat]
@@ -2195,7 +2195,7 @@ namespace GLib {
        public static void breakpoint ();
 
        /* Message Logging */
-       
+
        [CCode (cprefix = "G_LOG_", has_type_id = false)]
        public enum LogLevelFlags {
                /* log flags */
@@ -2217,7 +2217,7 @@ namespace GLib {
        [Diagnostics]
        [PrintfFormat]
        public void log (string? log_domain, LogLevelFlags log_level, string format, ...);
-       
+
        [Diagnostics]
        [PrintfFormat]
        public void message (string format, ...);
@@ -2268,7 +2268,7 @@ namespace GLib {
        public unowned string strerror (int errnum);
 
        /* Character Set Conversions */
-       
+
        public static string convert (string str, ssize_t len, string to_codeset, string from_codeset, out 
size_t bytes_read = null, out size_t bytes_written = null) throws ConvertError;
        public static bool get_charset (out unowned string charset);
 
@@ -2299,7 +2299,7 @@ namespace GLib {
        }
 
        /* Base64 Encoding */
-       
+
        namespace Base64 {
                public static size_t encode_step (uchar[] _in, bool break_lines, char* _out, ref int state, 
ref int save);
                public static size_t encode_close (bool break_lines, char* _out, ref int state, ref int save);
@@ -2381,7 +2381,7 @@ namespace GLib {
                [CCode (cname = "g_date_get_days_in_month")]
                public uchar get_days_in_month (DateYear year);
                [CCode (cname = "g_date_valid_month")]
-               public bool valid (); 
+               public bool valid ();
        }
 
        public struct DateYear : ushort {
@@ -2410,7 +2410,7 @@ namespace GLib {
                SUNDAY;
 
                [CCode (cname = "g_date_valid_weekday")]
-               public bool valid (); 
+               public bool valid ();
        }
 
        [CCode (cprefix = "G_DATE_", has_type_id = false)]
@@ -2622,7 +2622,7 @@ namespace GLib {
                public double next_double ();
                public double double_range (double begin, double end);
        }
-       
+
        namespace Random {
                public static void set_seed (uint32 seed);
                public static bool boolean ();
@@ -2633,9 +2633,9 @@ namespace GLib {
                public static double next_double ();
                public static double double_range (double begin, double end);
        }
-       
+
        /* Miscellaneous Utility Functions */
-       
+
        namespace Environment {
                [CCode (cname = "g_get_application_name")]
                public static unowned string? get_application_name ();
@@ -2999,7 +2999,7 @@ namespace GLib {
                public static bool spawn_command_line_sync (string command_line, out string standard_output = 
null, out string standard_error = null, out int exit_status = null) throws SpawnError;
                [CCode (cname = "g_spawn_close_pid")]
                public static void close_pid (Pid pid);
-               
+
                /* these macros are required to examine the exit status of a process */
                [CCode (cname = "WIFEXITED", cheader_filename = "sys/wait.h")]
                public static bool if_exited (int status);
@@ -3029,7 +3029,7 @@ namespace GLib {
                [CCode (cname = "signal", cheader_filename = "signal.h")]
                public SignalHandlerFunc @signal (ProcessSignal signum, SignalHandlerFunc handler);
        }
-       
+
        [CCode (cname = "int", has_type_id = false, cheader_filename = "signal.h", cprefix = "SIG")]
        public enum ProcessSignal {
                HUP,
@@ -3054,8 +3054,8 @@ namespace GLib {
                TTIN,
                TTOU
        }
-               
-       
+
+
        /* File Utilities */
 
        public errordomain FileError {
@@ -3182,7 +3182,7 @@ namespace GLib {
                public static int open_tmp (string tmpl, out string name_used) throws FileError;
                public static string read_link (string filename) throws FileError;
                public static int error_from_errno (int err_no);
-               
+
                [CCode (cname = "g_mkstemp")]
                public static int mkstemp (string tmpl);
                [CCode (cname = "g_rename")]
@@ -3193,7 +3193,7 @@ namespace GLib {
                public static int unlink (string filename);
                [CCode (cname = "g_chmod")]
                public static int chmod (string filename, int mode);
-               
+
                [CCode (cname = "symlink")]
                public static int symlink (string oldpath, string newpath);
 
@@ -3216,7 +3216,7 @@ namespace GLib {
                public unowned string? read_name ();
                public void rewind ();
        }
-       
+
        namespace DirUtils {
                [CCode (cname = "g_mkdir")]
                public static int create (string pathname, int mode);
@@ -3247,7 +3247,7 @@ namespace GLib {
 
        [CCode (cname = "stdout", cheader_filename = "stdio.h")]
        public static FileStream stdout;
-       
+
        [CCode (cname = "stderr", cheader_filename = "stdio.h")]
        public static FileStream stderr;
 
@@ -3326,7 +3326,7 @@ namespace GLib {
                DOUBLE,
                INT64
        }
-       
+
        [Flags]
        [CCode (cprefix = "G_OPTION_FLAG_", has_type_id = false)]
        public enum OptionFlags {
@@ -3338,7 +3338,7 @@ namespace GLib {
                OPTIONAL_ARG,
                NOALIAS
        }
-       
+
        public struct OptionEntry {
                public unowned string long_name;
                public char short_name;
@@ -3487,17 +3487,17 @@ namespace GLib {
                public void* pop ();
                public void* get_user_data ();
        }
-       
+
        public delegate void MarkupParserStartElementFunc (MarkupParseContext context, string element_name, 
[CCode (array_length = false, array_null_terminated = true)] string[] attribute_names, [CCode (array_length = 
false, array_null_terminated = true)] string[] attribute_values) throws MarkupError;
-       
+
        public delegate void MarkupParserEndElementFunc (MarkupParseContext context, string element_name) 
throws MarkupError;
-       
+
        public delegate void MarkupParserTextFunc (MarkupParseContext context, string text, size_t text_len) 
throws MarkupError;
-       
+
        public delegate void MarkupParserPassthroughFunc (MarkupParseContext context, string 
passthrough_text, size_t text_len) throws MarkupError;
-       
+
        public delegate void MarkupParserErrorFunc (MarkupParseContext context, Error error);
-       
+
        public struct MarkupParser {
                [CCode (delegate_target = false)]
                public unowned MarkupParserStartElementFunc start_element;
@@ -3600,7 +3600,7 @@ namespace GLib {
                public void remove_key (string group_name, string key) throws KeyFileError;
                public void remove_comment (string group_name, string key) throws KeyFileError;
        }
-       
+
        [CCode (cprefix = "G_KEY_FILE_", has_type_id = false)]
        public enum KeyFileFlags {
                NONE,
@@ -3791,7 +3791,7 @@ namespace GLib {
                public void delete_link (List<G> link_);
                [ReturnsModifiedPointer ()]
                public void remove_all (G data);
-               
+
                public uint length ();
                public List<unowned G> copy ();
                [ReturnsModifiedPointer ()]
@@ -3811,17 +3811,17 @@ namespace GLib {
                public unowned List<G> nth (uint n);
                public unowned G nth_data (uint n);
                public unowned List<G> nth_prev (uint n);
-               
+
                public unowned List<G> find (G data);
                public unowned List<G> find_custom (G data, CompareFunc<G> func);
                public int position (List<G> llink);
                public int index (G data);
-               
+
                public G data;
                public List<G> next;
                public unowned List<G> prev;
        }
-       
+
        /* Singly-Linked Lists */
 
        [Compact]
@@ -3891,7 +3891,7 @@ namespace GLib {
                public unowned List<G> head;
                public unowned List<G> tail;
                public uint length;
-       
+
                public Queue ();
 
                public void clear ();
@@ -4378,11 +4378,11 @@ namespace GLib {
                public unowned G index (uint index);
                public void set_size (uint length);
        }
-       
+
        /* GTree */
-       
+
        public delegate int TraverseFunc (void* key, void* value);
-       
+
        [CCode (cprefix = "G_", has_type_id = false)]
        public enum TraverseType {
                IN_ORDER,
@@ -4416,9 +4416,9 @@ namespace GLib {
                public bool remove (K key);
                public bool steal (K key);
        }
-       
+
        /* Internationalization */
-       
+
        [CCode (cname = "_", cheader_filename = "glib.h,glib/gi18n-lib.h")]
        public static unowned string _ (string str);
        [CCode (cname = "Q_", cheader_filename = "glib.h,glib/gi18n-lib.h")]
@@ -4441,7 +4441,7 @@ namespace GLib {
        public static unowned string dpgettext (string? domain, string msgctxid, size_t msgidoffset);
        [CCode (cname = "g_dpgettext2", cheader_filename = "glib/gi18n-lib.h")]
        public static unowned string dpgettext2 (string? domain, string context, string msgid);
-       
+
        [CCode (cname = "int", cprefix = "LC_", cheader_filename = "locale.h", has_type_id = false)]
        public enum LocaleCategory {
                ALL,
@@ -4452,7 +4452,7 @@ namespace GLib {
                NUMERIC,
                TIME
        }
-       
+
        namespace Intl {
                [CCode (cname = "setlocale", cheader_filename = "locale.h")]
                public static unowned string? setlocale (LocaleCategory category, string? locale);
diff --git a/vapi/libxml-2.0.vapi b/vapi/libxml-2.0.vapi
index eee6746..f20a815 100644
--- a/vapi/libxml-2.0.vapi
+++ b/vapi/libxml-2.0.vapi
@@ -924,6 +924,9 @@ namespace Xml {
 
                [CCode (cname = "xmlCtxtReadIO")]
                public Doc* read_io (Xml.InputReadCallback ioread, Xml.InputCloseCallback ioclose, void* 
ioctx, string url, string? encoding = null, int options = 0);
+
+               [CCode (cname = "xmlCtxtGetLastError")]
+               public Error *get_last_error ();
        }
 
        /* TODO: consider having this return bool, but right now, 0: valid, >0: invalid, -1: internal/API 
error */
@@ -1709,7 +1712,7 @@ namespace Xml {
        [Compact]
        [CCode (cname = "xmlError", cheader_filename = "libxml/xmlerror.h")]
        public struct Error {
-               public int domain;
+               public ErrorDomain domain;
                public int code;
                public string message;
                public ErrorLevel level;
@@ -1722,8 +1725,47 @@ namespace Xml {
                public int int2;
                public void* ctx;
                public void* node;
+
+               // TODO: should this just be get_last instead?
+               [CCode (cname = "xmlGetLastError")]
+               public static Xml.Error *get_last_error ();
        }
 
+       [CCode (cname = "xmlErrorDomain", cprefix = "XML_FROM_", cheader_filename = "libxml/xmlerror.h", 
has_type_id = false)]
+       public enum ErrorDomain {
+        NONE = 0,
+        PARSER = 1, /* The XML parser */
+        TREE = 2, /* The tree module */
+        NAMESPACE = 3, /* The XML Namespace module */
+        DTD = 4, /* The XML DTD validation with parser contex */
+        HTML = 5, /* The HTML parser */
+        MEMORY = 6, /* The memory allocator */
+        OUTPUT = 7, /* The serialization code */
+        IO = 8, /* The Input/Output stack */
+        FTP = 9, /* The FTP module */
+        HTTP = 10, /* The HTTP module */
+        XINCLUDE = 11, /* The XInclude processing */
+        XPATH = 12, /* The XPath module */
+        XPOINTER = 13, /* The XPointer module */
+        REGEXP = 14, /* The regular expressions module */
+        DATATYPE = 15, /* The W3C XML Schemas Datatype module */
+        SCHEMASP = 16, /* The W3C XML Schemas parser module */
+        SCHEMASV = 17, /* The W3C XML Schemas validation module */
+        RELAXNGP = 18, /* The Relax-NG parser module */
+        RELAXNGV = 19, /* The Relax-NG validator module */
+        CATALOG = 20, /* The Catalog module */
+        C14N = 21, /* The Canonicalization module */
+        XSLT = 22, /* The XSLT engine from libxslt */
+        VALID = 23, /* The XML DTD validation with valid context */
+        CHECK = 24, /* The error checking module */
+        WRITER = 25, /* The xmlwriter module */
+        MODULE = 26, /* The dynamically loaded module modul */
+        I18N = 27, /* The module handling character conversion */
+        SCHEMATRONV = 28, /* The Schematron validator module */
+        BUFFER = 29, /* The buffers module */
+        URI = 30 /*  The URI module */
+    }
+
        [CCode (cname = "xmlErrorLevel", cprefix = "XML_ERR_", cheader_filename = "libxml/xmlerror.h", 
has_type_id = false)]
        public enum ErrorLevel {
                NONE = 0,



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