/* libxml-Document.c generated by valac 0.28.1, the Vala compiler
 * generated from libxml-Document.vala, do not modify */

/* -*- Mode: vala; indent-tabs-mode: t; c-basic-offset: 2; tab-width: 2 -*- */
/* xDocument.vala
 *
 * Copyright (C) 2011-2013  Richard Schwarting <aquarichy@gmail.com>
 * Copyright (C) 2011-2015  Daniel Espinosa <esodan@gmail.com>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.

 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.

 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, see <http://www.gnu.org/licenses/>.
 *
 * Authors:
 *      Richard Schwarting <aquarichy@gmail.com>
 *      Daniel Espinosa <esodan@gmail.com>
 */
/* TODO:
 * * later on, go over libxml2 docs for Tree and xNode and xDocument, etc., and see if we're missing anything significant
 * * compare performance between libxml2 and GXml (should be a little different, but not too much)
 */
/* TODO:IMPORTANT: don't use GLib collections, use Libgee! */
/** Constructors */
/*** Node methods ***/

#include <glib.h>
#include <glib-object.h>
#include <stdlib.h>
#include <string.h>
#include <gee.h>
#include <gio/gio.h>
#include <libxml/tree.h>
#include <libxml/parser.h>
#include <glib/gi18n-lib.h>
#include <libxml/xmlerror.h>
#include "gxml/xlibxml.h"
#include "gxml//xlibxml.h"


#define GXML_TYPE_NODE (gxml_node_get_type ())
#define GXML_NODE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GXML_TYPE_NODE, GXmlNode))
#define GXML_IS_NODE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GXML_TYPE_NODE))
#define GXML_NODE_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), GXML_TYPE_NODE, GXmlNodeIface))

typedef struct _GXmlNode GXmlNode;
typedef struct _GXmlNodeIface GXmlNodeIface;

#define GXML_TYPE_ELEMENT_LIST (gxml_element_list_get_type ())
#define GXML_ELEMENT_LIST(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GXML_TYPE_ELEMENT_LIST, GXmlElementList))
#define GXML_ELEMENT_LIST_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GXML_TYPE_ELEMENT_LIST, GXmlElementListClass))
#define GXML_IS_ELEMENT_LIST(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GXML_TYPE_ELEMENT_LIST))
#define GXML_IS_ELEMENT_LIST_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GXML_TYPE_ELEMENT_LIST))
#define GXML_ELEMENT_LIST_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GXML_TYPE_ELEMENT_LIST, GXmlElementListClass))

typedef struct _GXmlElementList GXmlElementList;
typedef struct _GXmlElementListClass GXmlElementListClass;

#define GXML_TYPE_NAMESPACE (gxml_namespace_get_type ())
#define GXML_NAMESPACE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GXML_TYPE_NAMESPACE, GXmlNamespace))
#define GXML_IS_NAMESPACE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GXML_TYPE_NAMESPACE))
#define GXML_NAMESPACE_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), GXML_TYPE_NAMESPACE, GXmlNamespaceIface))

typedef struct _GXmlNamespace GXmlNamespace;
typedef struct _GXmlNamespaceIface GXmlNamespaceIface;

#define GXML_TYPE_NODE_TYPE (gxml_node_type_get_type ())

#define GXML_TYPE_DOCUMENT (gxml_document_get_type ())
#define GXML_DOCUMENT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GXML_TYPE_DOCUMENT, GXmlDocument))
#define GXML_IS_DOCUMENT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GXML_TYPE_DOCUMENT))
#define GXML_DOCUMENT_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), GXML_TYPE_DOCUMENT, GXmlDocumentIface))

typedef struct _GXmlDocument GXmlDocument;
typedef struct _GXmlDocumentIface GXmlDocumentIface;

#define GXML_TYPE_XNODE (gxml_xnode_get_type ())
#define GXML_XNODE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GXML_TYPE_XNODE, GXmlxNode))
#define GXML_XNODE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GXML_TYPE_XNODE, GXmlxNodeClass))
#define GXML_IS_XNODE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GXML_TYPE_XNODE))
#define GXML_IS_XNODE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GXML_TYPE_XNODE))
#define GXML_XNODE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GXML_TYPE_XNODE, GXmlxNodeClass))

typedef struct _GXmlxNode GXmlxNode;
typedef struct _GXmlxNodeClass GXmlxNodeClass;
typedef struct _GXmlxNodePrivate GXmlxNodePrivate;

#define GXML_TYPE_NAMESPACE_ATTR (gxml_namespace_attr_get_type ())
#define GXML_NAMESPACE_ATTR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GXML_TYPE_NAMESPACE_ATTR, GXmlNamespaceAttr))
#define GXML_NAMESPACE_ATTR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GXML_TYPE_NAMESPACE_ATTR, GXmlNamespaceAttrClass))
#define GXML_IS_NAMESPACE_ATTR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GXML_TYPE_NAMESPACE_ATTR))
#define GXML_IS_NAMESPACE_ATTR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GXML_TYPE_NAMESPACE_ATTR))
#define GXML_NAMESPACE_ATTR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GXML_TYPE_NAMESPACE_ATTR, GXmlNamespaceAttrClass))

typedef struct _GXmlNamespaceAttr GXmlNamespaceAttr;
typedef struct _GXmlNamespaceAttrClass GXmlNamespaceAttrClass;

#define GXML_TYPE_XNODE_LIST (gxml_xnode_list_get_type ())
#define GXML_XNODE_LIST(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GXML_TYPE_XNODE_LIST, GXmlxNodeList))
#define GXML_IS_XNODE_LIST(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GXML_TYPE_XNODE_LIST))
#define GXML_XNODE_LIST_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), GXML_TYPE_XNODE_LIST, GXmlxNodeListIface))

typedef struct _GXmlxNodeList GXmlxNodeList;
typedef struct _GXmlxNodeListIface GXmlxNodeListIface;

#define GXML_TYPE_ABSTRACT_NAMED_ATTR_MAP (gxml_abstract_named_attr_map_get_type ())
#define GXML_ABSTRACT_NAMED_ATTR_MAP(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GXML_TYPE_ABSTRACT_NAMED_ATTR_MAP, GXmlAbstractNamedAttrMap))
#define GXML_ABSTRACT_NAMED_ATTR_MAP_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GXML_TYPE_ABSTRACT_NAMED_ATTR_MAP, GXmlAbstractNamedAttrMapClass))
#define GXML_IS_ABSTRACT_NAMED_ATTR_MAP(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GXML_TYPE_ABSTRACT_NAMED_ATTR_MAP))
#define GXML_IS_ABSTRACT_NAMED_ATTR_MAP_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GXML_TYPE_ABSTRACT_NAMED_ATTR_MAP))
#define GXML_ABSTRACT_NAMED_ATTR_MAP_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GXML_TYPE_ABSTRACT_NAMED_ATTR_MAP, GXmlAbstractNamedAttrMapClass))

typedef struct _GXmlAbstractNamedAttrMap GXmlAbstractNamedAttrMap;
typedef struct _GXmlAbstractNamedAttrMapClass GXmlAbstractNamedAttrMapClass;

#define GXML_TYPE_NAMED_ATTR_MAP (gxml_named_attr_map_get_type ())
#define GXML_NAMED_ATTR_MAP(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GXML_TYPE_NAMED_ATTR_MAP, GXmlNamedAttrMap))
#define GXML_NAMED_ATTR_MAP_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GXML_TYPE_NAMED_ATTR_MAP, GXmlNamedAttrMapClass))
#define GXML_IS_NAMED_ATTR_MAP(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GXML_TYPE_NAMED_ATTR_MAP))
#define GXML_IS_NAMED_ATTR_MAP_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GXML_TYPE_NAMED_ATTR_MAP))
#define GXML_NAMED_ATTR_MAP_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GXML_TYPE_NAMED_ATTR_MAP, GXmlNamedAttrMapClass))

typedef struct _GXmlNamedAttrMap GXmlNamedAttrMap;
typedef struct _GXmlNamedAttrMapClass GXmlNamedAttrMapClass;

#define GXML_TYPE_ABSTRACT_NAMESPACE_ATTR_NODE_LIST (gxml_abstract_namespace_attr_node_list_get_type ())
#define GXML_ABSTRACT_NAMESPACE_ATTR_NODE_LIST(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GXML_TYPE_ABSTRACT_NAMESPACE_ATTR_NODE_LIST, GXmlAbstractNamespaceAttrNodeList))
#define GXML_ABSTRACT_NAMESPACE_ATTR_NODE_LIST_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GXML_TYPE_ABSTRACT_NAMESPACE_ATTR_NODE_LIST, GXmlAbstractNamespaceAttrNodeListClass))
#define GXML_IS_ABSTRACT_NAMESPACE_ATTR_NODE_LIST(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GXML_TYPE_ABSTRACT_NAMESPACE_ATTR_NODE_LIST))
#define GXML_IS_ABSTRACT_NAMESPACE_ATTR_NODE_LIST_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GXML_TYPE_ABSTRACT_NAMESPACE_ATTR_NODE_LIST))
#define GXML_ABSTRACT_NAMESPACE_ATTR_NODE_LIST_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GXML_TYPE_ABSTRACT_NAMESPACE_ATTR_NODE_LIST, GXmlAbstractNamespaceAttrNodeListClass))

typedef struct _GXmlAbstractNamespaceAttrNodeList GXmlAbstractNamespaceAttrNodeList;
typedef struct _GXmlAbstractNamespaceAttrNodeListClass GXmlAbstractNamespaceAttrNodeListClass;

#define GXML_TYPE_NAMESPACE_ATTR_NODE_LIST (gxml_namespace_attr_node_list_get_type ())
#define GXML_NAMESPACE_ATTR_NODE_LIST(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GXML_TYPE_NAMESPACE_ATTR_NODE_LIST, GXmlNamespaceAttrNodeList))
#define GXML_NAMESPACE_ATTR_NODE_LIST_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GXML_TYPE_NAMESPACE_ATTR_NODE_LIST, GXmlNamespaceAttrNodeListClass))
#define GXML_IS_NAMESPACE_ATTR_NODE_LIST(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GXML_TYPE_NAMESPACE_ATTR_NODE_LIST))
#define GXML_IS_NAMESPACE_ATTR_NODE_LIST_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GXML_TYPE_NAMESPACE_ATTR_NODE_LIST))
#define GXML_NAMESPACE_ATTR_NODE_LIST_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GXML_TYPE_NAMESPACE_ATTR_NODE_LIST, GXmlNamespaceAttrNodeListClass))

typedef struct _GXmlNamespaceAttrNodeList GXmlNamespaceAttrNodeList;
typedef struct _GXmlNamespaceAttrNodeListClass GXmlNamespaceAttrNodeListClass;

#define GXML_TYPE_XDOCUMENT (gxml_xdocument_get_type ())
#define GXML_XDOCUMENT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GXML_TYPE_XDOCUMENT, GXmlxDocument))
#define GXML_XDOCUMENT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GXML_TYPE_XDOCUMENT, GXmlxDocumentClass))
#define GXML_IS_XDOCUMENT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GXML_TYPE_XDOCUMENT))
#define GXML_IS_XDOCUMENT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GXML_TYPE_XDOCUMENT))
#define GXML_XDOCUMENT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GXML_TYPE_XDOCUMENT, GXmlxDocumentClass))

typedef struct _GXmlxDocument GXmlxDocument;
typedef struct _GXmlxDocumentClass GXmlxDocumentClass;
typedef struct _GXmlxDocumentPrivate GXmlxDocumentPrivate;

#define GXML_TYPE_BACKED_NODE (gxml_backed_node_get_type ())
#define GXML_BACKED_NODE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GXML_TYPE_BACKED_NODE, GXmlBackedNode))
#define GXML_BACKED_NODE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GXML_TYPE_BACKED_NODE, GXmlBackedNodeClass))
#define GXML_IS_BACKED_NODE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GXML_TYPE_BACKED_NODE))
#define GXML_IS_BACKED_NODE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GXML_TYPE_BACKED_NODE))
#define GXML_BACKED_NODE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GXML_TYPE_BACKED_NODE, GXmlBackedNodeClass))

typedef struct _GXmlBackedNode GXmlBackedNode;
typedef struct _GXmlBackedNodeClass GXmlBackedNodeClass;

#define GXML_TYPE_XELEMENT (gxml_xelement_get_type ())
#define GXML_XELEMENT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GXML_TYPE_XELEMENT, GXmlxElement))
#define GXML_XELEMENT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GXML_TYPE_XELEMENT, GXmlxElementClass))
#define GXML_IS_XELEMENT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GXML_TYPE_XELEMENT))
#define GXML_IS_XELEMENT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GXML_TYPE_XELEMENT))
#define GXML_XELEMENT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GXML_TYPE_XELEMENT, GXmlxElementClass))

typedef struct _GXmlxElement GXmlxElement;
typedef struct _GXmlxElementClass GXmlxElementClass;

#define GXML_TYPE_CHILD_NODE_LIST (gxml_child_node_list_get_type ())
#define GXML_CHILD_NODE_LIST(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GXML_TYPE_CHILD_NODE_LIST, GXmlChildNodeList))
#define GXML_CHILD_NODE_LIST_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GXML_TYPE_CHILD_NODE_LIST, GXmlChildNodeListClass))
#define GXML_IS_CHILD_NODE_LIST(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GXML_TYPE_CHILD_NODE_LIST))
#define GXML_IS_CHILD_NODE_LIST_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GXML_TYPE_CHILD_NODE_LIST))
#define GXML_CHILD_NODE_LIST_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GXML_TYPE_CHILD_NODE_LIST, GXmlChildNodeListClass))

typedef struct _GXmlChildNodeList GXmlChildNodeList;
typedef struct _GXmlChildNodeListClass GXmlChildNodeListClass;

#define GXML_TYPE_NODE_CHILD_NODE_LIST (gxml_node_child_node_list_get_type ())
#define GXML_NODE_CHILD_NODE_LIST(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GXML_TYPE_NODE_CHILD_NODE_LIST, GXmlNodeChildNodeList))
#define GXML_NODE_CHILD_NODE_LIST_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GXML_TYPE_NODE_CHILD_NODE_LIST, GXmlNodeChildNodeListClass))
#define GXML_IS_NODE_CHILD_NODE_LIST(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GXML_TYPE_NODE_CHILD_NODE_LIST))
#define GXML_IS_NODE_CHILD_NODE_LIST_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GXML_TYPE_NODE_CHILD_NODE_LIST))
#define GXML_NODE_CHILD_NODE_LIST_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GXML_TYPE_NODE_CHILD_NODE_LIST, GXmlNodeChildNodeListClass))

typedef struct _GXmlNodeChildNodeList GXmlNodeChildNodeList;
typedef struct _GXmlNodeChildNodeListClass GXmlNodeChildNodeListClass;

#define GXML_TYPE_XDOCUMENT_TYPE (gxml_xdocument_type_get_type ())
#define GXML_XDOCUMENT_TYPE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GXML_TYPE_XDOCUMENT_TYPE, GXmlxDocumentType))
#define GXML_XDOCUMENT_TYPE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GXML_TYPE_XDOCUMENT_TYPE, GXmlxDocumentTypeClass))
#define GXML_IS_XDOCUMENT_TYPE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GXML_TYPE_XDOCUMENT_TYPE))
#define GXML_IS_XDOCUMENT_TYPE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GXML_TYPE_XDOCUMENT_TYPE))
#define GXML_XDOCUMENT_TYPE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GXML_TYPE_XDOCUMENT_TYPE, GXmlxDocumentTypeClass))

typedef struct _GXmlxDocumentType GXmlxDocumentType;
typedef struct _GXmlxDocumentTypeClass GXmlxDocumentTypeClass;

#define GXML_TYPE_IMPLEMENTATION (gxml_implementation_get_type ())
#define GXML_IMPLEMENTATION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GXML_TYPE_IMPLEMENTATION, GXmlImplementation))
#define GXML_IMPLEMENTATION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GXML_TYPE_IMPLEMENTATION, GXmlImplementationClass))
#define GXML_IS_IMPLEMENTATION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GXML_TYPE_IMPLEMENTATION))
#define GXML_IS_IMPLEMENTATION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GXML_TYPE_IMPLEMENTATION))
#define GXML_IMPLEMENTATION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GXML_TYPE_IMPLEMENTATION, GXmlImplementationClass))

typedef struct _GXmlImplementation GXmlImplementation;
typedef struct _GXmlImplementationClass GXmlImplementationClass;
#define _g_list_free0(var) ((var == NULL) ? NULL : (var = (g_list_free (var), NULL)))
#define _g_hash_table_unref0(var) ((var == NULL) ? NULL : (var = (g_hash_table_unref (var), NULL)))
#define __g_list_free__g_object_unref0_0(var) ((var == NULL) ? NULL : (var = (_g_list_free__g_object_unref0_ (var), NULL)))
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

#define GXML_TYPE_XATTR (gxml_xattr_get_type ())
#define GXML_XATTR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GXML_TYPE_XATTR, GXmlxAttr))
#define GXML_XATTR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GXML_TYPE_XATTR, GXmlxAttrClass))
#define GXML_IS_XATTR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GXML_TYPE_XATTR))
#define GXML_IS_XATTR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GXML_TYPE_XATTR))
#define GXML_XATTR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GXML_TYPE_XATTR, GXmlxAttrClass))

typedef struct _GXmlxAttr GXmlxAttr;
typedef struct _GXmlxAttrClass GXmlxAttrClass;

#define GXML_TYPE_XCHARACTER_DATA (gxml_xcharacter_data_get_type ())
#define GXML_XCHARACTER_DATA(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GXML_TYPE_XCHARACTER_DATA, GXmlxCharacterData))
#define GXML_XCHARACTER_DATA_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GXML_TYPE_XCHARACTER_DATA, GXmlxCharacterDataClass))
#define GXML_IS_XCHARACTER_DATA(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GXML_TYPE_XCHARACTER_DATA))
#define GXML_IS_XCHARACTER_DATA_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GXML_TYPE_XCHARACTER_DATA))
#define GXML_XCHARACTER_DATA_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GXML_TYPE_XCHARACTER_DATA, GXmlxCharacterDataClass))

typedef struct _GXmlxCharacterData GXmlxCharacterData;
typedef struct _GXmlxCharacterDataClass GXmlxCharacterDataClass;

#define GXML_TYPE_XTEXT (gxml_xtext_get_type ())
#define GXML_XTEXT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GXML_TYPE_XTEXT, GXmlxText))
#define GXML_XTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GXML_TYPE_XTEXT, GXmlxTextClass))
#define GXML_IS_XTEXT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GXML_TYPE_XTEXT))
#define GXML_IS_XTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GXML_TYPE_XTEXT))
#define GXML_XTEXT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GXML_TYPE_XTEXT, GXmlxTextClass))

typedef struct _GXmlxText GXmlxText;
typedef struct _GXmlxTextClass GXmlxTextClass;

#define GXML_TYPE_XCDATA_SECTION (gxml_xcdata_section_get_type ())
#define GXML_XCDATA_SECTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GXML_TYPE_XCDATA_SECTION, GXmlxCDATASection))
#define GXML_XCDATA_SECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GXML_TYPE_XCDATA_SECTION, GXmlxCDATASectionClass))
#define GXML_IS_XCDATA_SECTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GXML_TYPE_XCDATA_SECTION))
#define GXML_IS_XCDATA_SECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GXML_TYPE_XCDATA_SECTION))
#define GXML_XCDATA_SECTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GXML_TYPE_XCDATA_SECTION, GXmlxCDATASectionClass))

typedef struct _GXmlxCDATASection GXmlxCDATASection;
typedef struct _GXmlxCDATASectionClass GXmlxCDATASectionClass;

#define GXML_TYPE_XCOMMENT (gxml_xcomment_get_type ())
#define GXML_XCOMMENT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GXML_TYPE_XCOMMENT, GXmlxComment))
#define GXML_XCOMMENT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GXML_TYPE_XCOMMENT, GXmlxCommentClass))
#define GXML_IS_XCOMMENT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GXML_TYPE_XCOMMENT))
#define GXML_IS_XCOMMENT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GXML_TYPE_XCOMMENT))
#define GXML_XCOMMENT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GXML_TYPE_XCOMMENT, GXmlxCommentClass))

typedef struct _GXmlxComment GXmlxComment;
typedef struct _GXmlxCommentClass GXmlxCommentClass;

#define GXML_TYPE_DOCUMENT_FRAGMENT (gxml_document_fragment_get_type ())
#define GXML_DOCUMENT_FRAGMENT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GXML_TYPE_DOCUMENT_FRAGMENT, GXmlDocumentFragment))
#define GXML_DOCUMENT_FRAGMENT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GXML_TYPE_DOCUMENT_FRAGMENT, GXmlDocumentFragmentClass))
#define GXML_IS_DOCUMENT_FRAGMENT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GXML_TYPE_DOCUMENT_FRAGMENT))
#define GXML_IS_DOCUMENT_FRAGMENT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GXML_TYPE_DOCUMENT_FRAGMENT))
#define GXML_DOCUMENT_FRAGMENT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GXML_TYPE_DOCUMENT_FRAGMENT, GXmlDocumentFragmentClass))

typedef struct _GXmlDocumentFragment GXmlDocumentFragment;
typedef struct _GXmlDocumentFragmentClass GXmlDocumentFragmentClass;

#define GXML_TYPE_DOM_EXCEPTION (gxml_dom_exception_get_type ())
#define _xmlFreeParserCtxt0(var) ((var == NULL) ? NULL : (var = (xmlFreeParserCtxt (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
#define _g_string_free0(var) ((var == NULL) ? NULL : (var = (g_string_free (var, TRUE), NULL)))

#define GXML_TYPE_XPROCESSING_INSTRUCTION (gxml_xprocessing_instruction_get_type ())
#define GXML_XPROCESSING_INSTRUCTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GXML_TYPE_XPROCESSING_INSTRUCTION, GXmlxProcessingInstruction))
#define GXML_XPROCESSING_INSTRUCTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GXML_TYPE_XPROCESSING_INSTRUCTION, GXmlxProcessingInstructionClass))
#define GXML_IS_XPROCESSING_INSTRUCTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GXML_TYPE_XPROCESSING_INSTRUCTION))
#define GXML_IS_XPROCESSING_INSTRUCTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GXML_TYPE_XPROCESSING_INSTRUCTION))
#define GXML_XPROCESSING_INSTRUCTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GXML_TYPE_XPROCESSING_INSTRUCTION, GXmlxProcessingInstructionClass))

typedef struct _GXmlxProcessingInstruction GXmlxProcessingInstruction;
typedef struct _GXmlxProcessingInstructionClass GXmlxProcessingInstructionClass;

#define GXML_TYPE_ENTITY_REFERENCE (gxml_entity_reference_get_type ())
#define GXML_ENTITY_REFERENCE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GXML_TYPE_ENTITY_REFERENCE, GXmlEntityReference))
#define GXML_ENTITY_REFERENCE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GXML_TYPE_ENTITY_REFERENCE, GXmlEntityReferenceClass))
#define GXML_IS_ENTITY_REFERENCE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GXML_TYPE_ENTITY_REFERENCE))
#define GXML_IS_ENTITY_REFERENCE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GXML_TYPE_ENTITY_REFERENCE))
#define GXML_ENTITY_REFERENCE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GXML_TYPE_ENTITY_REFERENCE, GXmlEntityReferenceClass))

typedef struct _GXmlEntityReference GXmlEntityReference;
typedef struct _GXmlEntityReferenceClass GXmlEntityReferenceClass;
typedef struct _GXmlBackedNodePrivate GXmlBackedNodePrivate;
#define _vala_assert(expr, msg) if G_LIKELY (expr) ; else g_assertion_message_expr (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, msg);
#define _vala_return_if_fail(expr, msg) if G_LIKELY (expr) ; else { g_return_if_fail_warning (G_LOG_DOMAIN, G_STRFUNC, msg); return; }
#define _vala_return_val_if_fail(expr, msg, val) if G_LIKELY (expr) ; else { g_return_if_fail_warning (G_LOG_DOMAIN, G_STRFUNC, msg); return val; }
#define _vala_warn_if_fail(expr, msg) if G_LIKELY (expr) ; else g_warn_message (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, msg);

struct _GXmlNamespaceIface {
	GTypeInterface parent_iface;
	gchar* (*get_uri) (GXmlNamespace* self);
	gchar* (*get_prefix) (GXmlNamespace* self);
};

typedef enum  {
	GXML_NODE_TYPE_X_UNKNOWN = 0,
	GXML_NODE_TYPE_ELEMENT = 1,
	GXML_NODE_TYPE_ATTRIBUTE,
	GXML_NODE_TYPE_TEXT,
	GXML_NODE_TYPE_CDATA_SECTION,
	GXML_NODE_TYPE_ENTITY_REFERENCE,
	GXML_NODE_TYPE_ENTITY,
	GXML_NODE_TYPE_PROCESSING_INSTRUCTION,
	GXML_NODE_TYPE_COMMENT,
	GXML_NODE_TYPE_DOCUMENT,
	GXML_NODE_TYPE_DOCUMENT_TYPE,
	GXML_NODE_TYPE_DOCUMENT_FRAGMENT,
	GXML_NODE_TYPE_NOTATION
} GXmlNodeType;

struct _GXmlDocumentIface {
	GTypeInterface parent_iface;
	GXmlNode* (*create_element) (GXmlDocument* self, const gchar* name, GError** error);
	GXmlNode* (*create_text) (GXmlDocument* self, const gchar* text);
	GXmlNode* (*create_comment) (GXmlDocument* self, const gchar* text);
	GXmlNode* (*create_cdata) (GXmlDocument* self, const gchar* text);
	GXmlNode* (*create_pi) (GXmlDocument* self, const gchar* target, const gchar* data);
	gboolean (*save) (GXmlDocument* self, GCancellable* cancellable, GError** error);
	gboolean (*save_as) (GXmlDocument* self, GFile* f, GCancellable* cancellable, GError** error);
	gboolean (*get_indent) (GXmlDocument* self);
	void (*set_indent) (GXmlDocument* self, gboolean value);
	gboolean (*get_ns_top) (GXmlDocument* self);
	void (*set_ns_top) (GXmlDocument* self, gboolean value);
	gboolean (*get_prefix_default_ns) (GXmlDocument* self);
	void (*set_prefix_default_ns) (GXmlDocument* self, gboolean value);
	gboolean (*get_backup) (GXmlDocument* self);
	void (*set_backup) (GXmlDocument* self, gboolean value);
	GXmlNode* (*get_root) (GXmlDocument* self);
	GFile* (*get_file) (GXmlDocument* self);
	void (*set_file) (GXmlDocument* self, GFile* value);
};

struct _GXmlNodeIface {
	GTypeInterface parent_iface;
	GXmlNode* (*get) (GXmlNode* self, const gchar* key);
	GXmlElementList* (*get_elements_by_property_value) (GXmlNode* self, const gchar* property, const gchar* value);
	gchar* (*to_string) (GXmlNode* self);
	gboolean (*set_namespace) (GXmlNode* self, const gchar* uri, const gchar* prefix);
	gchar* (*ns_prefix) (GXmlNode* self);
	gchar* (*ns_uri) (GXmlNode* self);
	GeeList* (*get_namespaces) (GXmlNode* self);
	GeeBidirList* (*get_childs) (GXmlNode* self);
	GeeBidirList* (*get_children) (GXmlNode* self);
	GeeMap* (*get_attrs) (GXmlNode* self);
	gchar* (*get_name) (GXmlNode* self);
	gchar* (*get_value) (GXmlNode* self);
	void (*set_value) (GXmlNode* self, const gchar* value);
	GXmlNodeType (*get_type_node) (GXmlNode* self);
	GXmlDocument* (*get_document) (GXmlNode* self);
	GXmlNode* (*get_parent) (GXmlNode* self);
};

struct _GXmlxNodeListIface {
	GTypeInterface parent_iface;
	GXmlxNode* (*item) (GXmlxNodeList* self, gulong idx);
	GXmlxNode* (*insert_before) (GXmlxNodeList* self, GXmlxNode* new_child, GXmlxNode* ref_child);
	GXmlxNode* (*replace_child) (GXmlxNodeList* self, GXmlxNode* new_child, GXmlxNode* old_child);
	GXmlxNode* (*remove_child) (GXmlxNodeList* self, GXmlxNode* old_child);
	GXmlxNode* (*append_child) (GXmlxNodeList* self, GXmlxNode* new_child);
	gchar* (*to_string) (GXmlxNodeList* self, gboolean in_line);
	GXmlxNode* (*first) (GXmlxNodeList* self);
	GXmlxNode* (*last) (GXmlxNodeList* self);
	GXmlxNode* (*get) (GXmlxNodeList* self, gint n);
	gulong (*get_length) (GXmlxNodeList* self);
	void (*set_length) (GXmlxNodeList* self, gulong value);
};

struct _GXmlxNode {
	GObject parent_instance;
	GXmlxNodePrivate * priv;
	GXmlxNodeList* _child_nodes;
	GXmlNamedAttrMap* _attributes;
	GXmlNamespaceAttrNodeList* _namespace_definitions;
};

struct _GXmlxNodeClass {
	GObjectClass parent_class;
	GXmlNamespaceAttr* (*add_namespace_attr) (GXmlxNode* self, const gchar* uri, const gchar* namespace_prefix);
	gboolean (*set_namespace) (GXmlxNode* self, const gchar* uri, const gchar* namespace_prefix);
	GXmlxNode* (*insert_before) (GXmlxNode* self, GXmlxNode* new_child, GXmlxNode* ref_child);
	GXmlxNode* (*replace_child) (GXmlxNode* self, GXmlxNode* new_child, GXmlxNode* old_child);
	GXmlxNode* (*remove_child) (GXmlxNode* self, GXmlxNode* old_child);
	GXmlxNode* (*append_child) (GXmlxNode* self, GXmlxNode* new_child);
	gboolean (*has_child_nodes) (GXmlxNode* self);
	GXmlxNode* (*clone_node) (GXmlxNode* self, gboolean deep);
	gchar* (*stringify) (GXmlxNode* self, gboolean format, gint level);
	gchar* (*to_string) (GXmlxNode* self);
	GeeList* (*get_namespace_definitions) (GXmlxNode* self);
	void (*set_namespace_definitions) (GXmlxNode* self, GeeList* value);
	const gchar* (*get_namespace_uri) (GXmlxNode* self);
	void (*set_namespace_uri) (GXmlxNode* self, const gchar* value);
	const gchar* (*get_namespace_prefix) (GXmlxNode* self);
	void (*set_namespace_prefix) (GXmlxNode* self, const gchar* value);
	const gchar* (*get_local_name) (GXmlxNode* self);
	void (*set_local_name) (GXmlxNode* self, const gchar* value);
	const gchar* (*get_node_name) (GXmlxNode* self);
	void (*set_node_name) (GXmlxNode* self, const gchar* value);
	const gchar* (*get_node_value) (GXmlxNode* self);
	void (*set_node_value) (GXmlxNode* self, const gchar* value);
	GXmlNodeType (*get_node_type) (GXmlxNode* self);
	void (*set_node_type) (GXmlxNode* self, GXmlNodeType value);
	GXmlxNode* (*get_parent_node) (GXmlxNode* self);
	void (*set_parent_node) (GXmlxNode* self, GXmlxNode* value);
	GXmlxNodeList* (*get_child_nodes) (GXmlxNode* self);
	void (*set_child_nodes) (GXmlxNode* self, GXmlxNodeList* value);
	GXmlxNode* (*get_first_child) (GXmlxNode* self);
	void (*set_first_child) (GXmlxNode* self, GXmlxNode* value);
	GXmlxNode* (*get_last_child) (GXmlxNode* self);
	void (*set_last_child) (GXmlxNode* self, GXmlxNode* value);
	GXmlxNode* (*get_previous_sibling) (GXmlxNode* self);
	void (*set_previous_sibling) (GXmlxNode* self, GXmlxNode* value);
	GXmlxNode* (*get_next_sibling) (GXmlxNode* self);
	void (*set_next_sibling) (GXmlxNode* self, GXmlxNode* value);
	GXmlNamedAttrMap* (*get_attributes) (GXmlxNode* self);
	void (*set_attributes) (GXmlxNode* self, GXmlNamedAttrMap* value);
	GeeList* (*get_namespaces) (GXmlxNode* self);
	GeeBidirList* (*get_children) (GXmlxNode* self);
	GeeMap* (*get_attrs) (GXmlxNode* self);
	gchar* (*get_name) (GXmlxNode* self);
	gchar* (*get_value) (GXmlxNode* self);
	void (*set_value) (GXmlxNode* self, const gchar* value);
	GXmlNode* (*get_parent) (GXmlxNode* self);
};

struct _GXmlxDocument {
	GXmlxNode parent_instance;
	GXmlxDocumentPrivate * priv;
	GHashTable* node_dict;
	GList* dirty_elements;
	xmlDoc* xmldoc;
	GXmlNodeChildNodeList* _node_list;
};

struct _GXmlxDocumentClass {
	GXmlxNodeClass parent_class;
	GXmlNode* (*get_root) (GXmlxDocument* self);
};

struct _GXmlxDocumentPrivate {
	GXmlxDocumentType* _doctype;
	GXmlImplementation* _implementation;
	GList* nodes_to_free;
	GList* new_nodes;
	gboolean _indent;
	gboolean _ns_top;
	gboolean _prefix_default_ns;
	gboolean _backup;
	GFile* _file;
};

typedef enum  {
	GXML_DOM_EXCEPTION_NONE,
	GXML_DOM_EXCEPTION_INDEX_SIZE,
	GXML_DOM_EXCEPTION_DOMSTRING_SIZE,
	GXML_DOM_EXCEPTION_HIERARCHY_REQUEST,
	GXML_DOM_EXCEPTION_WRONG_DOCUMENT,
	GXML_DOM_EXCEPTION_INVALID_CHARACTER,
	GXML_DOM_EXCEPTION_NO_DATA_ALLOWED,
	GXML_DOM_EXCEPTION_NO_MODIFICATION_ALLOWED,
	GXML_DOM_EXCEPTION_NOT_FOUND,
	GXML_DOM_EXCEPTION_NOT_SUPPORTED,
	GXML_DOM_EXCEPTION_INUSE_ATTRIBUTE,
	GXML_DOM_EXCEPTION_DOM,
	GXML_DOM_EXCEPTION_INVALID_DOC,
	GXML_DOM_EXCEPTION_INVALID_ROOT,
	GXML_DOM_EXCEPTION_NAMESPACE,
	GXML_DOM_EXCEPTION_X_OTHER
} GXmlDomException;

typedef enum  {
	GXML_ERROR_NOT_SUPPORTED,
	GXML_ERROR_PARSER,
	GXML_ERROR_WRITER
} GXmlError;
#define GXML_ERROR gxml_error_quark ()
struct _GXmlBackedNode {
	GXmlxNode parent_instance;
	GXmlBackedNodePrivate * priv;
	xmlNode* node;
};

struct _GXmlBackedNodeClass {
	GXmlxNodeClass parent_class;
};


static gpointer gxml_xdocument_parent_class = NULL;
static GXmlDocumentIface* gxml_xdocument_gxml_document_parent_iface = NULL;

GType gxml_element_list_get_type (void) G_GNUC_CONST;
GType gxml_namespace_get_type (void) G_GNUC_CONST;
GType gxml_node_type_get_type (void) G_GNUC_CONST;
GType gxml_document_get_type (void) G_GNUC_CONST;
GType gxml_node_get_type (void) G_GNUC_CONST;
GType gxml_xnode_get_type (void) G_GNUC_CONST;
GType gxml_namespace_attr_get_type (void) G_GNUC_CONST;
GType gxml_xnode_list_get_type (void) G_GNUC_CONST;
GType gxml_abstract_named_attr_map_get_type (void) G_GNUC_CONST;
GType gxml_named_attr_map_get_type (void) G_GNUC_CONST;
GType gxml_abstract_namespace_attr_node_list_get_type (void) G_GNUC_CONST;
GType gxml_namespace_attr_node_list_get_type (void) G_GNUC_CONST;
GType gxml_xdocument_get_type (void) G_GNUC_CONST;
GType gxml_backed_node_get_type (void) G_GNUC_CONST;
GType gxml_xelement_get_type (void) G_GNUC_CONST;
GType gxml_child_node_list_get_type (void) G_GNUC_CONST;
GType gxml_node_child_node_list_get_type (void) G_GNUC_CONST;
GType gxml_xdocument_type_get_type (void) G_GNUC_CONST;
GType gxml_implementation_get_type (void) G_GNUC_CONST;
#define GXML_XDOCUMENT_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GXML_TYPE_XDOCUMENT, GXmlxDocumentPrivate))
enum  {
	GXML_XDOCUMENT_DUMMY_PROPERTY,
	GXML_XDOCUMENT_NODE_NAME,
	GXML_XDOCUMENT_DOCTYPE,
	GXML_XDOCUMENT_IMPLEMENTATION,
	GXML_XDOCUMENT_DOCUMENT_ELEMENT,
	GXML_XDOCUMENT_CHILD_NODES,
	GXML_XDOCUMENT_INDENT,
	GXML_XDOCUMENT_NS_TOP,
	GXML_XDOCUMENT_PREFIX_DEFAULT_NS,
	GXML_XDOCUMENT_BACKUP,
	GXML_XDOCUMENT_FILE,
	GXML_XDOCUMENT_ROOT
};
static void _g_object_unref0_ (gpointer var);
static void _g_list_free__g_object_unref0_ (GList* self);
GType gxml_xattr_get_type (void) G_GNUC_CONST;
GXmlxAttr* gxml_xdocument_lookup_attr (GXmlxDocument* self, xmlAttr* xmlattr);
GXmlxNode* gxml_xdocument_lookup_node (GXmlxDocument* self, xmlNode* xmlnode);
GXmlxElement* gxml_xelement_new (xmlNode* node, GXmlxDocument* doc);
GXmlxElement* gxml_xelement_construct (GType object_type, xmlNode* node, GXmlxDocument* doc);
GXmlxText* gxml_xtext_new (xmlNode* text_node, GXmlxDocument* doc);
GXmlxText* gxml_xtext_construct (GType object_type, xmlNode* text_node, GXmlxDocument* doc);
GType gxml_xcharacter_data_get_type (void) G_GNUC_CONST;
GType gxml_xtext_get_type (void) G_GNUC_CONST;
GXmlxCDATASection* gxml_xcdata_section_new (xmlNode* cdata_node, GXmlxDocument* doc);
GXmlxCDATASection* gxml_xcdata_section_construct (GType object_type, xmlNode* cdata_node, GXmlxDocument* doc);
GType gxml_xcdata_section_get_type (void) G_GNUC_CONST;
GXmlxComment* gxml_xcomment_new (xmlNode* comment_node, GXmlxDocument* doc);
GXmlxComment* gxml_xcomment_construct (GType object_type, xmlNode* comment_node, GXmlxDocument* doc);
GType gxml_xcomment_get_type (void) G_GNUC_CONST;
GXmlDocumentFragment* gxml_document_fragment_new (xmlNode* fragment_node, GXmlxDocument* doc);
GXmlDocumentFragment* gxml_document_fragment_construct (GType object_type, xmlNode* fragment_node, GXmlxDocument* doc);
GType gxml_document_fragment_get_type (void) G_GNUC_CONST;
GXmlxAttr* gxml_xattr_new (xmlAttr* node, GXmlxDocument* doc);
GXmlxAttr* gxml_xattr_construct (GType object_type, xmlAttr* node, GXmlxDocument* doc);
const gchar* gxml_node_type_to_string (GXmlNodeType self);
GXmlxDocument* gxml_xdocument_new_with_implementation (GXmlImplementation* impl, const gchar* namespace_uri, const gchar* qualified_name, GXmlxDocumentType* doctype);
GXmlxDocument* gxml_xdocument_construct_with_implementation (GType object_type, GXmlImplementation* impl, const gchar* namespace_uri, const gchar* qualified_name, GXmlxDocumentType* doctype);
GXmlxDocument* gxml_xdocument_new (void);
GXmlxDocument* gxml_xdocument_construct (GType object_type);
static void gxml_xdocument_set_implementation (GXmlxDocument* self, GXmlImplementation* value);
GXmlNode* gxml_document_create_element (GXmlDocument* self, const gchar* name, GError** error);
GXmlxNode* gxml_xnode_append_child (GXmlxNode* self, GXmlxNode* new_child);
void gxml_xnode_set_namespace_uri (GXmlxNode* self, const gchar* value);
static void gxml_xdocument_set_doctype (GXmlxDocument* self, GXmlxDocumentType* value);
GXmlxDocument* gxml_xdocument_new_from_libxml2 (xmlDoc* doc, gboolean require_root);
GXmlxDocument* gxml_xdocument_construct_from_libxml2 (GType object_type, xmlDoc* doc, gboolean require_root);
GType gxml_dom_exception_get_type (void) G_GNUC_CONST;
void gxml_exception (GXmlDomException ex, const gchar* message);
GXmlxNode* gxml_xnode_construct_for_document (GType object_type);
void gxml_xnode_set_owner_document (GXmlxNode* self, GXmlxDocument* value);
GXmlxDocumentType* gxml_xdocument_type_new (xmlDtd* int_subset, xmlDtd* ext_subset, GXmlxDocument* doc);
GXmlxDocumentType* gxml_xdocument_type_construct (GType object_type, xmlDtd* int_subset, xmlDtd* ext_subset, GXmlxDocument* doc);
GXmlImplementation* gxml_implementation_new (void);
GXmlImplementation* gxml_implementation_construct (GType object_type);
GXmlxDocument* gxml_xnode_get_owner_document (GXmlxNode* self);
GXmlNodeChildNodeList* gxml_node_child_node_list_new (xmlNode* parent, GXmlxDocument* owner);
GXmlNodeChildNodeList* gxml_node_child_node_list_construct (GType object_type, xmlNode* parent, GXmlxDocument* owner);
GQuark gxml_error_quark (void);
GXmlxDocument* gxml_xdocument_new_from_path (const gchar* file_path, GError** error);
GXmlxDocument* gxml_xdocument_construct_from_path (GType object_type, const gchar* file_path, GError** error);
gchar* gxml_libxml2_error_to_string (xmlError* e);
GXmlxDocument* gxml_xdocument_new_from_gfile (GFile* fin, GCancellable* can, GError** error);
GXmlxDocument* gxml_xdocument_construct_from_gfile (GType object_type, GFile* fin, GCancellable* can, GError** error);
GXmlxDocument* gxml_xdocument_new_from_stream (GInputStream* instream, GCancellable* can, GError** error);
GXmlxDocument* gxml_xdocument_construct_from_stream (GType object_type, GInputStream* instream, GCancellable* can, GError** error);
GXmlxDocument* gxml_xdocument_new_from_string (const gchar* xml);
GXmlxDocument* gxml_xdocument_construct_from_string (GType object_type, const gchar* xml);
GXmlxDocument* gxml_xdocument_new_from_string_with_options (const gchar* xml, const gchar* url, const gchar* encoding, gint options, GError** error);
GXmlxDocument* gxml_xdocument_construct_from_string_with_options (GType object_type, const gchar* xml, const gchar* url, const gchar* encoding, gint options, GError** error);
void gxml_xdocument_save_to_path (GXmlxDocument* self, const gchar* file_path, GError** error);
void gxml_xdocument_save_to_stream (GXmlxDocument* self, GOutputStream* outstream, GCancellable* can, GError** error);
gchar* gxml_xnode_to_string (GXmlxNode* self);
static guint8* _vala_array_dup1 (guint8* self, int length);
static GXmlNode* gxml_xdocument_real_create_element (GXmlDocument* base, const gchar* tag_name, GError** error);
gboolean gxml_xdocument_check_invalid_characters (const gchar* name, const gchar* subject);
GXmlDocumentFragment* gxml_xdocument_create_document_fragment (GXmlxDocument* self);
GXmlxText* gxml_xdocument_create_text_node (GXmlxDocument* self, const gchar* text_data);
GXmlxComment* gxml_xdocument_create_managed_comment (GXmlxDocument* self, const gchar* comment_data);
GXmlxCDATASection* gxml_xdocument_create_cdata_section (GXmlxDocument* self, const gchar* cdata_data);
static void gxml_xdocument_check_not_supported_html (GXmlxDocument* self, const gchar* feature);
GType gxml_xprocessing_instruction_get_type (void) G_GNUC_CONST;
GXmlxProcessingInstruction* gxml_xdocument_create_processing_instruction (GXmlxDocument* self, const gchar* target, const gchar* data);
GXmlxProcessingInstruction* gxml_xprocessing_instruction_new (const gchar* target, const gchar* data, GXmlxDocument* doc);
GXmlxProcessingInstruction* gxml_xprocessing_instruction_construct (GType object_type, const gchar* target, const gchar* data, GXmlxDocument* doc);
GXmlxAttr* gxml_xdocument_create_attribute (GXmlxDocument* self, const gchar* name);
GType gxml_entity_reference_get_type (void) G_GNUC_CONST;
GXmlEntityReference* gxml_xdocument_create_entity_reference (GXmlxDocument* self, const gchar* name);
GXmlEntityReference* gxml_entity_reference_new (const gchar* refname, GXmlxDocument* doc);
GXmlEntityReference* gxml_entity_reference_construct (GType object_type, const gchar* refname, GXmlxDocument* doc);
GXmlxNodeList* gxml_xdocument_get_elements_by_tag_name (GXmlxDocument* self, const gchar* tag_name);
GXmlxElement* gxml_xdocument_get_document_element (GXmlxDocument* self);
GXmlxNodeList* gxml_xelement_get_elements_by_tag_name (GXmlxElement* self, const gchar* tag_name);
GXmlxDocumentType* gxml_xdocument_get_doctype (GXmlxDocument* self);
gchar* gxml_xnode_get_name (GXmlxNode* self);
static gchar* gxml_xdocument_real_stringify (GXmlxNode* base, gboolean format, gint level);
static GXmlxNode* gxml_xdocument_real_replace_child (GXmlxNode* base, GXmlxNode* new_child, GXmlxNode* old_child);
GXmlNodeType gxml_xnode_get_node_type (GXmlxNode* self);
GXmlxNode* gxml_xnode_replace_child (GXmlxNode* self, GXmlxNode* new_child, GXmlxNode* old_child);
static GXmlxNode* gxml_xdocument_real_remove_child (GXmlxNode* base, GXmlxNode* old_child);
GXmlxNodeList* gxml_xnode_get_child_nodes (GXmlxNode* self);
GXmlxNode* gxml_xnode_list_remove_child (GXmlxNodeList* self, GXmlxNode* old_child);
static GXmlxNode* gxml_xdocument_real_insert_before (GXmlxNode* base, GXmlxNode* new_child, GXmlxNode* ref_child);
GXmlxNode* gxml_xnode_list_insert_before (GXmlxNodeList* self, GXmlxNode* new_child, GXmlxNode* ref_child);
static GXmlxNode* gxml_xdocument_real_append_child (GXmlxNode* base, GXmlxNode* new_child);
void gxml_xnode_check_wrong_document (GXmlxNode* self, GXmlxNode* node);
gboolean gxml_xnode_check_read_only (GXmlxNode* self);
const gchar* gxml_xnode_get_node_name (GXmlxNode* self);
GXmlxNode* gxml_xnode_list_append_child (GXmlxNodeList* self, GXmlxNode* new_child);
static gboolean gxml_xdocument_real_has_child_nodes (GXmlxNode* base);
GXmlxNode* gxml_xdocument_copy_node (GXmlxDocument* self, GXmlxNode* foreign_node, gboolean deep);
static GXmlNode* gxml_xdocument_real_create_text (GXmlDocument* base, const gchar* str);
static GXmlNode* gxml_xdocument_real_create_comment (GXmlDocument* base, const gchar* text);
static GXmlNode* gxml_xdocument_real_create_cdata (GXmlDocument* base, const gchar* text);
static GXmlNode* gxml_xdocument_real_create_pi (GXmlDocument* base, const gchar* target, const gchar* data);
static gboolean gxml_xdocument_real_save (GXmlDocument* base, GCancellable* cancellable, GError** error);
GFile* gxml_document_get_file (GXmlDocument* self);
gboolean gxml_document_save_as (GXmlDocument* self, GFile* f, GCancellable* cancellable, GError** error);
static gboolean gxml_xdocument_real_save_as (GXmlDocument* base, GFile* f, GCancellable* cancellable, GError** error);
gboolean gxml_document_get_backup (GXmlDocument* self);
GXmlImplementation* gxml_xdocument_get_implementation (GXmlxDocument* self);
static void gxml_xdocument_set_document_element (GXmlxDocument* self, GXmlxElement* value);
GXmlNode* gxml_xdocument_get_root (GXmlxDocument* self);
static void gxml_xdocument_finalize (GObject* obj);
gboolean gxml_document_get_indent (GXmlDocument* self);
gboolean gxml_document_get_ns_top (GXmlDocument* self);
gboolean gxml_document_get_prefix_default_ns (GXmlDocument* self);
static void _vala_gxml_xdocument_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec);
void gxml_xnode_set_node_name (GXmlxNode* self, const gchar* value);
void gxml_xnode_set_child_nodes (GXmlxNode* self, GXmlxNodeList* value);
void gxml_document_set_indent (GXmlDocument* self, gboolean value);
void gxml_document_set_ns_top (GXmlDocument* self, gboolean value);
void gxml_document_set_prefix_default_ns (GXmlDocument* self, gboolean value);
void gxml_document_set_backup (GXmlDocument* self, gboolean value);
void gxml_document_set_file (GXmlDocument* self, GFile* value);
static void _vala_gxml_xdocument_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec);


static void _g_object_unref0_ (gpointer var) {
	(var == NULL) ? NULL : (var = (g_object_unref (var), NULL));
}


static void _g_list_free__g_object_unref0_ (GList* self) {
	g_list_foreach (self, (GFunc) _g_object_unref0_, NULL);
	g_list_free (self);
}


GXmlxAttr* gxml_xdocument_lookup_attr (GXmlxDocument* self, xmlAttr* xmlattr) {
	GXmlxAttr* result = NULL;
	xmlAttr* _tmp0_ = NULL;
	GXmlxNode* _tmp1_ = NULL;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = xmlattr;
	_tmp1_ = gxml_xdocument_lookup_node (self, (xmlNode*) _tmp0_);
	result = G_TYPE_CHECK_INSTANCE_CAST (_tmp1_, GXML_TYPE_XATTR, GXmlxAttr);
	return result;
}


GXmlxNode* gxml_xdocument_lookup_node (GXmlxDocument* self, xmlNode* xmlnode) {
	GXmlxNode* result = NULL;
	GXmlxNode* domnode = NULL;
	xmlNode* _tmp0_ = NULL;
	GHashTable* _tmp1_ = NULL;
	xmlNode* _tmp2_ = NULL;
	gconstpointer _tmp3_ = NULL;
	GXmlxNode* _tmp4_ = NULL;
	GXmlxNode* _tmp32_ = NULL;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = xmlnode;
	if (_tmp0_ == NULL) {
		result = NULL;
		return result;
	}
	_tmp1_ = self->node_dict;
	_tmp2_ = xmlnode;
	_tmp3_ = g_hash_table_lookup (_tmp1_, _tmp2_);
	domnode = (GXmlxNode*) _tmp3_;
	_tmp4_ = domnode;
	if (_tmp4_ == NULL) {
		GXmlNodeType nodetype = 0;
		xmlNode* _tmp5_ = NULL;
		xmlElementType _tmp6_ = 0;
		GXmlNodeType _tmp7_ = 0;
		GHashTable* _tmp29_ = NULL;
		xmlNode* _tmp30_ = NULL;
		gconstpointer _tmp31_ = NULL;
		_tmp5_ = xmlnode;
		_tmp6_ = _tmp5_->type;
		nodetype = (GXmlNodeType) _tmp6_;
		_tmp7_ = nodetype;
		switch (_tmp7_) {
			case GXML_NODE_TYPE_ELEMENT:
			{
				xmlNode* _tmp8_ = NULL;
				GXmlxElement* _tmp9_ = NULL;
				GXmlxElement* _tmp10_ = NULL;
				_tmp8_ = xmlnode;
				_tmp9_ = gxml_xelement_new (_tmp8_, self);
				_tmp10_ = _tmp9_;
				_g_object_unref0 (_tmp10_);
				break;
			}
			case GXML_NODE_TYPE_TEXT:
			{
				xmlNode* _tmp11_ = NULL;
				GXmlxText* _tmp12_ = NULL;
				GXmlxText* _tmp13_ = NULL;
				_tmp11_ = xmlnode;
				_tmp12_ = gxml_xtext_new (_tmp11_, self);
				_tmp13_ = _tmp12_;
				_g_object_unref0 (_tmp13_);
				break;
			}
			case GXML_NODE_TYPE_CDATA_SECTION:
			{
				xmlNode* _tmp14_ = NULL;
				GXmlxCDATASection* _tmp15_ = NULL;
				GXmlxCDATASection* _tmp16_ = NULL;
				_tmp14_ = xmlnode;
				_tmp15_ = gxml_xcdata_section_new (_tmp14_, self);
				_tmp16_ = _tmp15_;
				_g_object_unref0 (_tmp16_);
				break;
			}
			case GXML_NODE_TYPE_COMMENT:
			{
				xmlNode* _tmp17_ = NULL;
				GXmlxComment* _tmp18_ = NULL;
				GXmlxComment* _tmp19_ = NULL;
				_tmp17_ = xmlnode;
				_tmp18_ = gxml_xcomment_new (_tmp17_, self);
				_tmp19_ = _tmp18_;
				_g_object_unref0 (_tmp19_);
				break;
			}
			case GXML_NODE_TYPE_DOCUMENT_FRAGMENT:
			{
				xmlNode* _tmp20_ = NULL;
				GXmlDocumentFragment* _tmp21_ = NULL;
				GXmlDocumentFragment* _tmp22_ = NULL;
				_tmp20_ = xmlnode;
				_tmp21_ = gxml_document_fragment_new (_tmp20_, self);
				_tmp22_ = _tmp21_;
				_g_object_unref0 (_tmp22_);
				break;
			}
			case GXML_NODE_TYPE_ATTRIBUTE:
			{
				xmlNode* _tmp23_ = NULL;
				GXmlxAttr* _tmp24_ = NULL;
				GXmlxAttr* _tmp25_ = NULL;
				_tmp23_ = xmlnode;
				_tmp24_ = gxml_xattr_new ((xmlAttr*) _tmp23_, self);
				_tmp25_ = _tmp24_;
				_g_object_unref0 (_tmp25_);
				break;
			}
			case GXML_NODE_TYPE_ENTITY_REFERENCE:
			case GXML_NODE_TYPE_ENTITY:
			case GXML_NODE_TYPE_PROCESSING_INSTRUCTION:
			case GXML_NODE_TYPE_DOCUMENT_TYPE:
			case GXML_NODE_TYPE_NOTATION:
			case GXML_NODE_TYPE_DOCUMENT:
			{
				const gchar* _tmp26_ = NULL;
				GXmlNodeType _tmp27_ = 0;
				GEnumValue* _tmp28_;
				_tmp26_ = _ ("Looking up %s from an xmlNode* is not supported");
				_tmp27_ = nodetype;
				_tmp28_ = g_enum_get_value (g_type_class_ref (GXML_TYPE_NODE_TYPE), _tmp27_);
				g_warning (_tmp26_, (_tmp28_ != NULL) ? _tmp28_->value_name : NULL);
				break;
			}
			default:
			break;
		}
		_tmp29_ = self->node_dict;
		_tmp30_ = xmlnode;
		_tmp31_ = g_hash_table_lookup (_tmp29_, _tmp30_);
		domnode = (GXmlxNode*) _tmp31_;
	}
	_tmp32_ = domnode;
	result = _tmp32_;
	return result;
}


/**
 * Creates a xDocument from a given Implementation, supporting
 * the {@ GXml.Implementation.create_document} method.
 *
 * 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 xDocument
 * @param namespace_uri URI for the namespace in which this xDocument belongs, or %NULL
 * @param qualified_name A qualified name for the xDocument, or %NULL
 * @param doctype The type of the document, or %NULL
 *
 * @return The new document; this must be freed with {@link GLib.Object.unref}
 */
GXmlxDocument* gxml_xdocument_construct_with_implementation (GType object_type, GXmlImplementation* impl, const gchar* namespace_uri, const gchar* qualified_name, GXmlxDocumentType* doctype) {
	GXmlxDocument * self = NULL;
	GXmlImplementation* _tmp0_ = NULL;
	GXmlxNode* root = NULL;
	GXmlNode* _tmp1_ = NULL;
	const gchar* _tmp2_ = NULL;
	GXmlNode* _tmp3_ = NULL;
	GXmlNode* _tmp4_ = NULL;
	GXmlxNode* _tmp5_ = NULL;
	const gchar* _tmp6_ = NULL;
	GXmlxDocumentType* _tmp7_ = NULL;
	GError * _inner_error_ = NULL;
	g_return_val_if_fail (impl != NULL, NULL);
	self = (GXmlxDocument*) gxml_xdocument_construct (object_type);
	_tmp0_ = impl;
	gxml_xdocument_set_implementation (self, _tmp0_);
	_tmp2_ = qualified_name;
	_tmp3_ = gxml_document_create_element ((GXmlDocument*) self, _tmp2_, &_inner_error_);
	_tmp1_ = _tmp3_;
	if (G_UNLIKELY (_inner_error_ != NULL)) {
		_g_object_unref0 (root);
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
		g_clear_error (&_inner_error_);
		return NULL;
	}
	_tmp4_ = _tmp1_;
	_tmp1_ = NULL;
	_g_object_unref0 (root);
	root = G_TYPE_CHECK_INSTANCE_CAST (_tmp4_, GXML_TYPE_XNODE, GXmlxNode);
	_tmp5_ = root;
	gxml_xnode_append_child ((GXmlxNode*) self, _tmp5_);
	_tmp6_ = namespace_uri;
	gxml_xnode_set_namespace_uri ((GXmlxNode*) self, _tmp6_);
	_tmp7_ = doctype;
	gxml_xdocument_set_doctype (self, _tmp7_);
	_g_object_unref0 (_tmp1_);
	_g_object_unref0 (root);
	return self;
}


GXmlxDocument* gxml_xdocument_new_with_implementation (GXmlImplementation* impl, const gchar* namespace_uri, const gchar* qualified_name, GXmlxDocumentType* doctype) {
	return gxml_xdocument_construct_with_implementation (GXML_TYPE_XDOCUMENT, impl, namespace_uri, qualified_name, doctype);
}


/**
 * Creates a xDocument 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.xDocument} wrapping the provided {@link Xml.Doc}; this must be freed with {@link GLib.Object.unref}
 */
GXmlxDocument* gxml_xdocument_construct_from_libxml2 (GType object_type, xmlDoc* doc, gboolean require_root) {
	GXmlxDocument * self = NULL;
	xmlNode* root = NULL;
	xmlDoc* _tmp0_ = NULL;
	gboolean _tmp1_ = FALSE;
	xmlDoc* _tmp5_ = NULL;
	gboolean _tmp6_ = FALSE;
	xmlDoc* _tmp7_ = NULL;
	xmlDtd* _tmp8_ = NULL;
	GXmlImplementation* _tmp17_ = NULL;
	GXmlImplementation* _tmp18_ = NULL;
	xmlDoc* _tmp19_ = NULL;
	GXmlxDocument* _tmp20_ = NULL;
	GXmlxDocument* _tmp21_ = NULL;
	GXmlNodeChildNodeList* _tmp22_ = NULL;
	_tmp0_ = doc;
	if (_tmp0_ == NULL) {
		gxml_exception (GXML_DOM_EXCEPTION_INVALID_DOC, "Failed to parse document, xmlDoc* was NULL");
	}
	_tmp1_ = require_root;
	if (_tmp1_) {
		xmlDoc* _tmp2_ = NULL;
		xmlNode* _tmp3_ = NULL;
		xmlNode* _tmp4_ = NULL;
		_tmp2_ = doc;
		_tmp3_ = xmlDocGetRootElement (_tmp2_);
		root = _tmp3_;
		_tmp4_ = root;
		if (_tmp4_ == NULL) {
			gxml_exception (GXML_DOM_EXCEPTION_INVALID_ROOT, "Could not obtain a valid root for the document; xmlDoc*'s root was NUL" \
"L");
		}
	}
	self = (GXmlxDocument*) gxml_xnode_construct_for_document (object_type);
	gxml_xnode_set_owner_document ((GXmlxNode*) self, self);
	_tmp5_ = doc;
	self->xmldoc = _tmp5_;
	_tmp7_ = doc;
	_tmp8_ = _tmp7_->intSubset;
	if (_tmp8_ == NULL) {
		xmlDoc* _tmp9_ = NULL;
		xmlDtd* _tmp10_ = NULL;
		_tmp9_ = doc;
		_tmp10_ = _tmp9_->extSubset;
		_tmp6_ = _tmp10_ == NULL;
	} else {
		_tmp6_ = FALSE;
	}
	if (_tmp6_) {
		gxml_xdocument_set_doctype (self, NULL);
	} else {
		xmlDoc* _tmp11_ = NULL;
		xmlDtd* _tmp12_ = NULL;
		xmlDoc* _tmp13_ = NULL;
		xmlDtd* _tmp14_ = NULL;
		GXmlxDocumentType* _tmp15_ = NULL;
		GXmlxDocumentType* _tmp16_ = NULL;
		_tmp11_ = doc;
		_tmp12_ = _tmp11_->intSubset;
		_tmp13_ = doc;
		_tmp14_ = _tmp13_->extSubset;
		_tmp15_ = gxml_xdocument_type_new (_tmp12_, _tmp14_, self);
		_tmp16_ = _tmp15_;
		gxml_xdocument_set_doctype (self, _tmp16_);
		_g_object_unref0 (_tmp16_);
	}
	_tmp17_ = gxml_implementation_new ();
	_tmp18_ = _tmp17_;
	gxml_xdocument_set_implementation (self, _tmp18_);
	_g_object_unref0 (_tmp18_);
	_tmp19_ = self->xmldoc;
	_tmp20_ = gxml_xnode_get_owner_document ((GXmlxNode*) self);
	_tmp21_ = _tmp20_;
	_tmp22_ = gxml_node_child_node_list_new ((xmlNode*) _tmp19_, _tmp21_);
	_g_object_unref0 (self->_node_list);
	self->_node_list = _tmp22_;
	return self;
}


GXmlxDocument* gxml_xdocument_new_from_libxml2 (xmlDoc* doc, gboolean require_root) {
	return gxml_xdocument_construct_from_libxml2 (GXML_TYPE_XDOCUMENT, doc, require_root);
}


/**
 * Creates a xDocument from the file at file_path.
 *
 * @param file_path A path to an XML document
 *
 * @return A {@link GXml.xDocument} 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
 */
GXmlxDocument* gxml_xdocument_construct_from_path (GType object_type, const gchar* file_path, GError** error) {
	GXmlxDocument * self = NULL;
	xmlParserCtxt* ctxt = NULL;
	xmlDoc* doc = NULL;
	xmlError* e = NULL;
	xmlParserCtxt* _tmp0_ = NULL;
	xmlParserCtxt* _tmp1_ = NULL;
	xmlParserCtxt* _tmp2_ = NULL;
	const gchar* _tmp3_ = NULL;
	xmlDoc* _tmp4_ = NULL;
	xmlDoc* _tmp5_ = NULL;
	xmlDoc* _tmp18_ = NULL;
	GError * _inner_error_ = NULL;
	g_return_val_if_fail (file_path != NULL, NULL);
	_tmp0_ = xmlNewParserCtxt ();
	_xmlFreeParserCtxt0 (ctxt);
	ctxt = _tmp0_;
	_tmp1_ = ctxt;
	gxml_context_reset_last_error (_tmp1_);
	_tmp2_ = ctxt;
	_tmp3_ = file_path;
	_tmp4_ = xmlCtxtReadFile (_tmp2_, _tmp3_, NULL, 0);
	doc = _tmp4_;
	_tmp5_ = doc;
	if (_tmp5_ == NULL) {
		xmlParserCtxt* _tmp6_ = NULL;
		xmlError* _tmp7_ = NULL;
		const gchar* _tmp8_ = NULL;
		xmlError* _tmp9_ = NULL;
		const gchar* _tmp10_ = NULL;
		gchar* _tmp11_ = NULL;
		gchar* _tmp12_ = NULL;
		xmlError* _tmp13_ = NULL;
		gchar* _tmp14_ = NULL;
		gchar* _tmp15_ = NULL;
		GError* _tmp16_ = NULL;
		GError* _tmp17_ = NULL;
		_tmp6_ = ctxt;
		_tmp7_ = gxml_context_get_last_error (_tmp6_);
		e = _tmp7_;
		_tmp8_ = _ ("Could not load document from path: %s");
		_tmp9_ = e;
		_tmp10_ = (*_tmp9_).message;
		_tmp11_ = g_strdup_printf (_tmp8_, _tmp10_);
		_tmp12_ = _tmp11_;
		gxml_exception (GXML_DOM_EXCEPTION_INVALID_DOC, _tmp12_);
		_g_free0 (_tmp12_);
		_tmp13_ = e;
		_tmp14_ = gxml_libxml2_error_to_string (_tmp13_);
		_tmp15_ = _tmp14_;
		_tmp16_ = g_error_new_literal (GXML_ERROR, GXML_ERROR_PARSER, _tmp15_);
		_tmp17_ = _tmp16_;
		_g_free0 (_tmp15_);
		_inner_error_ = _tmp17_;
		if (_inner_error_->domain == GXML_ERROR) {
			g_propagate_error (error, _inner_error_);
			_xmlFreeParserCtxt0 (ctxt);
			_g_object_unref0 (self);
			return NULL;
		} else {
			_xmlFreeParserCtxt0 (ctxt);
			g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
			g_clear_error (&_inner_error_);
			return NULL;
		}
	}
	_tmp18_ = doc;
	self = (GXmlxDocument*) gxml_xdocument_construct_from_libxml2 (object_type, _tmp18_, TRUE);
	_xmlFreeParserCtxt0 (ctxt);
	return self;
}


GXmlxDocument* gxml_xdocument_new_from_path (const gchar* file_path, GError** error) {
	return gxml_xdocument_construct_from_path (GXML_TYPE_XDOCUMENT, file_path, error);
}


/**
 * Creates a xDocument 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.xDocument} 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
 */
static gpointer _g_error_copy0 (gpointer self) {
	return self ? g_error_copy (self) : NULL;
}


GXmlxDocument* gxml_xdocument_construct_from_gfile (GType object_type, GFile* fin, GCancellable* can, GError** error) {
	GXmlxDocument * self = NULL;
	GFile* _tmp0_ = NULL;
	gboolean _tmp1_ = FALSE;
	GInputStream* instream = NULL;
	GError * _inner_error_ = NULL;
	g_return_val_if_fail (fin != NULL, NULL);
	_tmp0_ = fin;
	_tmp1_ = g_file_query_exists (_tmp0_, NULL);
	_vala_return_val_if_fail (_tmp1_, "fin.query_exists ()", NULL);
	{
		GFileInputStream* _tmp2_ = NULL;
		GFile* _tmp3_ = NULL;
		GCancellable* _tmp4_ = NULL;
		GFileInputStream* _tmp5_ = NULL;
		GFileInputStream* _tmp6_ = NULL;
		GInputStream* _tmp7_ = NULL;
		GCancellable* _tmp8_ = NULL;
		GInputStream* _tmp9_ = NULL;
		_tmp3_ = fin;
		_tmp4_ = can;
		_tmp5_ = g_file_read (_tmp3_, _tmp4_, &_inner_error_);
		_tmp2_ = _tmp5_;
		if (G_UNLIKELY (_inner_error_ != NULL)) {
			goto __catch1_g_error;
		}
		_tmp6_ = _tmp2_;
		_tmp2_ = NULL;
		_g_object_unref0 (instream);
		instream = (GInputStream*) _tmp6_;
		_tmp7_ = instream;
		_tmp8_ = can;
		self = (GXmlxDocument*) gxml_xdocument_construct_from_stream (object_type, _tmp7_, _tmp8_, &_inner_error_);
		if (G_UNLIKELY (_inner_error_ != NULL)) {
			_g_object_unref0 (_tmp2_);
			goto __catch1_g_error;
		}
		_tmp9_ = instream;
		g_input_stream_close (_tmp9_, NULL, &_inner_error_);
		if (G_UNLIKELY (_inner_error_ != NULL)) {
			_g_object_unref0 (_tmp2_);
			goto __catch1_g_error;
		}
		_g_object_unref0 (_tmp2_);
	}
	goto __finally1;
	__catch1_g_error:
	{
		GError* e = NULL;
		GError* _tmp10_ = NULL;
		const gchar* _tmp11_ = NULL;
		gchar* _tmp12_ = NULL;
		gchar* _tmp13_ = NULL;
		GError* _tmp14_ = NULL;
		GError* _tmp15_ = NULL;
		e = _inner_error_;
		_inner_error_ = NULL;
		_tmp10_ = e;
		_tmp11_ = _tmp10_->message;
		_tmp12_ = g_strconcat ("Could not load document from GFile: ", _tmp11_, NULL);
		_tmp13_ = _tmp12_;
		gxml_exception (GXML_DOM_EXCEPTION_INVALID_DOC, _tmp13_);
		_g_free0 (_tmp13_);
		_tmp14_ = e;
		_tmp15_ = _g_error_copy0 (_tmp14_);
		_inner_error_ = _tmp15_;
		_g_error_free0 (e);
		goto __finally1;
	}
	__finally1:
	if (G_UNLIKELY (_inner_error_ != NULL)) {
		g_propagate_error (error, _inner_error_);
		_g_object_unref0 (instream);
		_g_object_unref0 (self);
		return NULL;
	}
	_g_object_unref0 (instream);
	return self;
}


GXmlxDocument* gxml_xdocument_new_from_gfile (GFile* fin, GCancellable* can, GError** error) {
	return gxml_xdocument_construct_from_gfile (GXML_TYPE_XDOCUMENT, fin, can, error);
}


/**
 * Creates a {@link GXml.xDocument} 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.xDocument} 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
 */
GXmlxDocument* gxml_xdocument_construct_from_stream (GType object_type, GInputStream* instream, GCancellable* can, GError** error) {
	GXmlxDocument * self = NULL;
	xmlError* e = NULL;
	gchar* errmsg = NULL;
	GMemoryOutputStream* ostream = NULL;
	GMemoryOutputStream* _tmp0_ = NULL;
	GMemoryOutputStream* _tmp1_ = NULL;
	GInputStream* _tmp2_ = NULL;
	GMemoryOutputStream* _tmp3_ = NULL;
	void* _tmp4_ = NULL;
	void* _tmp5_ = NULL;
	xmlDoc* doc = NULL;
	GMemoryOutputStream* _tmp10_ = NULL;
	void* _tmp11_ = NULL;
	void* _tmp12_ = NULL;
	GMemoryOutputStream* _tmp13_ = NULL;
	void* _tmp14_ = NULL;
	void* _tmp15_ = NULL;
	gint _tmp16_ = 0;
	gint _tmp17_ = 0;
	xmlDoc* _tmp18_ = NULL;
	xmlDoc* _tmp19_ = NULL;
	GError * _inner_error_ = NULL;
	g_return_val_if_fail (instream != NULL, NULL);
	e = NULL;
	errmsg = NULL;
	_tmp0_ = (GMemoryOutputStream*) g_memory_output_stream_new_resizable ();
	ostream = _tmp0_;
	_tmp1_ = ostream;
	_tmp2_ = instream;
	g_output_stream_splice ((GOutputStream*) _tmp1_, _tmp2_, G_OUTPUT_STREAM_SPLICE_NONE, NULL, &_inner_error_);
	if (G_UNLIKELY (_inner_error_ != NULL)) {
		g_propagate_error (error, _inner_error_);
		_g_object_unref0 (ostream);
		_g_free0 (errmsg);
		_g_object_unref0 (self);
		return NULL;
	}
	_tmp3_ = ostream;
	_tmp4_ = g_memory_output_stream_get_data (_tmp3_);
	_tmp5_ = _tmp4_;
	if (_tmp5_ == NULL) {
		gchar* _tmp6_ = NULL;
		const gchar* _tmp7_ = NULL;
		const gchar* _tmp8_ = NULL;
		GError* _tmp9_ = NULL;
		_tmp6_ = g_strdup ("Document is empty");
		_g_free0 (errmsg);
		errmsg = _tmp6_;
		_tmp7_ = errmsg;
		gxml_exception (GXML_DOM_EXCEPTION_INVALID_DOC, _tmp7_);
		_tmp8_ = errmsg;
		_tmp9_ = g_error_new_literal (GXML_ERROR, GXML_ERROR_PARSER, _tmp8_);
		_inner_error_ = _tmp9_;
		g_propagate_error (error, _inner_error_);
		_g_object_unref0 (ostream);
		_g_free0 (errmsg);
		_g_object_unref0 (self);
		return NULL;
	}
	gxml_reset_last_error ();
	_tmp10_ = ostream;
	_tmp11_ = g_memory_output_stream_get_data (_tmp10_);
	_tmp12_ = _tmp11_;
	_tmp13_ = ostream;
	_tmp14_ = g_memory_output_stream_get_data (_tmp13_);
	_tmp15_ = _tmp14_;
	_tmp16_ = strlen ((const gchar*) _tmp15_);
	_tmp17_ = _tmp16_;
	_tmp18_ = xmlParseMemory ((const gchar*) _tmp12_, _tmp17_);
	doc = _tmp18_;
	_tmp19_ = doc;
	if (_tmp19_ != NULL) {
		xmlDoc* _tmp20_ = NULL;
		_tmp20_ = doc;
		self = (GXmlxDocument*) gxml_xdocument_construct_from_libxml2 (object_type, _tmp20_, TRUE);
	} else {
		gchar* _tmp21_ = NULL;
		xmlError* _tmp22_ = NULL;
		xmlError* _tmp23_ = NULL;
		const gchar* _tmp30_ = NULL;
		const gchar* _tmp31_ = NULL;
		GError* _tmp32_ = NULL;
		_tmp21_ = g_strdup ("Parser Error");
		_g_free0 (errmsg);
		errmsg = _tmp21_;
		_tmp22_ = gxml_get_last_error ();
		e = _tmp22_;
		_tmp23_ = e;
		if (_tmp23_ != NULL) {
			gchar* s = NULL;
			xmlError* _tmp24_ = NULL;
			gchar* _tmp25_ = NULL;
			const gchar* _tmp26_ = NULL;
			_tmp24_ = e;
			_tmp25_ = gxml_libxml2_error_to_string (_tmp24_);
			s = _tmp25_;
			_tmp26_ = s;
			if (_tmp26_ != NULL) {
				const gchar* _tmp27_ = NULL;
				const gchar* _tmp28_ = NULL;
				gchar* _tmp29_ = NULL;
				_tmp27_ = errmsg;
				_tmp28_ = s;
				_tmp29_ = g_strconcat (_tmp27_, _tmp28_, NULL);
				_g_free0 (errmsg);
				errmsg = _tmp29_;
			}
			_g_free0 (s);
		}
		_tmp30_ = errmsg;
		gxml_exception (GXML_DOM_EXCEPTION_INVALID_DOC, _tmp30_);
		_tmp31_ = errmsg;
		_tmp32_ = g_error_new_literal (GXML_ERROR, GXML_ERROR_PARSER, _tmp31_);
		_inner_error_ = _tmp32_;
		g_propagate_error (error, _inner_error_);
		_g_object_unref0 (ostream);
		_g_free0 (errmsg);
		_g_object_unref0 (self);
		return NULL;
	}
	_g_object_unref0 (ostream);
	_g_free0 (errmsg);
	return self;
}


GXmlxDocument* gxml_xdocument_new_from_stream (GInputStream* instream, GCancellable* can, GError** error) {
	return gxml_xdocument_construct_from_stream (GXML_TYPE_XDOCUMENT, instream, can, error);
}


/**
 * Creates a xDocument from data found in memory.
 *
 * @param xml A string representing an XML document
 *
 * @return A new {@link GXml.xDocument} from `memory`; this must be freed with {@link GLib.Object.unref}
 */
GXmlxDocument* gxml_xdocument_construct_from_string (GType object_type, const gchar* xml) {
	GXmlxDocument * self = NULL;
	xmlDoc* doc = NULL;
	const gchar* _tmp0_ = NULL;
	const gchar* _tmp1_ = NULL;
	gint _tmp2_ = 0;
	gint _tmp3_ = 0;
	xmlDoc* _tmp4_ = NULL;
	xmlDoc* _tmp5_ = NULL;
	xmlDoc* _tmp7_ = NULL;
	g_return_val_if_fail (xml != NULL, NULL);
	gxml_reset_last_error ();
	_tmp0_ = xml;
	_tmp1_ = xml;
	_tmp2_ = strlen (_tmp1_);
	_tmp3_ = _tmp2_;
	_tmp4_ = xmlParseMemory (_tmp0_, (gint) _tmp3_);
	doc = _tmp4_;
	_tmp5_ = doc;
	if (_tmp5_ == NULL) {
		xmlDoc* _tmp6_ = NULL;
		_tmp6_ = xmlNewDoc ((xmlChar*) NULL);
		doc = _tmp6_;
	}
	_tmp7_ = doc;
	self = (GXmlxDocument*) gxml_xdocument_construct_from_libxml2 (object_type, _tmp7_, TRUE);
	return self;
}


GXmlxDocument* gxml_xdocument_new_from_string (const gchar* xml) {
	return gxml_xdocument_construct_from_string (GXML_TYPE_XDOCUMENT, xml);
}


/**
 * Creates a xDocument from data found in memory using options.
 *
 * @param xml A string representing an XML document
 * @param url the base URL to use for the document
 * @param encoding the document encoding
 * @param options a combination of {@link Xml.ParserOption}
 *
 * @return A new {@link GXml.xDocument} from `memory`; this must be freed with {@link GLib.Object.unref}
 */
GXmlxDocument* gxml_xdocument_construct_from_string_with_options (GType object_type, const gchar* xml, const gchar* url, const gchar* encoding, gint options, GError** error) {
	GXmlxDocument * self = NULL;
	xmlDoc* doc = NULL;
	const gchar* _tmp0_ = NULL;
	const gchar* _tmp1_ = NULL;
	gint _tmp2_ = 0;
	gint _tmp3_ = 0;
	const gchar* _tmp4_ = NULL;
	const gchar* _tmp5_ = NULL;
	gint _tmp6_ = 0;
	xmlDoc* _tmp7_ = NULL;
	xmlDoc* _tmp8_ = NULL;
	xmlError* e = NULL;
	xmlError* _tmp9_ = NULL;
	xmlError* _tmp10_ = NULL;
	GError * _inner_error_ = NULL;
	g_return_val_if_fail (xml != NULL, NULL);
	gxml_reset_last_error ();
	_tmp0_ = xml;
	_tmp1_ = xml;
	_tmp2_ = strlen (_tmp1_);
	_tmp3_ = _tmp2_;
	_tmp4_ = url;
	_tmp5_ = encoding;
	_tmp6_ = options;
	_tmp7_ = xmlReadMemory (_tmp0_, (gint) _tmp3_, _tmp4_, _tmp5_, _tmp6_);
	doc = _tmp7_;
	_tmp8_ = doc;
	self = (GXmlxDocument*) gxml_xdocument_construct_from_libxml2 (object_type, _tmp8_, TRUE);
	_tmp9_ = gxml_get_last_error ();
	e = _tmp9_;
	_tmp10_ = e;
	if (_tmp10_ != NULL) {
		gchar* errmsg = NULL;
		gchar* _tmp11_ = NULL;
		gchar* s = NULL;
		xmlError* _tmp12_ = NULL;
		gchar* _tmp13_ = NULL;
		const gchar* _tmp14_ = NULL;
		const gchar* _tmp16_ = NULL;
		const gchar* _tmp17_ = NULL;
		GError* _tmp18_ = NULL;
		_tmp11_ = g_strdup ("Parser Error for string");
		errmsg = _tmp11_;
		_tmp12_ = e;
		_tmp13_ = gxml_libxml2_error_to_string (_tmp12_);
		s = _tmp13_;
		_tmp14_ = s;
		if (_tmp14_ != NULL) {
			gchar* _tmp15_ = NULL;
			_tmp15_ = g_strdup (".  ");
			_g_free0 (errmsg);
			errmsg = _tmp15_;
		}
		_tmp16_ = errmsg;
		gxml_exception (GXML_DOM_EXCEPTION_INVALID_DOC, _tmp16_);
		_tmp17_ = errmsg;
		_tmp18_ = g_error_new_literal (GXML_ERROR, GXML_ERROR_PARSER, _tmp17_);
		_inner_error_ = _tmp18_;
		g_propagate_error (error, _inner_error_);
		_g_free0 (s);
		_g_free0 (errmsg);
		_g_object_unref0 (self);
		return NULL;
	}
	return self;
}


GXmlxDocument* gxml_xdocument_new_from_string_with_options (const gchar* xml, const gchar* url, const gchar* encoding, gint options, GError** error) {
	return gxml_xdocument_construct_from_string_with_options (GXML_TYPE_XDOCUMENT, xml, url, encoding, options, error);
}


/**
 * Creates an empty document.
 *
 * @return A new, empty {@link GXml.xDocument}; this must be freed with {@link GLib.Object.unref}
 */
GXmlxDocument* gxml_xdocument_construct (GType object_type) {
	GXmlxDocument * self = NULL;
	xmlDoc* doc = NULL;
	xmlDoc* _tmp0_ = NULL;
	xmlDoc* _tmp1_ = NULL;
	GXmlxDocument* _tmp2_ = NULL;
	GXmlxDocument* _tmp3_ = NULL;
	GXmlNodeChildNodeList* _tmp4_ = NULL;
	_tmp0_ = xmlNewDoc ((xmlChar*) NULL);
	doc = _tmp0_;
	self = (GXmlxDocument*) gxml_xdocument_construct_from_libxml2 (object_type, doc, FALSE);
	_tmp1_ = self->xmldoc;
	_tmp2_ = gxml_xnode_get_owner_document ((GXmlxNode*) self);
	_tmp3_ = _tmp2_;
	_tmp4_ = gxml_node_child_node_list_new ((xmlNode*) _tmp1_, _tmp3_);
	_g_object_unref0 (self->_node_list);
	self->_node_list = _tmp4_;
	return self;
}


GXmlxDocument* gxml_xdocument_new (void) {
	return gxml_xdocument_construct (GXML_TYPE_XDOCUMENT);
}


/**
 * Saves a xDocument 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
 */
void gxml_xdocument_save_to_path (GXmlxDocument* self, const gchar* file_path, GError** error) {
	gchar* errmsg = NULL;
	xmlError* e = NULL;
	xmlDoc* _tmp0_ = NULL;
	const gchar* _tmp1_ = NULL;
	gint _tmp2_ = 0;
	xmlError* _tmp5_ = NULL;
	xmlError* _tmp6_ = NULL;
	const gchar* _tmp13_ = NULL;
	const gchar* _tmp14_ = NULL;
	GError* _tmp15_ = NULL;
	GError * _inner_error_ = NULL;
	g_return_if_fail (self != NULL);
	g_return_if_fail (file_path != NULL);
	_tmp0_ = self->xmldoc;
	_tmp1_ = file_path;
	_tmp2_ = xmlSaveFile (_tmp1_, _tmp0_);
	if ((-1) == _tmp2_) {
		const gchar* _tmp3_ = NULL;
		gchar* _tmp4_ = NULL;
		_tmp3_ = file_path;
		_tmp4_ = g_strdup_printf ("Failed to write file to path '%s'", _tmp3_);
		_g_free0 (errmsg);
		errmsg = _tmp4_;
	} else {
		_g_free0 (errmsg);
		return;
	}
	_tmp5_ = gxml_get_last_error ();
	e = _tmp5_;
	_tmp6_ = e;
	if (_tmp6_ != NULL) {
		gchar* _tmp7_ = NULL;
		gchar* s = NULL;
		xmlError* _tmp8_ = NULL;
		gchar* _tmp9_ = NULL;
		const gchar* _tmp10_ = NULL;
		_tmp7_ = g_strdup ("Error to save to path");
		_g_free0 (errmsg);
		errmsg = _tmp7_;
		_tmp8_ = e;
		_tmp9_ = gxml_libxml2_error_to_string (_tmp8_);
		s = _tmp9_;
		_tmp10_ = s;
		if (_tmp10_ != NULL) {
			const gchar* _tmp11_ = NULL;
			gchar* _tmp12_ = NULL;
			_tmp11_ = errmsg;
			_tmp12_ = g_strconcat (_tmp11_, ".  ", NULL);
			_g_free0 (errmsg);
			errmsg = _tmp12_;
		}
		_g_free0 (s);
	}
	_tmp13_ = errmsg;
	gxml_exception (GXML_DOM_EXCEPTION_X_OTHER, _tmp13_);
	_tmp14_ = errmsg;
	_tmp15_ = g_error_new_literal (GXML_ERROR, GXML_ERROR_WRITER, _tmp14_);
	_inner_error_ = _tmp15_;
	if (_inner_error_->domain == GXML_ERROR) {
		g_propagate_error (error, _inner_error_);
		_g_free0 (errmsg);
		return;
	} else {
		_g_free0 (errmsg);
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
		g_clear_error (&_inner_error_);
		return;
	}
	_g_free0 (errmsg);
}


/**
 * Saves a xDocument 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
 */
static guint8* g_string_get_data (GString* self, int* result_length1) {
	guint8* result;
	guint8* res = NULL;
	const gchar* _tmp0_ = NULL;
	gint res_length1 = 0;
	gint _res_size_ = 0;
	gssize _tmp1_ = 0L;
	gint _tmp2_ = 0;
	guint8* _tmp3_ = NULL;
	gint _tmp3__length1 = 0;
	guint8* _tmp4_ = NULL;
	gint _tmp4__length1 = 0;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->str;
	res = (guint8*) _tmp0_;
	res_length1 = -1;
	_res_size_ = res_length1;
	_tmp1_ = self->len;
	res_length1 = (gint) _tmp1_;
	_tmp2_ = res_length1;
	_tmp3_ = res;
	_tmp3__length1 = res_length1;
	_tmp4_ = _tmp3_;
	_tmp4__length1 = _tmp3__length1;
	if (result_length1) {
		*result_length1 = _tmp4__length1;
	}
	result = _tmp4_;
	return result;
}


static guint8* _vala_array_dup1 (guint8* self, int length) {
	return g_memdup (self, length * sizeof (guint8));
}


void gxml_xdocument_save_to_stream (GXmlxDocument* self, GOutputStream* outstream, GCancellable* can, GError** error) {
	GError * _inner_error_ = NULL;
	g_return_if_fail (self != NULL);
	g_return_if_fail (outstream != NULL);
	{
		GString* s = NULL;
		GString* _tmp0_ = NULL;
		GString* _tmp1_ = NULL;
		gchar* _tmp2_ = NULL;
		gchar* _tmp3_ = NULL;
		GMemoryInputStream* istream = NULL;
		GString* _tmp4_ = NULL;
		guint8* _tmp5_ = NULL;
		gint _tmp5__length1 = 0;
		guint8* _tmp6_ = NULL;
		gint _tmp6__length1 = 0;
		guint8* _tmp7_ = NULL;
		gint _tmp7__length1 = 0;
		GMemoryInputStream* _tmp8_ = NULL;
		GOutputStream* _tmp9_ = NULL;
		GMemoryInputStream* _tmp10_ = NULL;
		_tmp0_ = g_string_new ("");
		s = _tmp0_;
		_tmp1_ = s;
		_tmp2_ = gxml_xnode_to_string ((GXmlxNode*) self);
		_tmp3_ = _tmp2_;
		g_string_append (_tmp1_, _tmp3_);
		_g_free0 (_tmp3_);
		_tmp4_ = s;
		_tmp5_ = g_string_get_data (_tmp4_, &_tmp5__length1);
		_tmp6_ = _tmp5_;
		_tmp6__length1 = _tmp5__length1;
		_tmp7_ = (_tmp6_ != NULL) ? _vala_array_dup1 (_tmp6_, _tmp6__length1) : ((gpointer) _tmp6_);
		_tmp7__length1 = _tmp6__length1;
		_tmp8_ = (GMemoryInputStream*) g_memory_input_stream_new_from_data (_tmp7_, _tmp7__length1, NULL);
		istream = _tmp8_;
		_tmp9_ = outstream;
		_tmp10_ = istream;
		g_output_stream_splice (_tmp9_, (GInputStream*) _tmp10_, G_OUTPUT_STREAM_SPLICE_NONE, NULL, &_inner_error_);
		if (G_UNLIKELY (_inner_error_ != NULL)) {
			_g_object_unref0 (istream);
			_g_string_free0 (s);
			goto __catch2_g_error;
		}
		_g_object_unref0 (istream);
		_g_string_free0 (s);
	}
	goto __finally2;
	__catch2_g_error:
	{
		GError* e = NULL;
		GError* _tmp11_ = NULL;
		const gchar* _tmp12_ = NULL;
		GError* _tmp13_ = NULL;
		const gchar* _tmp14_ = NULL;
		GError* _tmp15_ = NULL;
		e = _inner_error_;
		_inner_error_ = NULL;
		_tmp11_ = e;
		_tmp12_ = _tmp11_->message;
		gxml_exception (GXML_DOM_EXCEPTION_X_OTHER, _tmp12_);
		_tmp13_ = e;
		_tmp14_ = _tmp13_->message;
		_tmp15_ = g_error_new_literal (GXML_ERROR, GXML_ERROR_WRITER, _tmp14_);
		_inner_error_ = _tmp15_;
		_g_error_free0 (e);
		goto __finally2;
	}
	__finally2:
	if (G_UNLIKELY (_inner_error_ != NULL)) {
		g_propagate_error (error, _inner_error_);
		return;
	}
}


/**
 * Creates an empty {@link GXml.xElement} 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<<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.xElement}
 *
 * @return A new {@link GXml.xElement}; this should not be freed
 */
static gpointer _g_object_ref0 (gpointer self) {
	return self ? g_object_ref (self) : NULL;
}


static GXmlNode* gxml_xdocument_real_create_element (GXmlDocument* base, const gchar* tag_name, GError** error) {
	GXmlxDocument * self;
	GXmlNode* result = NULL;
	xmlNode* xmlelem = NULL;
	const gchar* _tmp0_ = NULL;
	xmlDoc* _tmp1_ = NULL;
	const gchar* _tmp2_ = NULL;
	xmlNode* _tmp3_ = NULL;
	GXmlxElement* new_elem = NULL;
	GXmlxElement* _tmp4_ = NULL;
	GXmlxNode* _tmp5_ = NULL;
	GXmlxElement* ret = NULL;
	GXmlNode* _tmp6_ = NULL;
	self = (GXmlxDocument*) base;
	g_return_val_if_fail (tag_name != NULL, NULL);
	_tmp0_ = tag_name;
	gxml_xdocument_check_invalid_characters (_tmp0_, "element");
	_tmp1_ = self->xmldoc;
	_tmp2_ = tag_name;
	_tmp3_ = xmlNewDocNode (_tmp1_, NULL, (xmlChar*) _tmp2_, (xmlChar*) NULL);
	xmlelem = _tmp3_;
	self->priv->new_nodes = g_list_append (self->priv->new_nodes, xmlelem);
	_tmp4_ = gxml_xelement_new (xmlelem, self);
	new_elem = _tmp4_;
	_tmp5_ = _g_object_ref0 ((GXmlxNode*) new_elem);
	self->priv->nodes_to_free = g_list_append (self->priv->nodes_to_free, _tmp5_);
	ret = new_elem;
	_tmp6_ = _g_object_ref0 ((GXmlNode*) ret);
	result = _tmp6_;
	_g_object_unref0 (new_elem);
	return result;
}


/**
 * Creates a {@link GXml.DocumentFragment}.
 *
 * xDocument 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<<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
 */
GXmlDocumentFragment* gxml_xdocument_create_document_fragment (GXmlxDocument* self) {
	GXmlDocumentFragment* result = NULL;
	GXmlDocumentFragment* fragment = NULL;
	xmlDoc* _tmp0_ = NULL;
	xmlNode* _tmp1_ = NULL;
	GXmlDocumentFragment* _tmp2_ = NULL;
	GXmlDocumentFragment* ret = NULL;
	GXmlxNode* _tmp3_ = NULL;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->xmldoc;
	_tmp1_ = xmlNewDocFragment (_tmp0_);
	_tmp2_ = gxml_document_fragment_new (_tmp1_, self);
	fragment = _tmp2_;
	ret = fragment;
	_tmp3_ = _g_object_ref0 ((GXmlxNode*) fragment);
	self->priv->nodes_to_free = g_list_append (self->priv->nodes_to_free, _tmp3_);
	result = ret;
	_g_object_unref0 (fragment);
	return result;
}


/**
 * 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<<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
 */
GXmlxText* gxml_xdocument_create_text_node (GXmlxDocument* self, const gchar* text_data) {
	GXmlxText* result = NULL;
	GXmlxText* text = NULL;
	xmlDoc* _tmp0_ = NULL;
	const gchar* _tmp1_ = NULL;
	xmlNode* _tmp2_ = NULL;
	GXmlxText* _tmp3_ = NULL;
	GXmlxText* ret = NULL;
	GXmlxNode* _tmp4_ = NULL;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (text_data != NULL, NULL);
	_tmp0_ = self->xmldoc;
	_tmp1_ = text_data;
	_tmp2_ = xmlNewDocText (_tmp0_, (xmlChar*) _tmp1_);
	_tmp3_ = gxml_xtext_new (_tmp2_, self);
	text = _tmp3_;
	ret = text;
	_tmp4_ = _g_object_ref0 ((GXmlxNode*) text);
	self->priv->nodes_to_free = g_list_append (self->priv->nodes_to_free, _tmp4_);
	result = ret;
	_g_object_unref0 (text);
	return result;
}


/**
 * Creates an XML comment with data.  Its memory is
 * freed when its owner document is freed.
 *
 * XML example:
 *
 * {{{
 *  <!-- data -->
 * }}}
 *
 * Version: DOM Level 1 Core<<BR>>
 * URL: [[http://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html#method-createComment]]
 *
 * @param comment_data The content of the comment
 *
 * @return A new {@link GXml.Comment} containing the
 * supplied data; this should not be freed
 */
GXmlxComment* gxml_xdocument_create_managed_comment (GXmlxDocument* self, const gchar* comment_data) {
	GXmlxComment* result = NULL;
	GXmlxComment* comment = NULL;
	xmlDoc* _tmp0_ = NULL;
	const gchar* _tmp1_ = NULL;
	xmlNode* _tmp2_ = NULL;
	GXmlxComment* _tmp3_ = NULL;
	GXmlxComment* ret = NULL;
	GXmlxNode* _tmp4_ = NULL;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (comment_data != NULL, NULL);
	_tmp0_ = self->xmldoc;
	_tmp1_ = comment_data;
	_tmp2_ = xmlNewDocComment (_tmp0_, (xmlChar*) _tmp1_);
	_tmp3_ = gxml_xcomment_new (_tmp2_, self);
	comment = _tmp3_;
	ret = comment;
	_tmp4_ = _g_object_ref0 ((GXmlxNode*) comment);
	self->priv->nodes_to_free = g_list_append (self->priv->nodes_to_free, _tmp4_);
	result = ret;
	_g_object_unref0 (comment);
	return result;
}


/**
 * Creates a CDATA section containing data.
 *
 * 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.]]>. }}}
 *
 * 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.xCDATASection} with the
 * supplied data; this should not be freed
 */
GXmlxCDATASection* gxml_xdocument_create_cdata_section (GXmlxDocument* self, const gchar* cdata_data) {
	GXmlxCDATASection* result = NULL;
	GXmlxCDATASection* cdata = NULL;
	xmlDoc* _tmp0_ = NULL;
	const gchar* _tmp1_ = NULL;
	const gchar* _tmp2_ = NULL;
	gint _tmp3_ = 0;
	gint _tmp4_ = 0;
	xmlNode* _tmp5_ = NULL;
	GXmlxCDATASection* _tmp6_ = NULL;
	GXmlxCDATASection* ret = NULL;
	GXmlxNode* _tmp7_ = NULL;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (cdata_data != NULL, NULL);
	gxml_xdocument_check_not_supported_html (self, "CDATA section");
	_tmp0_ = self->xmldoc;
	_tmp1_ = cdata_data;
	_tmp2_ = cdata_data;
	_tmp3_ = strlen (_tmp2_);
	_tmp4_ = _tmp3_;
	_tmp5_ = xmlNewCDataBlock (_tmp0_, (xmlChar*) _tmp1_, (gint) _tmp4_);
	_tmp6_ = gxml_xcdata_section_new (_tmp5_, self);
	cdata = _tmp6_;
	ret = cdata;
	_tmp7_ = _g_object_ref0 ((GXmlxNode*) cdata);
	self->priv->nodes_to_free = g_list_append (self->priv->nodes_to_free, _tmp7_);
	result = ret;
	_g_object_unref0 (cdata);
	return result;
}


/**
 * Creates a new {@link GXml.ProcessingInstruction}.
 *
 * Its memory is freed when its owner document is
 * freed.
 *
 * 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
 */
GXmlxProcessingInstruction* gxml_xdocument_create_processing_instruction (GXmlxDocument* self, const gchar* target, const gchar* data) {
	GXmlxProcessingInstruction* result = NULL;
	const gchar* _tmp0_ = NULL;
	GXmlxProcessingInstruction* pi = NULL;
	const gchar* _tmp1_ = NULL;
	const gchar* _tmp2_ = NULL;
	GXmlxProcessingInstruction* _tmp3_ = NULL;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (target != NULL, NULL);
	g_return_val_if_fail (data != NULL, NULL);
	gxml_xdocument_check_not_supported_html (self, "processing instructions");
	_tmp0_ = target;
	gxml_xdocument_check_invalid_characters (_tmp0_, "processing instruction");
	_tmp1_ = target;
	_tmp2_ = data;
	_tmp3_ = gxml_xprocessing_instruction_new (_tmp1_, _tmp2_, self);
	pi = _tmp3_;
	result = pi;
	return result;
}


/**
 * Creates an {@link GXml.Attribute} attribute with `name`, usually to be associated with an xElement.
 *
 * XML example: {{{<element attributename="attributevalue">content</element>}}}
 *
 * 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.Attribute} with the given `name`; this should not be freed
 */
GXmlxAttr* gxml_xdocument_create_attribute (GXmlxDocument* self, const gchar* name) {
	GXmlxAttr* result = NULL;
	const gchar* _tmp0_ = NULL;
	xmlDoc* _tmp1_ = NULL;
	const gchar* _tmp2_ = NULL;
	xmlAttr* _tmp3_ = NULL;
	GXmlxAttr* _tmp4_ = NULL;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (name != NULL, NULL);
	_tmp0_ = name;
	gxml_xdocument_check_invalid_characters (_tmp0_, "attribute");
	_tmp1_ = self->xmldoc;
	_tmp2_ = name;
	_tmp3_ = xmlNewDocProp (_tmp1_, (xmlChar*) _tmp2_, (xmlChar*) "");
	_tmp4_ = gxml_xattr_new (_tmp3_, self);
	result = _tmp4_;
	return result;
}


/**
 * 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<<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
 *
 * @return An {@link GXml.EntityReference} for `name`; this should not be freed
 */
GXmlEntityReference* gxml_xdocument_create_entity_reference (GXmlxDocument* self, const gchar* name) {
	GXmlEntityReference* result = NULL;
	const gchar* _tmp0_ = NULL;
	const gchar* _tmp1_ = NULL;
	GXmlEntityReference* _tmp2_ = NULL;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (name != NULL, NULL);
	gxml_xdocument_check_not_supported_html (self, "entity reference");
	_tmp0_ = name;
	gxml_xdocument_check_invalid_characters (_tmp0_, "entity reference");
	_tmp1_ = name;
	_tmp2_ = gxml_entity_reference_new (_tmp1_, self);
	result = _tmp2_;
	return result;
}


/**
 * Obtains a list of {@link GXml.xElement}s, each with
 * the given tag name `tag_name`, contained within
 * this document.
 *
 * Note that the list is live, updated as new elements
 * are added to the document.
 *
 * Unlike a {@link GXml.xNode} 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<<BR>>
 * URL: [[http://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html#method-getElementsByTagName]]
 *
 * @param tag_name The {@link GXml.xElement} tag name we matching for
 *
 * @return A {@link GXml.NodeList} of
 * {@link GXml.xElement}s; this must be freed with
 * {@link GLib.Object.unref}.
 */
GXmlxNodeList* gxml_xdocument_get_elements_by_tag_name (GXmlxDocument* self, const gchar* tag_name) {
	GXmlxNodeList* result = NULL;
	GXmlxElement* _tmp0_ = NULL;
	GXmlxElement* _tmp1_ = NULL;
	const gchar* _tmp2_ = NULL;
	GXmlxNodeList* _tmp3_ = NULL;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (tag_name != NULL, NULL);
	_tmp0_ = gxml_xdocument_get_document_element (self);
	_tmp1_ = _tmp0_;
	_tmp2_ = tag_name;
	_tmp3_ = gxml_xelement_get_elements_by_tag_name (_tmp1_, _tmp2_);
	result = _tmp3_;
	return result;
}


/**
 * Feature should be something like "processing instructions"
 */
static void gxml_xdocument_check_not_supported_html (GXmlxDocument* self, const gchar* feature) {
	gboolean _tmp0_ = FALSE;
	GXmlxDocumentType* _tmp1_ = NULL;
	g_return_if_fail (self != NULL);
	g_return_if_fail (feature != NULL);
	_tmp1_ = self->priv->_doctype;
	if (_tmp1_ != NULL) {
		GXmlxDocumentType* _tmp2_ = NULL;
		gchar* _tmp3_ = NULL;
		gchar* _tmp4_ = NULL;
		gchar* _tmp5_ = NULL;
		gchar* _tmp6_ = NULL;
		gchar* _tmp7_ = NULL;
		gchar* _tmp8_ = NULL;
		gchar* _tmp9_ = NULL;
		_tmp2_ = self->priv->_doctype;
		_tmp3_ = gxml_xnode_get_name ((GXmlxNode*) _tmp2_);
		_tmp4_ = _tmp3_;
		_tmp5_ = _tmp4_;
		_tmp6_ = g_utf8_casefold (_tmp5_, (gssize) (-1));
		_tmp7_ = _tmp6_;
		_tmp8_ = g_utf8_casefold ("html", (gssize) (-1));
		_tmp9_ = _tmp8_;
		_tmp0_ = g_strcmp0 (_tmp7_, _tmp9_) == 0;
		_g_free0 (_tmp9_);
		_g_free0 (_tmp7_);
		_g_free0 (_tmp5_);
	} else {
		_tmp0_ = FALSE;
	}
	if (_tmp0_) {
		const gchar* _tmp10_ = NULL;
		gchar* _tmp11_ = NULL;
		gchar* _tmp12_ = NULL;
		_tmp10_ = feature;
		_tmp11_ = g_strdup_printf ("HTML documents do not support '%s'", _tmp10_);
		_tmp12_ = _tmp11_;
		gxml_exception (GXML_DOM_EXCEPTION_NOT_SUPPORTED, _tmp12_);
		_g_free0 (_tmp12_);
	}
}


/**
 * Subject should be something like "element" or "processing instruction"
 */
gboolean gxml_xdocument_check_invalid_characters (const gchar* name, const gchar* subject) {
	gboolean result = FALSE;
	const gchar* _tmp0_ = NULL;
	gint _tmp1_ = 0;
	g_return_val_if_fail (name != NULL, FALSE);
	g_return_val_if_fail (subject != NULL, FALSE);
	_tmp0_ = name;
	_tmp1_ = gxml_validate_name (_tmp0_, 0);
	if (_tmp1_ != 0) {
		const gchar* _tmp2_ = NULL;
		const gchar* _tmp3_ = NULL;
		gchar* _tmp4_ = NULL;
		gchar* _tmp5_ = NULL;
		_tmp2_ = name;
		_tmp3_ = subject;
		_tmp4_ = g_strdup_printf ("Provided name '%s' for '%s' is not a valid XML name", _tmp2_, _tmp3_);
		_tmp5_ = _tmp4_;
		gxml_exception (GXML_DOM_EXCEPTION_INVALID_CHARACTER, _tmp5_);
		_g_free0 (_tmp5_);
		result = FALSE;
		return result;
	}
	result = TRUE;
	return result;
}


/**
 * {@inheritDoc}
 */
static gchar* gxml_xdocument_real_stringify (GXmlxNode* base, gboolean format, gint level) {
	GXmlxDocument * self;
	gchar* result = NULL;
	gchar* str = NULL;
	gint len = 0;
	xmlDoc* _tmp0_ = NULL;
	gboolean _tmp1_ = FALSE;
	gchar* _tmp2_ = NULL;
	gint _tmp3_ = 0;
	self = (GXmlxDocument*) base;
	_tmp0_ = self->xmldoc;
	_tmp1_ = format;
	xmlDocDumpFormatMemory (_tmp0_, (xmlChar*) (&_tmp2_), &_tmp3_, _tmp1_);
	_g_free0 (str);
	str = _tmp2_;
	len = _tmp3_;
	result = str;
	return result;
}


/**
 * Replaces `old_child` with `new_child` in this node's list of children.
 *
 * 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`; this should not be freed
 */
static GXmlxNode* gxml_xdocument_real_replace_child (GXmlxNode* base, GXmlxNode* new_child, GXmlxNode* old_child) {
	GXmlxDocument * self;
	GXmlxNode* result = NULL;
	gboolean _tmp0_ = FALSE;
	GXmlxNode* _tmp1_ = NULL;
	GXmlNodeType _tmp2_ = 0;
	GXmlNodeType _tmp3_ = 0;
	self = (GXmlxDocument*) base;
	g_return_val_if_fail (new_child != NULL, NULL);
	g_return_val_if_fail (old_child != NULL, NULL);
	_tmp1_ = new_child;
	_tmp2_ = gxml_xnode_get_node_type (_tmp1_);
	_tmp3_ = _tmp2_;
	if (_tmp3_ == GXML_NODE_TYPE_ELEMENT) {
		_tmp0_ = TRUE;
	} else {
		GXmlxNode* _tmp4_ = NULL;
		GXmlNodeType _tmp5_ = 0;
		GXmlNodeType _tmp6_ = 0;
		_tmp4_ = new_child;
		_tmp5_ = gxml_xnode_get_node_type (_tmp4_);
		_tmp6_ = _tmp5_;
		_tmp0_ = _tmp6_ == GXML_NODE_TYPE_DOCUMENT_TYPE;
	}
	if (_tmp0_) {
		GXmlxNode* _tmp7_ = NULL;
		GXmlxNode* _tmp8_ = NULL;
		_tmp7_ = new_child;
		_tmp8_ = gxml_xnode_append_child ((GXmlxNode*) self, _tmp7_);
		result = _tmp8_;
		return result;
	} else {
		GXmlxNode* _tmp9_ = NULL;
		GXmlxNode* _tmp10_ = NULL;
		GXmlxNode* _tmp11_ = NULL;
		_tmp9_ = new_child;
		_tmp10_ = old_child;
		_tmp11_ = gxml_xnode_replace_child ((GXmlxNode*) self, _tmp9_, _tmp10_);
		result = _tmp11_;
		return result;
	}
}


/**
 * Removes `old_child` from this document's list of
 * children.
 *
 * 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
 *
 * @return The removed node `old_child`; this should not be freed
 */
static GXmlxNode* gxml_xdocument_real_remove_child (GXmlxNode* base, GXmlxNode* old_child) {
	GXmlxDocument * self;
	GXmlxNode* result = NULL;
	GXmlxNodeList* _tmp0_ = NULL;
	GXmlxNodeList* _tmp1_ = NULL;
	GXmlxNode* _tmp2_ = NULL;
	GXmlxNode* _tmp3_ = NULL;
	self = (GXmlxDocument*) base;
	g_return_val_if_fail (old_child != NULL, NULL);
	_tmp0_ = gxml_xnode_get_child_nodes ((GXmlxNode*) self);
	_tmp1_ = _tmp0_;
	_tmp2_ = old_child;
	_tmp3_ = gxml_xnode_list_remove_child (_tmp1_, _tmp2_);
	result = _tmp3_;
	return result;
}


/**
 * Inserts `new_child` into this document before
 * `ref_child`, an existing child of this
 * {@link GXml.xDocument}. A document can only have one
 * {@link GXml.xElement} child (the root element) and
 * one {@link GXml.xDocumentType}.
 *
 * 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, or %NULL
 *
 * @return The newly inserted child; this should not be freed
 */
static GXmlxNode* gxml_xdocument_real_insert_before (GXmlxNode* base, GXmlxNode* new_child, GXmlxNode* ref_child) {
	GXmlxDocument * self;
	GXmlxNode* result = NULL;
	gboolean _tmp0_ = FALSE;
	GXmlxNode* _tmp1_ = NULL;
	GXmlNodeType _tmp2_ = 0;
	GXmlNodeType _tmp3_ = 0;
	self = (GXmlxDocument*) base;
	g_return_val_if_fail (new_child != NULL, NULL);
	_tmp1_ = new_child;
	_tmp2_ = gxml_xnode_get_node_type (_tmp1_);
	_tmp3_ = _tmp2_;
	if (_tmp3_ == GXML_NODE_TYPE_ELEMENT) {
		_tmp0_ = TRUE;
	} else {
		GXmlxNode* _tmp4_ = NULL;
		GXmlNodeType _tmp5_ = 0;
		GXmlNodeType _tmp6_ = 0;
		_tmp4_ = new_child;
		_tmp5_ = gxml_xnode_get_node_type (_tmp4_);
		_tmp6_ = _tmp5_;
		_tmp0_ = _tmp6_ == GXML_NODE_TYPE_DOCUMENT_TYPE;
	}
	if (_tmp0_) {
		GXmlxNode* _tmp7_ = NULL;
		GXmlxNode* _tmp8_ = NULL;
		_tmp7_ = new_child;
		_tmp8_ = gxml_xnode_append_child ((GXmlxNode*) self, _tmp7_);
		result = _tmp8_;
		return result;
	} else {
		GXmlxNodeList* _tmp9_ = NULL;
		GXmlxNodeList* _tmp10_ = NULL;
		GXmlxNode* _tmp11_ = NULL;
		GXmlxNode* _tmp12_ = NULL;
		GXmlxNode* _tmp13_ = NULL;
		_tmp9_ = gxml_xnode_get_child_nodes ((GXmlxNode*) self);
		_tmp10_ = _tmp9_;
		_tmp11_ = new_child;
		_tmp12_ = ref_child;
		_tmp13_ = gxml_xnode_list_insert_before (_tmp10_, _tmp11_, _tmp12_);
		result = _tmp13_;
		return result;
	}
}


/**
 * Appends new_child to this document, appearing at
 * the end of its list of children.  A document can
 * only have one {@link GXml.xElement} child, the root
 * element, and one {@link GXml.xDocumentType}.
 *
 * 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; this should not be freed
 */
static GXmlxNode* gxml_xdocument_real_append_child (GXmlxNode* base, GXmlxNode* new_child) {
	GXmlxDocument * self;
	GXmlxNode* result = NULL;
	GXmlxNode* _tmp0_ = NULL;
	GXmlxNode* _tmp1_ = NULL;
	GXmlNodeType _tmp2_ = 0;
	GXmlNodeType _tmp3_ = 0;
	self = (GXmlxDocument*) base;
	g_return_val_if_fail (new_child != NULL, NULL);
	_tmp0_ = new_child;
	gxml_xnode_check_wrong_document ((GXmlxNode*) self, _tmp0_);
	gxml_xnode_check_read_only ((GXmlxNode*) self);
	_tmp1_ = new_child;
	_tmp2_ = gxml_xnode_get_node_type (_tmp1_);
	_tmp3_ = _tmp2_;
	if (_tmp3_ == GXML_NODE_TYPE_ELEMENT) {
		xmlDoc* _tmp4_ = NULL;
		xmlNode* _tmp5_ = NULL;
		_tmp4_ = self->xmldoc;
		_tmp5_ = xmlDocGetRootElement (_tmp4_);
		if (_tmp5_ == NULL) {
			xmlDoc* _tmp6_ = NULL;
			GXmlxNode* _tmp7_ = NULL;
			xmlNode* _tmp8_ = NULL;
			_tmp6_ = self->xmldoc;
			_tmp7_ = new_child;
			_tmp8_ = ((GXmlBackedNode*) G_TYPE_CHECK_INSTANCE_CAST (_tmp7_, GXML_TYPE_XELEMENT, GXmlxElement))->node;
			xmlDocSetRootElement (_tmp6_, _tmp8_);
		} else {
			GXmlxNode* _tmp9_ = NULL;
			const gchar* _tmp10_ = NULL;
			const gchar* _tmp11_ = NULL;
			gchar* _tmp12_ = NULL;
			gchar* _tmp13_ = NULL;
			_tmp9_ = new_child;
			_tmp10_ = gxml_xnode_get_node_name (_tmp9_);
			_tmp11_ = _tmp10_;
			_tmp12_ = g_strdup_printf ("Document already has a root element.  Could not add child element with" \
" name '%s'", _tmp11_);
			_tmp13_ = _tmp12_;
			gxml_exception (GXML_DOM_EXCEPTION_HIERARCHY_REQUEST, _tmp13_);
			_g_free0 (_tmp13_);
		}
	} else {
		GXmlxNode* _tmp14_ = NULL;
		GXmlNodeType _tmp15_ = 0;
		GXmlNodeType _tmp16_ = 0;
		_tmp14_ = new_child;
		_tmp15_ = gxml_xnode_get_node_type (_tmp14_);
		_tmp16_ = _tmp15_;
		if (_tmp16_ == GXML_NODE_TYPE_DOCUMENT_TYPE) {
			GXmlxDocumentType* _tmp17_ = NULL;
			_tmp17_ = self->priv->_doctype;
			if (_tmp17_ == NULL) {
				GXmlxNode* _tmp18_ = NULL;
				_tmp18_ = new_child;
				gxml_xdocument_set_doctype (self, G_TYPE_CHECK_INSTANCE_CAST (_tmp18_, GXML_TYPE_XDOCUMENT_TYPE, GXmlxDocumentType));
			} else {
				GXmlxNode* _tmp19_ = NULL;
				gchar* _tmp20_ = NULL;
				gchar* _tmp21_ = NULL;
				gchar* _tmp22_ = NULL;
				gchar* _tmp23_ = NULL;
				gchar* _tmp24_ = NULL;
				_tmp19_ = new_child;
				_tmp20_ = gxml_xnode_get_name ((GXmlxNode*) G_TYPE_CHECK_INSTANCE_CAST (_tmp19_, GXML_TYPE_XDOCUMENT_TYPE, GXmlxDocumentType));
				_tmp21_ = _tmp20_;
				_tmp22_ = _tmp21_;
				_tmp23_ = g_strdup_printf ("Document already has a doctype.  Could not add new doctype with name '" \
"%s'.", _tmp22_);
				_tmp24_ = _tmp23_;
				gxml_exception (GXML_DOM_EXCEPTION_HIERARCHY_REQUEST, _tmp24_);
				_g_free0 (_tmp24_);
				_g_free0 (_tmp22_);
			}
		} else {
			GXmlxNodeList* _tmp25_ = NULL;
			GXmlxNodeList* _tmp26_ = NULL;
			GXmlxNode* _tmp27_ = NULL;
			GXmlxNode* _tmp28_ = NULL;
			_tmp25_ = gxml_xnode_get_child_nodes ((GXmlxNode*) self);
			_tmp26_ = _tmp25_;
			_tmp27_ = new_child;
			_tmp28_ = gxml_xnode_list_append_child (_tmp26_, _tmp27_);
			result = _tmp28_;
			return result;
		}
	}
	result = NULL;
	return result;
}


/**
 * {@inheritDoc}
 */
static gboolean gxml_xdocument_real_has_child_nodes (GXmlxNode* base) {
	GXmlxDocument * self;
	gboolean result = FALSE;
	xmlDoc* _tmp0_ = NULL;
	xmlNode* _tmp1_ = NULL;
	self = (GXmlxDocument*) base;
	_tmp0_ = self->xmldoc;
	_tmp1_ = _tmp0_->children;
	result = _tmp1_ != NULL;
	return result;
}


GXmlxNode* gxml_xdocument_copy_node (GXmlxDocument* self, GXmlxNode* foreign_node, gboolean deep) {
	GXmlxNode* result = NULL;
	gint _tmp0_ = 0;
	gboolean _tmp1_ = FALSE;
	xmlNode* our_copy_xml = NULL;
	GXmlxNode* _tmp2_ = NULL;
	xmlNode* _tmp3_ = NULL;
	xmlDoc* _tmp4_ = NULL;
	xmlNode* _tmp5_ = NULL;
	GXmlxNode* _tmp6_ = NULL;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (foreign_node != NULL, NULL);
	_tmp1_ = deep;
	if (_tmp1_) {
		_tmp0_ = 1;
	} else {
		_tmp0_ = 0;
	}
	_tmp2_ = foreign_node;
	_tmp3_ = G_TYPE_CHECK_INSTANCE_CAST (_tmp2_, GXML_TYPE_BACKED_NODE, GXmlBackedNode)->node;
	_tmp4_ = self->xmldoc;
	_tmp5_ = xmlDocCopyNode (_tmp3_, _tmp4_, _tmp0_);
	our_copy_xml = _tmp5_;
	_tmp6_ = gxml_xdocument_lookup_node (self, our_copy_xml);
	result = _tmp6_;
	return result;
}


static GXmlNode* gxml_xdocument_real_create_text (GXmlDocument* base, const gchar* str) {
	GXmlxDocument * self;
	GXmlNode* result = NULL;
	const gchar* _tmp0_ = NULL;
	GXmlxText* _tmp1_ = NULL;
	GXmlNode* _tmp2_ = NULL;
	self = (GXmlxDocument*) base;
	g_return_val_if_fail (str != NULL, NULL);
	_tmp0_ = str;
	_tmp1_ = gxml_xdocument_create_text_node (self, _tmp0_);
	_tmp2_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp1_, GXML_TYPE_NODE, GXmlNode));
	result = _tmp2_;
	return result;
}


static GXmlNode* gxml_xdocument_real_create_comment (GXmlDocument* base, const gchar* text) {
	GXmlxDocument * self;
	GXmlNode* result = NULL;
	const gchar* _tmp0_ = NULL;
	GXmlxComment* _tmp1_ = NULL;
	GXmlNode* _tmp2_ = NULL;
	self = (GXmlxDocument*) base;
	g_return_val_if_fail (text != NULL, NULL);
	_tmp0_ = text;
	_tmp1_ = gxml_xdocument_create_managed_comment (self, _tmp0_);
	_tmp2_ = _g_object_ref0 ((GXmlNode*) _tmp1_);
	result = _tmp2_;
	return result;
}


static GXmlNode* gxml_xdocument_real_create_cdata (GXmlDocument* base, const gchar* text) {
	GXmlxDocument * self;
	GXmlNode* result = NULL;
	const gchar* _tmp0_ = NULL;
	GXmlxCDATASection* _tmp1_ = NULL;
	GXmlNode* _tmp2_ = NULL;
	self = (GXmlxDocument*) base;
	g_return_val_if_fail (text != NULL, NULL);
	_tmp0_ = text;
	_tmp1_ = gxml_xdocument_create_cdata_section (self, _tmp0_);
	_tmp2_ = _g_object_ref0 ((GXmlNode*) _tmp1_);
	result = _tmp2_;
	return result;
}


static GXmlNode* gxml_xdocument_real_create_pi (GXmlDocument* base, const gchar* target, const gchar* data) {
	GXmlxDocument * self;
	GXmlNode* result = NULL;
	const gchar* _tmp0_ = NULL;
	const gchar* _tmp1_ = NULL;
	GXmlxProcessingInstruction* _tmp2_ = NULL;
	self = (GXmlxDocument*) base;
	g_return_val_if_fail (target != NULL, NULL);
	g_return_val_if_fail (data != NULL, NULL);
	_tmp0_ = target;
	_tmp1_ = data;
	_tmp2_ = gxml_xdocument_create_processing_instruction (self, _tmp0_, _tmp1_);
	result = (GXmlNode*) _tmp2_;
	return result;
}


static gboolean gxml_xdocument_real_save (GXmlDocument* base, GCancellable* cancellable, GError** error) {
	GXmlxDocument * self;
	gboolean result = FALSE;
	GFile* _tmp0_ = NULL;
	GFile* _tmp1_ = NULL;
	GFile* _tmp2_ = NULL;
	GFile* _tmp3_ = NULL;
	gboolean _tmp4_ = FALSE;
	gboolean _tmp5_ = FALSE;
	GFile* _tmp6_ = NULL;
	GFile* _tmp7_ = NULL;
	GCancellable* _tmp8_ = NULL;
	gboolean _tmp9_ = FALSE;
	GError * _inner_error_ = NULL;
	self = (GXmlxDocument*) base;
	_tmp0_ = gxml_document_get_file ((GXmlDocument*) self);
	_tmp1_ = _tmp0_;
	_vala_return_val_if_fail (_tmp1_ != NULL, "file != null", FALSE);
	_tmp2_ = gxml_document_get_file ((GXmlDocument*) self);
	_tmp3_ = _tmp2_;
	_tmp4_ = g_file_query_exists (_tmp3_, NULL);
	_vala_return_val_if_fail (_tmp4_, "file.query_exists ()", FALSE);
	_tmp6_ = gxml_document_get_file ((GXmlDocument*) self);
	_tmp7_ = _tmp6_;
	_tmp8_ = cancellable;
	_tmp9_ = gxml_document_save_as ((GXmlDocument*) self, _tmp7_, _tmp8_, &_inner_error_);
	_tmp5_ = _tmp9_;
	if (G_UNLIKELY (_inner_error_ != NULL)) {
		g_propagate_error (error, _inner_error_);
		return FALSE;
	}
	result = _tmp5_;
	return result;
}


static gboolean gxml_xdocument_real_save_as (GXmlDocument* base, GFile* f, GCancellable* cancellable, GError** error) {
	GXmlxDocument * self;
	gboolean result = FALSE;
	GFileOutputStream* ostream = NULL;
	GFile* _tmp0_ = NULL;
	gboolean _tmp1_ = FALSE;
	gboolean _tmp2_ = FALSE;
	GCancellable* _tmp3_ = NULL;
	GFileOutputStream* _tmp4_ = NULL;
	GFileOutputStream* _tmp5_ = NULL;
	GError * _inner_error_ = NULL;
	self = (GXmlxDocument*) base;
	g_return_val_if_fail (f != NULL, FALSE);
	_tmp0_ = f;
	_tmp1_ = gxml_document_get_backup ((GXmlDocument*) self);
	_tmp2_ = _tmp1_;
	_tmp3_ = cancellable;
	_tmp4_ = g_file_replace (_tmp0_, NULL, _tmp2_, G_FILE_CREATE_NONE, _tmp3_, &_inner_error_);
	ostream = _tmp4_;
	if (G_UNLIKELY (_inner_error_ != NULL)) {
		g_propagate_error (error, _inner_error_);
		return FALSE;
	}
	_tmp5_ = ostream;
	gxml_xdocument_save_to_stream (self, (GOutputStream*) _tmp5_, NULL, &_inner_error_);
	if (G_UNLIKELY (_inner_error_ != NULL)) {
		g_propagate_error (error, _inner_error_);
		_g_object_unref0 (ostream);
		return FALSE;
	}
	result = TRUE;
	_g_object_unref0 (ostream);
	return result;
}


static const gchar* gxml_xdocument_real_get_node_name (GXmlxNode* base) {
	const gchar* result;
	GXmlxDocument* self;
	self = (GXmlxDocument*) base;
	result = "#document";
	return result;
}


static void gxml_xdocument_real_set_node_name (GXmlxNode* base, const gchar* value) {
	GXmlxDocument* self;
	self = (GXmlxDocument*) base;
	g_object_notify ((GObject *) self, "node-name");
}


GXmlxDocumentType* gxml_xdocument_get_doctype (GXmlxDocument* self) {
	GXmlxDocumentType* result;
	GXmlxDocumentType* _tmp0_ = NULL;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_doctype;
	result = _tmp0_;
	return result;
}


static void gxml_xdocument_set_doctype (GXmlxDocument* self, GXmlxDocumentType* value) {
	GXmlxDocumentType* _tmp0_ = NULL;
	GXmlxDocumentType* _tmp1_ = NULL;
	g_return_if_fail (self != NULL);
	_tmp0_ = value;
	_tmp1_ = _g_object_ref0 (_tmp0_);
	_g_object_unref0 (self->priv->_doctype);
	self->priv->_doctype = _tmp1_;
	g_object_notify ((GObject *) self, "doctype");
}


GXmlImplementation* gxml_xdocument_get_implementation (GXmlxDocument* self) {
	GXmlImplementation* result;
	GXmlImplementation* _tmp0_ = NULL;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_implementation;
	result = _tmp0_;
	return result;
}


static void gxml_xdocument_set_implementation (GXmlxDocument* self, GXmlImplementation* value) {
	GXmlImplementation* _tmp0_ = NULL;
	GXmlImplementation* _tmp1_ = NULL;
	g_return_if_fail (self != NULL);
	_tmp0_ = value;
	_tmp1_ = _g_object_ref0 (_tmp0_);
	_g_object_unref0 (self->priv->_implementation);
	self->priv->_implementation = _tmp1_;
	g_object_notify ((GObject *) self, "implementation");
}


GXmlxElement* gxml_xdocument_get_document_element (GXmlxDocument* self) {
	GXmlxElement* result;
	xmlDoc* _tmp0_ = NULL;
	xmlNode* _tmp1_ = NULL;
	GXmlxNode* _tmp2_ = NULL;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->xmldoc;
	_tmp1_ = xmlDocGetRootElement (_tmp0_);
	_tmp2_ = gxml_xdocument_lookup_node (self, _tmp1_);
	result = G_TYPE_CHECK_INSTANCE_CAST (_tmp2_, GXML_TYPE_XELEMENT, GXmlxElement);
	return result;
}


static void gxml_xdocument_set_document_element (GXmlxDocument* self, GXmlxElement* value) {
	g_return_if_fail (self != NULL);
	g_object_notify ((GObject *) self, "document-element");
}


static GXmlxNodeList* gxml_xdocument_real_get_child_nodes (GXmlxNode* base) {
	GXmlxNodeList* result;
	GXmlxDocument* self;
	GXmlNodeChildNodeList* _tmp0_ = NULL;
	self = (GXmlxDocument*) base;
	_tmp0_ = self->_node_list;
	result = (GXmlxNodeList*) _tmp0_;
	return result;
}


static void gxml_xdocument_real_set_child_nodes (GXmlxNode* base, GXmlxNodeList* value) {
	GXmlxDocument* self;
	self = (GXmlxDocument*) base;
	g_object_notify ((GObject *) self, "child-nodes");
}


static gboolean gxml_xdocument_real_get_indent (GXmlDocument* base) {
	gboolean result;
	GXmlxDocument* self;
	gboolean _tmp0_ = FALSE;
	self = (GXmlxDocument*) base;
	_tmp0_ = self->priv->_indent;
	result = _tmp0_;
	return result;
}


static void gxml_xdocument_real_set_indent (GXmlDocument* base, gboolean value) {
	GXmlxDocument* self;
	gboolean _tmp0_ = FALSE;
	self = (GXmlxDocument*) base;
	_tmp0_ = value;
	self->priv->_indent = _tmp0_;
	g_object_notify ((GObject *) self, "indent");
}


static gboolean gxml_xdocument_real_get_ns_top (GXmlDocument* base) {
	gboolean result;
	GXmlxDocument* self;
	gboolean _tmp0_ = FALSE;
	self = (GXmlxDocument*) base;
	_tmp0_ = self->priv->_ns_top;
	result = _tmp0_;
	return result;
}


static void gxml_xdocument_real_set_ns_top (GXmlDocument* base, gboolean value) {
	GXmlxDocument* self;
	gboolean _tmp0_ = FALSE;
	self = (GXmlxDocument*) base;
	_tmp0_ = value;
	self->priv->_ns_top = _tmp0_;
	g_object_notify ((GObject *) self, "ns-top");
}


static gboolean gxml_xdocument_real_get_prefix_default_ns (GXmlDocument* base) {
	gboolean result;
	GXmlxDocument* self;
	gboolean _tmp0_ = FALSE;
	self = (GXmlxDocument*) base;
	_tmp0_ = self->priv->_prefix_default_ns;
	result = _tmp0_;
	return result;
}


static void gxml_xdocument_real_set_prefix_default_ns (GXmlDocument* base, gboolean value) {
	GXmlxDocument* self;
	gboolean _tmp0_ = FALSE;
	self = (GXmlxDocument*) base;
	_tmp0_ = value;
	self->priv->_prefix_default_ns = _tmp0_;
	g_object_notify ((GObject *) self, "prefix-default-ns");
}


static gboolean gxml_xdocument_real_get_backup (GXmlDocument* base) {
	gboolean result;
	GXmlxDocument* self;
	gboolean _tmp0_ = FALSE;
	self = (GXmlxDocument*) base;
	_tmp0_ = self->priv->_backup;
	result = _tmp0_;
	return result;
}


static void gxml_xdocument_real_set_backup (GXmlDocument* base, gboolean value) {
	GXmlxDocument* self;
	gboolean _tmp0_ = FALSE;
	self = (GXmlxDocument*) base;
	_tmp0_ = value;
	self->priv->_backup = _tmp0_;
	g_object_notify ((GObject *) self, "backup");
}


static GFile* gxml_xdocument_real_get_file (GXmlDocument* base) {
	GFile* result;
	GXmlxDocument* self;
	GFile* _tmp0_ = NULL;
	self = (GXmlxDocument*) base;
	_tmp0_ = self->priv->_file;
	result = _tmp0_;
	return result;
}


static void gxml_xdocument_real_set_file (GXmlDocument* base, GFile* value) {
	GXmlxDocument* self;
	GFile* _tmp0_ = NULL;
	GFile* _tmp1_ = NULL;
	self = (GXmlxDocument*) base;
	_tmp0_ = value;
	_tmp1_ = _g_object_ref0 (_tmp0_);
	_g_object_unref0 (self->priv->_file);
	self->priv->_file = _tmp1_;
	g_object_notify ((GObject *) self, "file");
}


GXmlNode* gxml_xdocument_get_root (GXmlxDocument* self) {
	g_return_val_if_fail (self != NULL, NULL);
	return GXML_XDOCUMENT_GET_CLASS (self)->get_root (self);
}


static GXmlNode* gxml_xdocument_real_get_root (GXmlxDocument* base) {
	GXmlNode* result;
	GXmlxDocument* self;
	GXmlxElement* _tmp0_ = NULL;
	GXmlxElement* _tmp1_ = NULL;
	GObject* _tmp2_ = NULL;
	GXmlNode* _tmp3_ = NULL;
	self = base;
	_tmp0_ = gxml_xdocument_get_document_element (self);
	_tmp1_ = _tmp0_;
	_tmp2_ = g_object_ref ((GObject*) _tmp1_);
	_tmp3_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp2_, GXML_TYPE_NODE, GXmlNode));
	result = _tmp3_;
	return result;
}


static void gxml_xdocument_class_init (GXmlxDocumentClass * klass) {
	gxml_xdocument_parent_class = g_type_class_peek_parent (klass);
	g_type_class_add_private (klass, sizeof (GXmlxDocumentPrivate));
	((GXmlxNodeClass *) klass)->stringify = gxml_xdocument_real_stringify;
	((GXmlxNodeClass *) klass)->replace_child = gxml_xdocument_real_replace_child;
	((GXmlxNodeClass *) klass)->remove_child = gxml_xdocument_real_remove_child;
	((GXmlxNodeClass *) klass)->insert_before = gxml_xdocument_real_insert_before;
	((GXmlxNodeClass *) klass)->append_child = gxml_xdocument_real_append_child;
	((GXmlxNodeClass *) klass)->has_child_nodes = gxml_xdocument_real_has_child_nodes;
	GXML_XNODE_CLASS (klass)->get_node_name = gxml_xdocument_real_get_node_name;
	GXML_XNODE_CLASS (klass)->set_node_name = gxml_xdocument_real_set_node_name;
	GXML_XNODE_CLASS (klass)->get_child_nodes = gxml_xdocument_real_get_child_nodes;
	GXML_XNODE_CLASS (klass)->set_child_nodes = gxml_xdocument_real_set_child_nodes;
	GXML_XDOCUMENT_CLASS (klass)->get_root = gxml_xdocument_real_get_root;
	G_OBJECT_CLASS (klass)->get_property = _vala_gxml_xdocument_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_gxml_xdocument_set_property;
	G_OBJECT_CLASS (klass)->finalize = gxml_xdocument_finalize;
	/**
	 * Provides the name for this node. For documents, it is always "#document".
	 */
	g_object_class_install_property (G_OBJECT_CLASS (klass), GXML_XDOCUMENT_NODE_NAME, g_param_spec_string ("node-name", "node-name", "node-name", NULL, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE));
	/**
	 * The xDocument Type Definition (DTD) defining this document. This may be %NULL.
	 *
	 * Version: DOM Level 1 Core<<BR>>
	 * URL: [[http://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html#attribute-doctype]]
	 */
	g_object_class_install_property (G_OBJECT_CLASS (klass), GXML_XDOCUMENT_DOCTYPE, g_param_spec_object ("doctype", "doctype", "doctype", GXML_TYPE_XDOCUMENT_TYPE, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE));
	/**
	 * Describes the features of the DOM implementation behind this document.
	 *
	 * Version: DOM Level 1 Core<<BR>>
	 * URL: [[http://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html#attribute-implementation]]
	 */
	g_object_class_install_property (G_OBJECT_CLASS (klass), GXML_XDOCUMENT_IMPLEMENTATION, g_param_spec_object ("implementation", "implementation", "implementation", GXML_TYPE_IMPLEMENTATION, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE));
	/**
	 * The root node of the document's node tree.
	 *
	 * Version: DOM Level 1 Core<<BR>>
	 * URL: [[http://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html#attribute-documentElement]]
	 */
	g_object_class_install_property (G_OBJECT_CLASS (klass), GXML_XDOCUMENT_DOCUMENT_ELEMENT, g_param_spec_object ("document-element", "document-element", "document-element", GXML_TYPE_XELEMENT, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE));
	/**
	 * {@inheritDoc}
	 */
	g_object_class_install_property (G_OBJECT_CLASS (klass), GXML_XDOCUMENT_CHILD_NODES, g_param_spec_object ("child-nodes", "child-nodes", "child-nodes", GXML_TYPE_XNODE_LIST, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GXML_XDOCUMENT_INDENT, g_param_spec_boolean ("indent", "indent", "indent", FALSE, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GXML_XDOCUMENT_NS_TOP, g_param_spec_boolean ("ns-top", "ns-top", "ns-top", FALSE, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GXML_XDOCUMENT_PREFIX_DEFAULT_NS, g_param_spec_boolean ("prefix-default-ns", "prefix-default-ns", "prefix-default-ns", FALSE, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GXML_XDOCUMENT_BACKUP, g_param_spec_boolean ("backup", "backup", "backup", TRUE, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GXML_XDOCUMENT_FILE, g_param_spec_object ("file", "file", "file", G_TYPE_FILE, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GXML_XDOCUMENT_ROOT, g_param_spec_object ("root", "root", "root", GXML_TYPE_NODE, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE));
}


static void gxml_xdocument_gxml_document_interface_init (GXmlDocumentIface * iface) {
	gxml_xdocument_gxml_document_parent_iface = g_type_interface_peek_parent (iface);
	iface->create_element = (GXmlNode* (*)(GXmlDocument*, const gchar*, GError**)) gxml_xdocument_real_create_element;
	iface->create_text = (GXmlNode* (*)(GXmlDocument*, const gchar*)) gxml_xdocument_real_create_text;
	iface->create_comment = (GXmlNode* (*)(GXmlDocument*, const gchar*)) gxml_xdocument_real_create_comment;
	iface->create_cdata = (GXmlNode* (*)(GXmlDocument*, const gchar*)) gxml_xdocument_real_create_cdata;
	iface->create_pi = (GXmlNode* (*)(GXmlDocument*, const gchar*, const gchar*)) gxml_xdocument_real_create_pi;
	iface->save = (gboolean (*)(GXmlDocument*, GCancellable*, GError**)) gxml_xdocument_real_save;
	iface->save_as = (gboolean (*)(GXmlDocument*, GFile*, GCancellable*, GError**)) gxml_xdocument_real_save_as;
	iface->get_indent = gxml_xdocument_real_get_indent;
	iface->set_indent = gxml_xdocument_real_set_indent;
	iface->get_ns_top = gxml_xdocument_real_get_ns_top;
	iface->set_ns_top = gxml_xdocument_real_set_ns_top;
	iface->get_prefix_default_ns = gxml_xdocument_real_get_prefix_default_ns;
	iface->set_prefix_default_ns = gxml_xdocument_real_set_prefix_default_ns;
	iface->get_backup = gxml_xdocument_real_get_backup;
	iface->set_backup = gxml_xdocument_real_set_backup;
	iface->get_file = gxml_xdocument_real_get_file;
	iface->set_file = gxml_xdocument_real_set_file;
	iface->get_root = (GXmlNode* (*) (GXmlDocument *)) gxml_xdocument_get_root;
}


static void gxml_xdocument_instance_init (GXmlxDocument * self) {
	GHashFunc _tmp0_ = NULL;
	GEqualFunc _tmp1_ = NULL;
	GHashTable* _tmp2_ = NULL;
	self->priv = GXML_XDOCUMENT_GET_PRIVATE (self);
	_tmp0_ = g_direct_hash;
	_tmp1_ = g_direct_equal;
	_tmp2_ = g_hash_table_new_full (_tmp0_, _tmp1_, NULL, _g_object_unref0_);
	self->node_dict = _tmp2_;
	self->dirty_elements = NULL;
	self->priv->nodes_to_free = NULL;
	self->priv->new_nodes = NULL;
	self->priv->_indent = FALSE;
	self->priv->_ns_top = FALSE;
	self->priv->_prefix_default_ns = FALSE;
	self->priv->_backup = TRUE;
}


static void gxml_xdocument_finalize (GObject* obj) {
	GXmlxDocument * self;
	GList* to_free = NULL;
	GList* _tmp0_ = NULL;
	GList* _tmp4_ = NULL;
	xmlDoc* _tmp6_ = NULL;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GXML_TYPE_XDOCUMENT, GXmlxDocument);
	to_free = NULL;
	_tmp0_ = self->priv->new_nodes;
	{
		GList* new_node_collection = NULL;
		GList* new_node_it = NULL;
		new_node_collection = _tmp0_;
		for (new_node_it = new_node_collection; new_node_it != NULL; new_node_it = new_node_it->next) {
			xmlNode* new_node = NULL;
			new_node = new_node_it->data;
			{
				xmlNode* _tmp1_ = NULL;
				xmlNode* _tmp2_ = NULL;
				_tmp1_ = new_node;
				_tmp2_ = _tmp1_->parent;
				if (_tmp2_ == NULL) {
					xmlNode* _tmp3_ = NULL;
					_tmp3_ = new_node;
					to_free = g_list_append (to_free, _tmp3_);
				}
			}
		}
	}
	_tmp4_ = to_free;
	{
		GList* freeable_collection = NULL;
		GList* freeable_it = NULL;
		freeable_collection = _tmp4_;
		for (freeable_it = freeable_collection; freeable_it != NULL; freeable_it = freeable_it->next) {
			xmlNode* freeable = NULL;
			freeable = freeable_it->data;
			{
				xmlNode* _tmp5_ = NULL;
				_tmp5_ = freeable;
				xmlFreeNode (_tmp5_);
			}
		}
	}
	_tmp6_ = self->xmldoc;
	xmlFreeDoc (_tmp6_);
	_g_list_free0 (to_free);
	_g_hash_table_unref0 (self->node_dict);
	__g_list_free__g_object_unref0_0 (self->dirty_elements);
	_g_object_unref0 (self->_node_list);
	_g_object_unref0 (self->priv->_doctype);
	_g_object_unref0 (self->priv->_implementation);
	__g_list_free__g_object_unref0_0 (self->priv->nodes_to_free);
	_g_list_free0 (self->priv->new_nodes);
	_g_object_unref0 (self->priv->_file);
	G_OBJECT_CLASS (gxml_xdocument_parent_class)->finalize (obj);
}


/**
 * Represents an XML xDocument as a tree of {@link GXml.xNode}s.
 *
 * The xDocument has a root document element {@link GXml.xElement}.
 * A xDocument's schema can be defined through its
 * {@link GXml.xDocumentType}.
 *
 * Version: DOM Level 1 Core<<BR>>
 * URL: [[http://www.w3.org/TR/DOM-Level-1/level-one-core.html#i-xDocument]]
 */
GType gxml_xdocument_get_type (void) {
	static volatile gsize gxml_xdocument_type_id__volatile = 0;
	if (g_once_init_enter (&gxml_xdocument_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (GXmlxDocumentClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) gxml_xdocument_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GXmlxDocument), 0, (GInstanceInitFunc) gxml_xdocument_instance_init, NULL };
		static const GInterfaceInfo gxml_document_info = { (GInterfaceInitFunc) gxml_xdocument_gxml_document_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
		GType gxml_xdocument_type_id;
		gxml_xdocument_type_id = g_type_register_static (GXML_TYPE_XNODE, "GXmlxDocument", &g_define_type_info, 0);
		g_type_add_interface_static (gxml_xdocument_type_id, GXML_TYPE_DOCUMENT, &gxml_document_info);
		g_once_init_leave (&gxml_xdocument_type_id__volatile, gxml_xdocument_type_id);
	}
	return gxml_xdocument_type_id__volatile;
}


static void _vala_gxml_xdocument_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec) {
	GXmlxDocument * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, GXML_TYPE_XDOCUMENT, GXmlxDocument);
	switch (property_id) {
		case GXML_XDOCUMENT_NODE_NAME:
		g_value_set_string (value, gxml_xnode_get_node_name ((GXmlxNode*) self));
		break;
		case GXML_XDOCUMENT_DOCTYPE:
		g_value_set_object (value, gxml_xdocument_get_doctype (self));
		break;
		case GXML_XDOCUMENT_IMPLEMENTATION:
		g_value_set_object (value, gxml_xdocument_get_implementation (self));
		break;
		case GXML_XDOCUMENT_DOCUMENT_ELEMENT:
		g_value_set_object (value, gxml_xdocument_get_document_element (self));
		break;
		case GXML_XDOCUMENT_CHILD_NODES:
		g_value_set_object (value, gxml_xnode_get_child_nodes ((GXmlxNode*) self));
		break;
		case GXML_XDOCUMENT_INDENT:
		g_value_set_boolean (value, gxml_document_get_indent ((GXmlDocument*) self));
		break;
		case GXML_XDOCUMENT_NS_TOP:
		g_value_set_boolean (value, gxml_document_get_ns_top ((GXmlDocument*) self));
		break;
		case GXML_XDOCUMENT_PREFIX_DEFAULT_NS:
		g_value_set_boolean (value, gxml_document_get_prefix_default_ns ((GXmlDocument*) self));
		break;
		case GXML_XDOCUMENT_BACKUP:
		g_value_set_boolean (value, gxml_document_get_backup ((GXmlDocument*) self));
		break;
		case GXML_XDOCUMENT_FILE:
		g_value_set_object (value, gxml_document_get_file ((GXmlDocument*) self));
		break;
		case GXML_XDOCUMENT_ROOT:
		g_value_take_object (value, gxml_xdocument_get_root (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}


static void _vala_gxml_xdocument_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec) {
	GXmlxDocument * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, GXML_TYPE_XDOCUMENT, GXmlxDocument);
	switch (property_id) {
		case GXML_XDOCUMENT_NODE_NAME:
		gxml_xnode_set_node_name ((GXmlxNode*) self, g_value_get_string (value));
		break;
		case GXML_XDOCUMENT_DOCTYPE:
		gxml_xdocument_set_doctype (self, g_value_get_object (value));
		break;
		case GXML_XDOCUMENT_IMPLEMENTATION:
		gxml_xdocument_set_implementation (self, g_value_get_object (value));
		break;
		case GXML_XDOCUMENT_DOCUMENT_ELEMENT:
		gxml_xdocument_set_document_element (self, g_value_get_object (value));
		break;
		case GXML_XDOCUMENT_CHILD_NODES:
		gxml_xnode_set_child_nodes ((GXmlxNode*) self, g_value_get_object (value));
		break;
		case GXML_XDOCUMENT_INDENT:
		gxml_document_set_indent ((GXmlDocument*) self, g_value_get_boolean (value));
		break;
		case GXML_XDOCUMENT_NS_TOP:
		gxml_document_set_ns_top ((GXmlDocument*) self, g_value_get_boolean (value));
		break;
		case GXML_XDOCUMENT_PREFIX_DEFAULT_NS:
		gxml_document_set_prefix_default_ns ((GXmlDocument*) self, g_value_get_boolean (value));
		break;
		case GXML_XDOCUMENT_BACKUP:
		gxml_document_set_backup ((GXmlDocument*) self, g_value_get_boolean (value));
		break;
		case GXML_XDOCUMENT_FILE:
		gxml_document_set_file ((GXmlDocument*) self, g_value_get_object (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}



