/* XDocument.c generated by valac 0.56.19, the Vala compiler
 * generated from XDocument.vala, do not modify */

/* -*- Mode: vala; indent-tabs-mode: nil; c-basic-offset: 2; tab-width: 2 -*- */
/* XDocument.vala
 *
 * Copyright (C) 2016-2019  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:
 *      Daniel Espinosa <esodan@gmail.com>
 */

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

#if !defined(VALA_STRICT_C)
#if !defined(__clang__) && defined(__GNUC__) && (__GNUC__ >= 14)
#pragma GCC diagnostic warning "-Wincompatible-pointer-types"
#elif defined(__clang__) && (__clang_major__ >= 16)
#pragma clang diagnostic ignored "-Wincompatible-function-pointer-types"
#pragma clang diagnostic ignored "-Wincompatible-pointer-types"
#endif
#endif

enum  {
	GXML_XDOCUMENT_0_PROPERTY,
	GXML_XDOCUMENT_ATTRS_PROPERTY,
	GXML_XDOCUMENT_CHILDREN_NODES_PROPERTY,
	GXML_XDOCUMENT_DOCUMENT_PROPERTY,
	GXML_XDOCUMENT_INDENT_PROPERTY,
	GXML_XDOCUMENT_NS_TOP_PROPERTY,
	GXML_XDOCUMENT_PREFIX_DEFAULT_NS_PROPERTY,
	GXML_XDOCUMENT_BACKUP_PROPERTY,
	GXML_XDOCUMENT_FILE_PROPERTY,
	GXML_XDOCUMENT_ROOT_PROPERTY,
	GXML_XDOCUMENT_IMPLEMENTATION_PROPERTY,
	GXML_XDOCUMENT_URL_PROPERTY,
	GXML_XDOCUMENT_DOCUMENT_URI_PROPERTY,
	GXML_XDOCUMENT_ORIGIN_PROPERTY,
	GXML_XDOCUMENT_COMPAT_MODE_PROPERTY,
	GXML_XDOCUMENT_CHARACTER_SET_PROPERTY,
	GXML_XDOCUMENT_CONTENT_TYPE_PROPERTY,
	GXML_XDOCUMENT_DOCTYPE_PROPERTY,
	GXML_XDOCUMENT_DOCUMENT_ELEMENT_PROPERTY,
	GXML_XDOCUMENT_CHILDREN_PROPERTY,
	GXML_XDOCUMENT_FIRST_ELEMENT_CHILD_PROPERTY,
	GXML_XDOCUMENT_LAST_ELEMENT_CHILD_PROPERTY,
	GXML_XDOCUMENT_CHILD_ELEMENT_COUNT_PROPERTY,
	GXML_XDOCUMENT_NUM_PROPERTIES
};
static GParamSpec* gxml_xdocument_properties[GXML_XDOCUMENT_NUM_PROPERTIES];
#define _xmlFreeDoc0(var) ((var == NULL) ? NULL : (var = (xmlFreeDoc (var), NULL)))
#define _xmlBufferFree0(var) ((var == NULL) ? NULL : (var = (xmlBufferFree (var), NULL)))
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

#define GXML_TYPE_XD_PARSER (gxml_xd_parser_get_type ())
#define GXML_XD_PARSER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GXML_TYPE_XD_PARSER, GXmlXdParser))
#define GXML_XD_PARSER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GXML_TYPE_XD_PARSER, GXmlXdParserClass))
#define GXML_IS_XD_PARSER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GXML_TYPE_XD_PARSER))
#define GXML_IS_XD_PARSER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GXML_TYPE_XD_PARSER))
#define GXML_XD_PARSER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GXML_TYPE_XD_PARSER, GXmlXdParserClass))

typedef struct _GXmlXdParser GXmlXdParser;
typedef struct _GXmlXdParserClass GXmlXdParserClass;
#define _g_free0(var) (var = (g_free (var), NULL))
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))

#define GXML_TYPE_XIMPLEMENTATION (gxml_ximplementation_get_type ())
#define GXML_XIMPLEMENTATION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GXML_TYPE_XIMPLEMENTATION, GXmlXImplementation))
#define GXML_XIMPLEMENTATION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GXML_TYPE_XIMPLEMENTATION, GXmlXImplementationClass))
#define GXML_IS_XIMPLEMENTATION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GXML_TYPE_XIMPLEMENTATION))
#define GXML_IS_XIMPLEMENTATION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GXML_TYPE_XIMPLEMENTATION))
#define GXML_XIMPLEMENTATION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GXML_TYPE_XIMPLEMENTATION, GXmlXImplementationClass))

typedef struct _GXmlXImplementation GXmlXImplementation;
typedef struct _GXmlXImplementationClass GXmlXImplementationClass;

#define GXML_TYPE_XDOCUMENT_FRAGMENT (gxml_xdocument_fragment_get_type ())
#define GXML_XDOCUMENT_FRAGMENT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GXML_TYPE_XDOCUMENT_FRAGMENT, GXmlXDocumentFragment))
#define GXML_XDOCUMENT_FRAGMENT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GXML_TYPE_XDOCUMENT_FRAGMENT, GXmlXDocumentFragmentClass))
#define GXML_IS_XDOCUMENT_FRAGMENT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GXML_TYPE_XDOCUMENT_FRAGMENT))
#define GXML_IS_XDOCUMENT_FRAGMENT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GXML_TYPE_XDOCUMENT_FRAGMENT))
#define GXML_XDOCUMENT_FRAGMENT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GXML_TYPE_XDOCUMENT_FRAGMENT, GXmlXDocumentFragmentClass))

typedef struct _GXmlXDocumentFragment GXmlXDocumentFragment;
typedef struct _GXmlXDocumentFragmentClass GXmlXDocumentFragmentClass;
typedef struct _GXmlXImplementationPrivate GXmlXImplementationPrivate;
enum  {
	GXML_XIMPLEMENTATION_0_PROPERTY,
	GXML_XIMPLEMENTATION_NUM_PROPERTIES
};
static GParamSpec* gxml_ximplementation_properties[GXML_XIMPLEMENTATION_NUM_PROPERTIES];

#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;
typedef struct _GXmlXDocumentTypePrivate GXmlXDocumentTypePrivate;
enum  {
	GXML_XDOCUMENT_TYPE_0_PROPERTY,
	GXML_XDOCUMENT_TYPE_NAME_PROPERTY,
	GXML_XDOCUMENT_TYPE_PUBLIC_ID_PROPERTY,
	GXML_XDOCUMENT_TYPE_SYSTEM_ID_PROPERTY,
	GXML_XDOCUMENT_TYPE_NUM_PROPERTIES
};
static GParamSpec* gxml_xdocument_type_properties[GXML_XDOCUMENT_TYPE_NUM_PROPERTIES];
typedef struct _GXmlXDocumentFragmentPrivate GXmlXDocumentFragmentPrivate;
enum  {
	GXML_XDOCUMENT_FRAGMENT_0_PROPERTY,
	GXML_XDOCUMENT_FRAGMENT_NUM_PROPERTIES
};
static GParamSpec* gxml_xdocument_fragment_properties[GXML_XDOCUMENT_FRAGMENT_NUM_PROPERTIES];

struct _GXmlXDocumentPrivate {
	gboolean _indent;
	gboolean _ns_top;
	gboolean _prefix_default_ns;
	gboolean _backup;
	GFile* _file;
};

struct _GXmlXImplementation {
	GObject parent_instance;
	GXmlXImplementationPrivate * priv;
};

struct _GXmlXImplementationClass {
	GObjectClass parent_class;
};

struct _GXmlXDocumentType {
	GXmlXChildNode parent_instance;
	gchar* _name;
	gchar* _public_id;
	gchar* _system_id;
	GXmlXDocumentTypePrivate * priv;
};

struct _GXmlXDocumentTypeClass {
	GXmlXChildNodeClass parent_class;
};

struct _GXmlXDocumentFragment {
	GXmlXDocument parent_instance;
	GXmlXDocumentFragmentPrivate * priv;
};

struct _GXmlXDocumentFragmentClass {
	GXmlXDocumentClass parent_class;
};

static gint GXmlXDocument_private_offset;
static gpointer gxml_xdocument_parent_class = NULL;
static GXmlDomParentNodeIface * gxml_xdocument_gxml_dom_parent_node_parent_iface = NULL;
static GXmlDomNonElementParentNodeIface * gxml_xdocument_gxml_dom_non_element_parent_node_parent_iface = NULL;
static GXmlDomDocumentIface * gxml_xdocument_gxml_dom_document_parent_iface = NULL;
static GXmlDomXMLDocumentIface * gxml_xdocument_gxml_dom_xml_document_parent_iface = NULL;
static GXmlXPathContextIface * gxml_xdocument_gxml_xpath_context_parent_iface = NULL;
static gpointer gxml_ximplementation_parent_class = NULL;
static GXmlDomImplementationIface * gxml_ximplementation_gxml_dom_implementation_parent_iface = NULL;
static gpointer gxml_xdocument_type_parent_class = NULL;
static GXmlDomNodeIface * gxml_xdocument_type_gxml_dom_node_parent_iface = NULL;
static GXmlDomChildNodeIface * gxml_xdocument_type_gxml_dom_child_node_parent_iface = NULL;
static GXmlDomDocumentTypeIface * gxml_xdocument_type_gxml_dom_document_type_parent_iface = NULL;
static gpointer gxml_xdocument_fragment_parent_class = NULL;
static GXmlDomDocumentFragmentIface * gxml_xdocument_fragment_gxml_dom_document_fragment_parent_iface = NULL;

VALA_EXTERN GType gxml_xd_parser_get_type (void) G_GNUC_CONST ;
VALA_EXTERN GXmlXdParser* gxml_xd_parser_new (GXmlXDocument* doc);
VALA_EXTERN GXmlXdParser* gxml_xd_parser_construct (GType object_type,
                                        GXmlXDocument* doc);
static GXmlParser* gxml_xdocument_real_gxml_dom_document_get_xml_parser (GXmlDomDocument* base);
static void gxml_xdocument_real_set_xml_parser (GXmlDomDocument* base,
                                         GXmlParser* parser);
static gboolean gxml_xdocument_real_set_namespace (GXmlXNode* base,
                                            const gchar* uri,
                                            const gchar* prefix);
VALA_EXTERN void gxml_xnode_take_node (GXmlXNode* self);
static gchar* gxml_xdocument_real_to_string (GXmlXNode* base);
static gboolean gxml_xdocument_real_save (GXmlXDocument* self,
                                   GCancellable* cancellable,
                                   GError** error);
static gboolean gxml_xdocument_real_save_as (GXmlXDocument* self,
                                      GFile* f,
                                      GCancellable* cancellable,
                                      GError** error);
VALA_EXTERN GXmlXImplementation* gxml_ximplementation_new (void);
VALA_EXTERN GXmlXImplementation* gxml_ximplementation_construct (GType object_type);
VALA_EXTERN GType gxml_ximplementation_get_type (void) G_GNUC_CONST ;
static GXmlDomElement* gxml_xdocument_real_gxml_dom_document_create_element (GXmlDomDocument* base,
                                                                      const gchar* local_name,
                                                                      GError** error);
VALA_EXTERN gchar* gxml_xnode_libxml2_error_to_string (xmlError* e);
static GXmlDomElement* gxml_xdocument_real_gxml_dom_document_create_element_ns (GXmlDomDocument* base,
                                                                         const gchar* ns,
                                                                         const gchar* qualified_name,
                                                                         GError** error);
static GXmlDomHTMLCollection* gxml_xdocument_real_get_elements_by_tag_name (GXmlDomDocument* base,
                                                                     const gchar* local_name);
static GXmlDomHTMLCollection* gxml_xdocument_real_get_elements_by_tag_name_ns (GXmlDomDocument* base,
                                                                        const gchar* ns,
                                                                        const gchar* local_name);
static GXmlDomHTMLCollection* gxml_xdocument_real_get_elements_by_class_name (GXmlDomDocument* base,
                                                                       const gchar* class_names);
static GXmlDomDocumentFragment* gxml_xdocument_real_create_document_fragment (GXmlDomDocument* base);
VALA_EXTERN GXmlXDocumentFragment* gxml_xdocument_fragment_new (GXmlXDocument* d);
VALA_EXTERN GXmlXDocumentFragment* gxml_xdocument_fragment_construct (GType object_type,
                                                          GXmlXDocument* d);
VALA_EXTERN GType gxml_xdocument_fragment_get_type (void) G_GNUC_CONST ;
static GXmlDomText* gxml_xdocument_real_create_text_node (GXmlDomDocument* base,
                                                   const gchar* data,
                                                   GError** error);
static GXmlDomComment* gxml_xdocument_real_gxml_dom_document_create_comment (GXmlDomDocument* base,
                                                                      const gchar* data,
                                                                      GError** error);
static GXmlDomProcessingInstruction* gxml_xdocument_real_create_processing_instruction (GXmlDomDocument* base,
                                                                                 const gchar* target,
                                                                                 const gchar* data,
                                                                                 GError** error);
static GXmlDomNode* gxml_xdocument_real_import_node (GXmlDomDocument* base,
                                              GXmlDomNode* node,
                                              gboolean deep,
                                              GError** error);
static GXmlDomNode* gxml_xdocument_real_adopt_node (GXmlDomDocument* base,
                                             GXmlDomNode* node,
                                             GError** error);
static GXmlDomEvent* gxml_xdocument_real_create_event (GXmlDomDocument* base,
                                                const gchar* iface,
                                                GError** error);
static GXmlDomRange* gxml_xdocument_real_create_range (GXmlDomDocument* base);
static GXmlDomNodeIterator* gxml_xdocument_real_create_node_iterator (GXmlDomDocument* base,
                                                               GXmlDomNode* root,
                                                               gint what_to_show);
static GXmlDomTreeWalker* gxml_xdocument_real_create_tree_walker (GXmlDomDocument* base,
                                                           GXmlDomNode* root,
                                                           gint what_to_show);
static GXmlDomNodeList* gxml_xdocument_real_query_selector_all (GXmlDomParentNode* base,
                                                         const gchar* selectors,
                                                         GError** error);
static GXmlDomElement* gxml_xdocument_real_get_element_by_id (GXmlDomNonElementParentNode* base,
                                                       const gchar* element_id,
                                                       GError** error);
static GXmlXPathObject* gxml_xdocument_real_evaluate (GXmlXPathContext* base,
                                               const gchar* expression,
                                               GeeMap* resolver,
                                               GError** error);
static GObject * gxml_xdocument_constructor (GType type,
                                      guint n_construct_properties,
                                      GObjectConstructParam * construct_properties);
static void gxml_xdocument_finalize (GObject * obj);
static GType gxml_xdocument_get_type_once (void);
static void _vala_gxml_xdocument_get_property (GObject * object,
                                        guint property_id,
                                        GValue * value,
                                        GParamSpec * pspec);
static void _vala_gxml_xdocument_set_property (GObject * object,
                                        guint property_id,
                                        const GValue * value,
                                        GParamSpec * pspec);
static GXmlDomDocumentType* gxml_ximplementation_real_create_document_type (GXmlDomImplementation* base,
                                                                     const gchar* qualified_name,
                                                                     const gchar* public_id,
                                                                     const gchar* system_id,
                                                                     GError** error);
VALA_EXTERN GXmlXDocumentType* gxml_xdocument_type_new_with_ids (const gchar* name,
                                                     const gchar* public_id,
                                                     const gchar* system_id);
VALA_EXTERN GXmlXDocumentType* gxml_xdocument_type_construct_with_ids (GType object_type,
                                                           const gchar* name,
                                                           const gchar* public_id,
                                                           const gchar* system_id);
VALA_EXTERN GType gxml_xdocument_type_get_type (void) G_GNUC_CONST ;
static GXmlDomXMLDocument* gxml_ximplementation_real_create_document (GXmlDomImplementation* base,
                                                               const gchar* namespace,
                                                               const gchar* qualified_name,
                                                               GXmlDomDocumentType* doctype,
                                                               GError** error);
static GXmlDomDocument* gxml_ximplementation_real_create_html_document (GXmlDomImplementation* base,
                                                                 const gchar* title);
static GType gxml_ximplementation_get_type_once (void);
VALA_EXTERN GXmlXDocumentType* gxml_xdocument_type_new_with_name (const gchar* name);
VALA_EXTERN GXmlXDocumentType* gxml_xdocument_type_construct_with_name (GType object_type,
                                                            const gchar* name);
static void gxml_xdocument_type_real_remove (GXmlDomChildNode* base);
VALA_EXTERN GXmlXDocumentType* gxml_xdocument_type_new (void);
VALA_EXTERN GXmlXDocumentType* gxml_xdocument_type_construct (GType object_type);
static void gxml_xdocument_type_finalize (GObject * obj);
static GType gxml_xdocument_type_get_type_once (void);
static void _vala_gxml_xdocument_type_get_property (GObject * object,
                                             guint property_id,
                                             GValue * value,
                                             GParamSpec * pspec);
static GType gxml_xdocument_fragment_get_type_once (void);
static void _vala_array_destroy (gpointer array,
                          gssize array_length,
                          GDestroyNotify destroy_func);
static void _vala_array_free (gpointer array,
                       gssize array_length,
                       GDestroyNotify destroy_func);
static gssize _vala_array_length (gpointer array);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

static inline gpointer
gxml_xdocument_get_instance_private (GXmlXDocument* self)
{
	return G_STRUCT_MEMBER_P (self, GXmlXDocument_private_offset);
}

GXmlXDocument*
gxml_xdocument_construct (GType object_type)
{
	GXmlXDocument * self = NULL;
	xmlDoc* _tmp0_;
	self = (GXmlXDocument*) gxml_xnode_construct (object_type);
	_tmp0_ = xmlNewDoc ((xmlChar*) NULL);
	self->doc = _tmp0_;
	return self;
}

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

GXmlXDocument*
gxml_xdocument_construct_from_path (GType object_type,
                                    const gchar* path,
                                    gint options,
                                    GError** error)
{
	GXmlXDocument * self = NULL;
	GFile* _tmp0_;
	GFile* _tmp1_;
	GError* _inner_error0_ = NULL;
	g_return_val_if_fail (path != NULL, NULL);
	_tmp0_ = g_file_new_for_path (path);
	_tmp1_ = _tmp0_;
	self = (GXmlXDocument*) gxml_xdocument_construct_from_file (object_type, _tmp1_, options, NULL, &_inner_error0_);
	_g_object_unref0 (_tmp1_);
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		g_propagate_error (error, _inner_error0_);
		_g_object_unref0 (self);
		return NULL;
	}
	return self;
}

GXmlXDocument*
gxml_xdocument_new_from_path (const gchar* path,
                              gint options,
                              GError** error)
{
	return gxml_xdocument_construct_from_path (GXML_TYPE_XDOCUMENT, path, options, error);
}

GXmlXDocument*
gxml_xdocument_construct_from_uri (GType object_type,
                                   const gchar* uri,
                                   gint options,
                                   GError** error)
{
	GXmlXDocument * self = NULL;
	GFile* _tmp0_;
	GFile* _tmp1_;
	GError* _inner_error0_ = NULL;
	g_return_val_if_fail (uri != NULL, NULL);
	_tmp0_ = g_file_new_for_uri (uri);
	_tmp1_ = _tmp0_;
	self = (GXmlXDocument*) gxml_xdocument_construct_from_file (object_type, _tmp1_, options, NULL, &_inner_error0_);
	_g_object_unref0 (_tmp1_);
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		g_propagate_error (error, _inner_error0_);
		_g_object_unref0 (self);
		return NULL;
	}
	return self;
}

GXmlXDocument*
gxml_xdocument_new_from_uri (const gchar* uri,
                             gint options,
                             GError** error)
{
	return gxml_xdocument_construct_from_uri (GXML_TYPE_XDOCUMENT, uri, options, error);
}

GXmlXDocument*
gxml_xdocument_construct_from_file (GType object_type,
                                    GFile* file,
                                    gint options,
                                    GCancellable* cancel,
                                    GError** error)
{
	GXmlXDocument * self = NULL;
	GXmlXdParser* parser = NULL;
	GXmlXdParser* _tmp1_;
	GXmlXdParser* _tmp2_;
	GFileInputStream* _tmp3_ = NULL;
	GFileInputStream* _tmp4_;
	GXmlXdParser* _tmp5_;
	GError* _inner_error0_ = NULL;
	g_return_val_if_fail (file != NULL, NULL);
	self = (GXmlXDocument*) gxml_xnode_construct (object_type);
	if (!g_file_query_exists (file, NULL)) {
		GError* _tmp0_;
		_tmp0_ = g_error_new_literal (GXML_DOM_DOCUMENT_ERROR, GXML_DOM_DOCUMENT_ERROR_INVALID_DOCUMENT_ERROR, _ ("File doesn't exist"));
		_inner_error0_ = _tmp0_;
		g_propagate_error (error, _inner_error0_);
		_g_object_unref0 (self);
		return NULL;
	}
	_tmp1_ = gxml_xd_parser_new (self);
	parser = _tmp1_;
	_tmp2_ = parser;
	gxml_parser_set_cancellable ((GXmlParser*) _tmp2_, cancel);
	_tmp4_ = g_file_read (file, NULL, &_inner_error0_);
	_tmp3_ = _tmp4_;
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		g_propagate_error (error, _inner_error0_);
		_g_object_unref0 (parser);
		_g_object_unref0 (self);
		return NULL;
	}
	_tmp5_ = parser;
	gxml_parser_read_stream ((GXmlParser*) _tmp5_, (GInputStream*) _tmp3_, &_inner_error0_);
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		g_propagate_error (error, _inner_error0_);
		_g_object_unref0 (_tmp3_);
		_g_object_unref0 (parser);
		_g_object_unref0 (self);
		return NULL;
	}
	_g_object_unref0 (_tmp3_);
	_g_object_unref0 (parser);
	return self;
}

GXmlXDocument*
gxml_xdocument_new_from_file (GFile* file,
                              gint options,
                              GCancellable* cancel,
                              GError** error)
{
	return gxml_xdocument_construct_from_file (GXML_TYPE_XDOCUMENT, file, options, cancel, error);
}

GXmlXDocument*
gxml_xdocument_construct_from_string (GType object_type,
                                      const gchar* str,
                                      gint options,
                                      GError** error)
{
	GXmlXDocument * self = NULL;
	GXmlXdParser* parser = NULL;
	GXmlXdParser* _tmp0_;
	GError* _inner_error0_ = NULL;
	g_return_val_if_fail (str != NULL, NULL);
	self = (GXmlXDocument*) gxml_xnode_construct (object_type);
	_tmp0_ = gxml_xd_parser_new (self);
	parser = _tmp0_;
	gxml_parser_read_string ((GXmlParser*) parser, str, &_inner_error0_);
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		g_propagate_error (error, _inner_error0_);
		_g_object_unref0 (parser);
		_g_object_unref0 (self);
		return NULL;
	}
	_g_object_unref0 (parser);
	return self;
}

GXmlXDocument*
gxml_xdocument_new_from_string (const gchar* str,
                                gint options,
                                GError** error)
{
	return gxml_xdocument_construct_from_string (GXML_TYPE_XDOCUMENT, str, options, error);
}

GXmlXDocument*
gxml_xdocument_construct_from_stream (GType object_type,
                                      GInputStream* istream,
                                      GError** error)
{
	GXmlXDocument * self = NULL;
	GXmlXdParser* parser = NULL;
	GXmlXdParser* _tmp0_;
	GError* _inner_error0_ = NULL;
	g_return_val_if_fail (istream != NULL, NULL);
	self = (GXmlXDocument*) gxml_xnode_construct (object_type);
	_tmp0_ = gxml_xd_parser_new (self);
	parser = _tmp0_;
	gxml_parser_read_stream ((GXmlParser*) parser, istream, &_inner_error0_);
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		g_propagate_error (error, _inner_error0_);
		_g_object_unref0 (parser);
		_g_object_unref0 (self);
		return NULL;
	}
	_g_object_unref0 (parser);
	return self;
}

GXmlXDocument*
gxml_xdocument_new_from_stream (GInputStream* istream,
                                GError** error)
{
	return gxml_xdocument_construct_from_stream (GXML_TYPE_XDOCUMENT, istream, error);
}

/**
   * Gigen {@link Xml.Doc} is owned by this
   */
GXmlXDocument*
gxml_xdocument_construct_from_doc (GType object_type,
                                   xmlDoc* doc)
{
	GXmlXDocument * self = NULL;
	xmlDoc* _tmp0_;
	g_return_val_if_fail (doc != NULL, NULL);
	self = (GXmlXDocument*) gxml_xnode_construct (object_type);
	_tmp0_ = self->doc;
	if (_tmp0_ != NULL) {
		xmlDoc* _tmp1_;
		_tmp1_ = self->doc;
		_xmlFreeDoc0 (_tmp1_);
		self->doc = NULL;
	}
	self->doc = doc;
	return self;
}

GXmlXDocument*
gxml_xdocument_new_from_doc (xmlDoc* doc)
{
	return gxml_xdocument_construct_from_doc (GXML_TYPE_XDOCUMENT, doc);
}

static gpointer
_g_object_ref0 (gpointer self)
{
	return self ? g_object_ref (self) : NULL;
}

static GXmlParser*
gxml_xdocument_real_gxml_dom_document_get_xml_parser (GXmlDomDocument* base)
{
	GXmlXDocument * self;
	GXmlParser* _tmp0_;
	GXmlXdParser* _tmp3_;
	GXmlParser* result;
	self = (GXmlXDocument*) base;
	_tmp0_ = self->_parser;
	if (_tmp0_ != NULL) {
		GXmlParser* _tmp1_;
		GXmlParser* _tmp2_;
		_tmp1_ = self->_parser;
		_tmp2_ = _g_object_ref0 (_tmp1_);
		result = _tmp2_;
		return result;
	}
	_tmp3_ = gxml_xd_parser_new (self);
	result = (GXmlParser*) _tmp3_;
	return result;
}

static void
gxml_xdocument_real_set_xml_parser (GXmlDomDocument* base,
                                    GXmlParser* parser)
{
	GXmlXDocument * self;
	GXmlParser* _tmp0_;
	self = (GXmlXDocument*) base;
	g_return_if_fail (parser != NULL);
	_tmp0_ = _g_object_ref0 (parser);
	_g_object_unref0 (self->_parser);
	self->_parser = _tmp0_;
}

static gboolean
gxml_xdocument_real_set_namespace (GXmlXNode* base,
                                   const gchar* uri,
                                   const gchar* prefix)
{
	GXmlXDocument * self;
	xmlNode* root = NULL;
	xmlDoc* _tmp0_;
	xmlNode* _tmp1_;
	xmlNode* _tmp2_;
	gboolean result;
	self = (GXmlXDocument*) base;
	g_return_val_if_fail (uri != NULL, FALSE);
	_tmp0_ = self->doc;
	_tmp1_ = xmlDocGetRootElement (_tmp0_);
	root = _tmp1_;
	_tmp2_ = root;
	if (_tmp2_ != NULL) {
		xmlNs* ns = NULL;
		xmlNode* _tmp3_;
		xmlNs* _tmp4_;
		xmlNs* _tmp5_;
		_tmp3_ = root;
		_tmp4_ = xmlNewNs (_tmp3_, (xmlChar*) uri, (xmlChar*) prefix);
		ns = _tmp4_;
		_tmp5_ = ns;
		result = _tmp5_ != NULL;
		return result;
	}
	result = FALSE;
	return result;
}

static GeeMap*
gxml_xdocument_real_get_attrs (GXmlXNode* base)
{
	GeeMap* result;
	GXmlXDocument* self;
	xmlDoc* _tmp0_;
	GXmlXHashMapAttr* _tmp1_;
	GeeMap* _tmp2_;
	self = (GXmlXDocument*) base;
	_tmp0_ = self->doc;
	_tmp1_ = gxml_xhash_map_attr_new (self, (xmlNode*) _tmp0_);
	_tmp2_ = G_TYPE_CHECK_INSTANCE_TYPE (_tmp1_, GEE_TYPE_MAP) ? ((GeeMap*) _tmp1_) : NULL;
	if (_tmp2_ == NULL) {
		_g_object_unref0 (_tmp1_);
	}
	result = _tmp2_;
	return result;
}

static GeeBidirList*
gxml_xdocument_real_get_children_nodes (GXmlXNode* base)
{
	GeeBidirList* result;
	GXmlXDocument* self;
	xmlDoc* _tmp0_;
	GXmlXListChildren* _tmp1_;
	GeeBidirList* _tmp2_;
	self = (GXmlXDocument*) base;
	_tmp0_ = self->doc;
	_tmp1_ = gxml_xlist_children_new (self, (xmlNode*) _tmp0_);
	_tmp2_ = G_TYPE_CHECK_INSTANCE_TYPE (_tmp1_, GEE_TYPE_BIDIR_LIST) ? ((GeeBidirList*) _tmp1_) : NULL;
	if (_tmp2_ == NULL) {
		_g_object_unref0 (_tmp1_);
	}
	result = _tmp2_;
	return result;
}

static GXmlDomDocument*
gxml_xdocument_real_get_document (GXmlXNode* base)
{
	GXmlDomDocument* result;
	GXmlXDocument* self;
	self = (GXmlXDocument*) base;
	result = (GXmlDomDocument*) self;
	return result;
}

gboolean
gxml_xdocument_get_indent (GXmlXDocument* self)
{
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	result = self->priv->_indent;
	return result;
}

void
gxml_xdocument_set_indent (GXmlXDocument* self,
                           gboolean value)
{
	gboolean old_value;
	g_return_if_fail (self != NULL);
	old_value = gxml_xdocument_get_indent (self);
	if (old_value != value) {
		self->priv->_indent = value;
		g_object_notify_by_pspec ((GObject *) self, gxml_xdocument_properties[GXML_XDOCUMENT_INDENT_PROPERTY]);
	}
}

gboolean
gxml_xdocument_get_ns_top (GXmlXDocument* self)
{
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	result = self->priv->_ns_top;
	return result;
}

void
gxml_xdocument_set_ns_top (GXmlXDocument* self,
                           gboolean value)
{
	gboolean old_value;
	g_return_if_fail (self != NULL);
	old_value = gxml_xdocument_get_ns_top (self);
	if (old_value != value) {
		self->priv->_ns_top = value;
		g_object_notify_by_pspec ((GObject *) self, gxml_xdocument_properties[GXML_XDOCUMENT_NS_TOP_PROPERTY]);
	}
}

gboolean
gxml_xdocument_get_prefix_default_ns (GXmlXDocument* self)
{
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	result = self->priv->_prefix_default_ns;
	return result;
}

void
gxml_xdocument_set_prefix_default_ns (GXmlXDocument* self,
                                      gboolean value)
{
	gboolean old_value;
	g_return_if_fail (self != NULL);
	old_value = gxml_xdocument_get_prefix_default_ns (self);
	if (old_value != value) {
		self->priv->_prefix_default_ns = value;
		g_object_notify_by_pspec ((GObject *) self, gxml_xdocument_properties[GXML_XDOCUMENT_PREFIX_DEFAULT_NS_PROPERTY]);
	}
}

gboolean
gxml_xdocument_get_backup (GXmlXDocument* self)
{
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	result = self->priv->_backup;
	return result;
}

void
gxml_xdocument_set_backup (GXmlXDocument* self,
                           gboolean value)
{
	gboolean old_value;
	g_return_if_fail (self != NULL);
	old_value = gxml_xdocument_get_backup (self);
	if (old_value != value) {
		self->priv->_backup = value;
		g_object_notify_by_pspec ((GObject *) self, gxml_xdocument_properties[GXML_XDOCUMENT_BACKUP_PROPERTY]);
	}
}

GFile*
gxml_xdocument_get_file (GXmlXDocument* self)
{
	GFile* result;
	GFile* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_file;
	result = _tmp0_;
	return result;
}

void
gxml_xdocument_set_file (GXmlXDocument* self,
                         GFile* value)
{
	GFile* old_value;
	g_return_if_fail (self != NULL);
	old_value = gxml_xdocument_get_file (self);
	if (old_value != value) {
		GFile* _tmp0_;
		_tmp0_ = _g_object_ref0 (value);
		_g_object_unref0 (self->priv->_file);
		self->priv->_file = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, gxml_xdocument_properties[GXML_XDOCUMENT_FILE_PROPERTY]);
	}
}

GXmlDomNode*
gxml_xdocument_get_root (GXmlXDocument* self)
{
	GXmlDomNode* result;
	xmlNode* r = NULL;
	xmlDoc* _tmp0_;
	xmlNode* _tmp1_;
	xmlNode* _tmp2_;
	xmlNode* _tmp18_;
	GXmlXElement* _tmp19_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->doc;
	_tmp1_ = xmlDocGetRootElement (_tmp0_);
	r = _tmp1_;
	_tmp2_ = r;
	if (_tmp2_ == NULL) {
		gint found = 0;
		found = 0;
		{
			gint i = 0;
			i = 0;
			{
				gboolean _tmp3_ = FALSE;
				_tmp3_ = TRUE;
				while (TRUE) {
					GeeBidirList* _tmp5_;
					GeeBidirList* _tmp6_;
					GeeBidirList* _tmp7_;
					gint _tmp8_;
					gint _tmp9_;
					gboolean _tmp10_;
					GXmlDomNode* n = NULL;
					GeeBidirList* _tmp11_;
					GeeBidirList* _tmp12_;
					GeeBidirList* _tmp13_;
					gpointer _tmp14_;
					GXmlDomNode* _tmp15_;
					GXmlDomNode* _tmp16_;
					if (!_tmp3_) {
						gint _tmp4_;
						_tmp4_ = i;
						i = _tmp4_ + 1;
					}
					_tmp3_ = FALSE;
					_tmp5_ = gxml_xnode_get_children_nodes ((GXmlXNode*) self);
					_tmp6_ = _tmp5_;
					_tmp7_ = _tmp6_;
					_tmp8_ = gee_collection_get_size ((GeeCollection*) _tmp7_);
					_tmp9_ = _tmp8_;
					_tmp10_ = !(i < _tmp9_);
					_g_object_unref0 (_tmp7_);
					if (_tmp10_) {
						break;
					}
					_tmp11_ = gxml_xnode_get_children_nodes ((GXmlXNode*) self);
					_tmp12_ = _tmp11_;
					_tmp13_ = _tmp12_;
					_tmp14_ = gee_list_get ((GeeList*) _tmp13_, i);
					_tmp15_ = (GXmlDomNode*) _tmp14_;
					_g_object_unref0 (_tmp13_);
					n = _tmp15_;
					_tmp16_ = n;
					if (GXML_IS_DOM_ELEMENT (_tmp16_)) {
						gint _tmp17_;
						_tmp17_ = found;
						found = _tmp17_ + 1;
						if (found == 1) {
							result = n;
							return result;
						}
					}
					_g_object_unref0 (n);
				}
			}
		}
		if (found > 1) {
			g_warning ("XDocument.vala:135: Document have more than one root GXmlElement. Usin" \
"g first found");
		}
	}
	_tmp18_ = r;
	_tmp19_ = gxml_xelement_new (self, _tmp18_);
	result = (GXmlDomNode*) _tmp19_;
	return result;
}

GXmlDomNode*
gxml_xdocument_create_pi (GXmlXDocument* self,
                          const gchar* target,
                          const gchar* data)
{
	xmlNode* pi = NULL;
	xmlDoc* _tmp0_;
	xmlNode* _tmp1_;
	GXmlXProcessingInstruction* _tmp2_;
	GXmlDomNode* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (target != NULL, NULL);
	g_return_val_if_fail (data != NULL, NULL);
	_tmp0_ = self->doc;
	_tmp1_ = xmlNewDocPI (_tmp0_, (xmlChar*) target, (xmlChar*) data);
	pi = _tmp1_;
	_tmp2_ = gxml_xprocessing_instruction_new (self, pi);
	result = (GXmlDomNode*) _tmp2_;
	return result;
}

GXmlDomNode*
gxml_xdocument_create_text (GXmlXDocument* self,
                            const gchar* text)
{
	xmlNode* t = NULL;
	xmlDoc* _tmp0_;
	xmlNode* _tmp1_;
	GXmlXText* n = NULL;
	GXmlXText* _tmp2_;
	GXmlDomNode* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (text != NULL, NULL);
	_tmp0_ = self->doc;
	_tmp1_ = xmlNewDocText (_tmp0_, (xmlChar*) text);
	t = _tmp1_;
	_tmp2_ = gxml_xtext_new (self, t);
	n = _tmp2_;
	gxml_xnode_take_node ((GXmlXNode*) n);
	result = (GXmlDomNode*) n;
	return result;
}

static gchar*
gxml_xdocument_real_to_string (GXmlXNode* base)
{
	GXmlXDocument * self;
	GError* _inner_error0_ = NULL;
	gchar* result;
	self = (GXmlXDocument*) base;
	{
		gchar* _tmp0_ = NULL;
		gchar* _tmp1_;
		gchar* _tmp2_;
		_tmp1_ = gxml_dom_document_write_string ((GXmlDomDocument*) self, NULL, &_inner_error0_);
		_tmp0_ = _tmp1_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		_tmp2_ = _tmp0_;
		_tmp0_ = NULL;
		result = _tmp2_;
		_g_free0 (_tmp0_);
		return result;
	}
	goto __finally0;
	__catch0_g_error:
	{
		GError* e = NULL;
		GError* _tmp3_;
		const gchar* _tmp4_;
		gchar* _tmp5_;
		e = _inner_error0_;
		_inner_error0_ = NULL;
		_tmp3_ = e;
		_tmp4_ = _tmp3_->message;
		g_warning (_ ("Error writing document to string: %s"), _tmp4_);
		_tmp5_ = g_strdup ("");
		result = _tmp5_;
		_g_error_free0 (e);
		return result;
	}
	__finally0:
	g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
	g_clear_error (&_inner_error0_);
	return NULL;
}

/**
   * Uses libxml2 internal dump to memory function over owned
   */
gchar*
gxml_xdocument_libxml_to_string (GXmlXDocument* self)
{
	gchar* buffer = NULL;
	xmlDoc* _tmp0_;
	gchar* _tmp1_ = NULL;
	gchar* _tmp2_;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->doc;
	xmlDocDumpMemory (_tmp0_, (xmlChar**) (&_tmp1_), NULL);
	_g_free0 (buffer);
	buffer = _tmp1_;
	_tmp2_ = g_strdup (buffer);
	result = _tmp2_;
	_g_free0 (buffer);
	return result;
}

static gboolean
gxml_xdocument_real_save (GXmlXDocument* self,
                          GCancellable* cancellable,
                          GError** error)
{
	gboolean _tmp0_ = FALSE;
	GFile* _tmp1_;
	GError* _inner_error0_ = NULL;
	gboolean result;
	_tmp1_ = self->priv->_file;
	_tmp0_ = gxml_xdocument_save_as (self, _tmp1_, cancellable, &_inner_error0_);
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		gboolean _tmp2_ = FALSE;
		g_propagate_error (error, _inner_error0_);
		return _tmp2_;
	}
	result = _tmp0_;
	return result;
}

gboolean
gxml_xdocument_save (GXmlXDocument* self,
                     GCancellable* cancellable,
                     GError** error)
{
	GXmlXDocumentClass* _klass_;
	g_return_val_if_fail (self != NULL, FALSE);
	_klass_ = GXML_XDOCUMENT_GET_CLASS (self);
	if (_klass_->save) {
		return _klass_->save (self, cancellable, error);
	}
	return FALSE;
}

static gboolean
gxml_xdocument_real_save_as (GXmlXDocument* self,
                             GFile* f,
                             GCancellable* cancellable,
                             GError** error)
{
	GError* _inner_error0_ = NULL;
	gboolean result;
	g_return_val_if_fail (f != NULL, FALSE);
	gxml_dom_document_write_file ((GXmlDomDocument*) self, f, cancellable, &_inner_error0_);
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		gboolean _tmp0_ = FALSE;
		g_propagate_error (error, _inner_error0_);
		return _tmp0_;
	}
	result = TRUE;
	return result;
}

gboolean
gxml_xdocument_save_as (GXmlXDocument* self,
                        GFile* f,
                        GCancellable* cancellable,
                        GError** error)
{
	GXmlXDocumentClass* _klass_;
	g_return_val_if_fail (self != NULL, FALSE);
	_klass_ = GXML_XDOCUMENT_GET_CLASS (self);
	if (_klass_->save_as) {
		return _klass_->save_as (self, f, cancellable, error);
	}
	return FALSE;
}

static GXmlDomImplementation*
gxml_xdocument_real_get_implementation (GXmlDomDocument* base)
{
	GXmlDomImplementation* result;
	GXmlXDocument* self;
	GXmlDomImplementation* _tmp0_;
	self = (GXmlXDocument*) base;
	_tmp0_ = self->_implementation;
	result = G_TYPE_CHECK_INSTANCE_CAST (_tmp0_, GXML_TYPE_DOM_IMPLEMENTATION, GXmlDomImplementation);
	return result;
}

static const gchar*
gxml_xdocument_real_get_url (GXmlDomDocument* base)
{
	const gchar* result;
	GXmlXDocument* self;
	const gchar* _tmp0_;
	self = (GXmlXDocument*) base;
	_tmp0_ = self->_url;
	result = _tmp0_;
	return result;
}

static const gchar*
gxml_xdocument_real_get_document_uri (GXmlDomDocument* base)
{
	const gchar* result;
	GXmlXDocument* self;
	const gchar* _tmp0_;
	self = (GXmlXDocument*) base;
	_tmp0_ = self->_url;
	result = _tmp0_;
	return result;
}

static const gchar*
gxml_xdocument_real_get_origin (GXmlDomDocument* base)
{
	const gchar* result;
	GXmlXDocument* self;
	const gchar* _tmp0_;
	self = (GXmlXDocument*) base;
	_tmp0_ = self->_origin;
	result = _tmp0_;
	return result;
}

static const gchar*
gxml_xdocument_real_get_compat_mode (GXmlDomDocument* base)
{
	const gchar* result;
	GXmlXDocument* self;
	const gchar* _tmp0_;
	self = (GXmlXDocument*) base;
	_tmp0_ = self->_compat_mode;
	result = _tmp0_;
	return result;
}

static const gchar*
gxml_xdocument_real_get_character_set (GXmlDomDocument* base)
{
	const gchar* result;
	GXmlXDocument* self;
	const gchar* _tmp0_;
	self = (GXmlXDocument*) base;
	_tmp0_ = self->_character_set;
	result = _tmp0_;
	return result;
}

static const gchar*
gxml_xdocument_real_get_content_type (GXmlDomDocument* base)
{
	const gchar* result;
	GXmlXDocument* self;
	const gchar* _tmp0_;
	self = (GXmlXDocument*) base;
	_tmp0_ = self->_content_type;
	result = _tmp0_;
	return result;
}

static GXmlDomDocumentType*
gxml_xdocument_real_get_doctype (GXmlDomDocument* base)
{
	GXmlDomDocumentType* result;
	GXmlXDocument* self;
	self = (GXmlXDocument*) base;
	{
		GXmlDomNodeList* _n_list = NULL;
		GXmlDomNodeList* _tmp0_;
		GXmlDomNodeList* _tmp1_;
		gint _n_size = 0;
		GXmlDomNodeList* _tmp2_;
		gint _tmp3_;
		gint _tmp4_;
		gint _n_index = 0;
		_tmp0_ = gxml_dom_node_get_child_nodes ((GXmlDomNode*) self);
		_tmp1_ = _tmp0_;
		_n_list = _tmp1_;
		_tmp2_ = _n_list;
		_tmp3_ = gee_collection_get_size ((GeeCollection*) _tmp2_);
		_tmp4_ = _tmp3_;
		_n_size = _tmp4_;
		_n_index = -1;
		while (TRUE) {
			gint _tmp5_;
			gint _tmp6_;
			GXmlDomNode* n = NULL;
			GXmlDomNodeList* _tmp7_;
			gpointer _tmp8_;
			GXmlDomNode* _tmp9_;
			_n_index = _n_index + 1;
			_tmp5_ = _n_index;
			_tmp6_ = _n_size;
			if (!(_tmp5_ < _tmp6_)) {
				break;
			}
			_tmp7_ = _n_list;
			_tmp8_ = gee_list_get ((GeeList*) _tmp7_, _n_index);
			n = (GXmlDomNode*) _tmp8_;
			_tmp9_ = n;
			if (GXML_IS_DOM_DOCUMENT_TYPE (_tmp9_)) {
				GXmlDomNode* _tmp10_;
				GXmlDomDocumentType* _tmp11_;
				_tmp10_ = n;
				_tmp11_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp10_, GXML_TYPE_DOM_DOCUMENT_TYPE, GXmlDomDocumentType));
				result = _tmp11_;
				_g_object_unref0 (n);
				_g_object_unref0 (_n_list);
				return result;
			}
			_g_object_unref0 (n);
		}
		_g_object_unref0 (_n_list);
	}
	result = NULL;
	return result;
}

static GXmlDomElement*
gxml_xdocument_real_get_document_element (GXmlDomDocument* base)
{
	GXmlDomElement* result;
	GXmlXDocument* self;
	GXmlDomNode* _tmp0_;
	GXmlDomNode* _tmp1_;
	self = (GXmlXDocument*) base;
	_tmp0_ = gxml_xdocument_get_root (self);
	_tmp1_ = _tmp0_;
	result = G_TYPE_CHECK_INSTANCE_CAST (_tmp1_, GXML_TYPE_DOM_ELEMENT, GXmlDomElement);
	return result;
}

static GXmlDomElement*
gxml_xdocument_real_gxml_dom_document_create_element (GXmlDomDocument* base,
                                                      const gchar* local_name,
                                                      GError** error)
{
	GXmlXDocument * self;
	xmlNode* el = NULL;
	xmlDoc* _tmp0_;
	xmlNode* _tmp1_;
	xmlError* e = NULL;
	xmlError* _tmp2_;
	xmlError* _tmp3_;
	GXmlXElement* n = NULL;
	xmlNode* _tmp11_;
	GXmlXElement* _tmp12_;
	GError* _inner_error0_ = NULL;
	GXmlDomElement* result;
	self = (GXmlXDocument*) base;
	g_return_val_if_fail (local_name != NULL, NULL);
	xmlResetLastError ();
	_tmp0_ = self->doc;
	_tmp1_ = xmlNewDocRawNode (_tmp0_, NULL, (xmlChar*) local_name, (xmlChar*) NULL);
	el = _tmp1_;
	_tmp2_ = xmlGetLastError ();
	e = _tmp2_;
	_tmp3_ = e;
	if (_tmp3_ != NULL) {
		gchar* errmsg = NULL;
		gchar* _tmp4_;
		gchar* s = NULL;
		xmlError* _tmp5_;
		gchar* _tmp6_;
		const gchar* _tmp7_;
		const gchar* _tmp9_;
		GError* _tmp10_;
		_tmp4_ = g_strdup ("Parser Error for string");
		errmsg = _tmp4_;
		_tmp5_ = e;
		_tmp6_ = gxml_xnode_libxml2_error_to_string (_tmp5_);
		s = _tmp6_;
		_tmp7_ = s;
		if (_tmp7_ != NULL) {
			gchar* _tmp8_;
			_tmp8_ = g_strdup (".  ");
			_g_free0 (errmsg);
			errmsg = _tmp8_;
		}
		_tmp9_ = errmsg;
		_tmp10_ = g_error_new_literal (GXML_ERROR, GXML_ERROR_PARSER, _tmp9_);
		_inner_error0_ = _tmp10_;
		g_propagate_error (error, _inner_error0_);
		_g_free0 (s);
		_g_free0 (errmsg);
		return NULL;
	}
	_tmp11_ = el;
	_tmp12_ = gxml_xelement_new (self, _tmp11_);
	n = _tmp12_;
	gxml_xnode_take_node ((GXmlXNode*) n);
	result = (GXmlDomElement*) n;
	return result;
}

static gboolean
string_contains (const gchar* self,
                 const gchar* needle)
{
	gchar* _tmp0_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (needle != NULL, FALSE);
	_tmp0_ = strstr ((gchar*) self, (gchar*) needle);
	result = _tmp0_ != NULL;
	return result;
}

static GXmlDomElement*
gxml_xdocument_real_gxml_dom_document_create_element_ns (GXmlDomDocument* base,
                                                         const gchar* ns,
                                                         const gchar* qualified_name,
                                                         GError** error)
{
	GXmlXDocument * self;
	gchar* prefix = NULL;
	gchar* qname = NULL;
	gchar* _tmp0_;
	GXmlDomElement* e = NULL;
	const gchar* _tmp11_;
	GXmlDomElement* _tmp12_;
	const gchar* _tmp13_;
	GXmlDomElement* _tmp14_;
	GError* _inner_error0_ = NULL;
	GXmlDomElement* result;
	self = (GXmlXDocument*) base;
	g_return_val_if_fail (qualified_name != NULL, NULL);
	prefix = NULL;
	_tmp0_ = g_strdup (qualified_name);
	qname = _tmp0_;
	if (string_contains (qualified_name, ":")) {
		gchar** s = NULL;
		gchar** _tmp1_;
		gchar** _tmp2_;
		gint s_length1;
		gint _s_size_;
		gchar** _tmp3_;
		gint _tmp3__length1;
		gchar** _tmp5_;
		gint _tmp5__length1;
		const gchar* _tmp6_;
		gchar* _tmp7_;
		gchar** _tmp8_;
		gint _tmp8__length1;
		const gchar* _tmp9_;
		gchar* _tmp10_;
		_tmp2_ = _tmp1_ = g_strsplit (qualified_name, ":", 0);
		s = _tmp2_;
		s_length1 = _vala_array_length (_tmp1_);
		_s_size_ = s_length1;
		_tmp3_ = s;
		_tmp3__length1 = s_length1;
		if (_tmp3__length1 != 2) {
			GError* _tmp4_;
			_tmp4_ = g_error_new_literal (GXML_DOM_ERROR, GXML_DOM_ERROR_INVALID_CHARACTER_ERROR, _ ("Invalid element qualified name: multiple namespace prefixes"));
			_inner_error0_ = _tmp4_;
			g_propagate_error (error, _inner_error0_);
			s = (_vala_array_free (s, s_length1, (GDestroyNotify) g_free), NULL);
			_g_free0 (qname);
			_g_free0 (prefix);
			return NULL;
		}
		_tmp5_ = s;
		_tmp5__length1 = s_length1;
		_tmp6_ = _tmp5_[0];
		_tmp7_ = g_strdup (_tmp6_);
		_g_free0 (prefix);
		prefix = _tmp7_;
		_tmp8_ = s;
		_tmp8__length1 = s_length1;
		_tmp9_ = _tmp8_[1];
		_tmp10_ = g_strdup (_tmp9_);
		_g_free0 (qname);
		qname = _tmp10_;
		s = (_vala_array_free (s, s_length1, (GDestroyNotify) g_free), NULL);
	}
	_tmp11_ = qname;
	_tmp12_ = gxml_dom_document_create_element (G_TYPE_CHECK_INSTANCE_CAST (self, GXML_TYPE_DOM_DOCUMENT, GXmlDomDocument), _tmp11_, &_inner_error0_);
	e = _tmp12_;
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		g_propagate_error (error, _inner_error0_);
		_g_free0 (qname);
		_g_free0 (prefix);
		return NULL;
	}
	_tmp13_ = prefix;
	gxml_xnode_set_namespace ((GXmlXNode*) G_TYPE_CHECK_INSTANCE_CAST (e, GXML_TYPE_XELEMENT, GXmlXElement), ns, _tmp13_);
	gxml_xnode_take_node ((GXmlXNode*) G_TYPE_CHECK_INSTANCE_CAST (e, GXML_TYPE_XELEMENT, GXmlXElement));
	_tmp14_ = _g_object_ref0 (GXML_IS_DOM_ELEMENT (e) ? ((GXmlDomElement*) e) : NULL);
	result = _tmp14_;
	_g_object_unref0 (e);
	_g_free0 (qname);
	_g_free0 (prefix);
	return result;
}

static GXmlDomHTMLCollection*
gxml_xdocument_real_get_elements_by_tag_name (GXmlDomDocument* base,
                                              const gchar* local_name)
{
	GXmlXDocument * self;
	GXmlHTMLCollection* l = NULL;
	GXmlHTMLCollection* _tmp0_;
	GXmlDomElement* _tmp1_;
	GXmlDomElement* _tmp2_;
	GXmlDomElement* _tmp3_;
	gboolean _tmp4_;
	GXmlHTMLCollection* _tmp5_;
	GXmlDomElement* _tmp6_;
	GXmlDomElement* _tmp7_;
	GXmlDomElement* _tmp8_;
	GXmlDomHTMLCollection* _tmp9_;
	GXmlDomHTMLCollection* _tmp10_;
	GXmlDomHTMLCollection* result;
	self = (GXmlXDocument*) base;
	g_return_val_if_fail (local_name != NULL, NULL);
	_tmp0_ = gxml_html_collection_new ();
	l = _tmp0_;
	_tmp1_ = gxml_dom_document_get_document_element ((GXmlDomDocument*) self);
	_tmp2_ = _tmp1_;
	_tmp3_ = _tmp2_;
	_tmp4_ = _tmp3_ == NULL;
	_g_object_unref0 (_tmp3_);
	if (_tmp4_) {
		result = (GXmlDomHTMLCollection*) l;
		return result;
	}
	_tmp5_ = l;
	_tmp6_ = gxml_dom_document_get_document_element ((GXmlDomDocument*) self);
	_tmp7_ = _tmp6_;
	_tmp8_ = _tmp7_;
	_tmp9_ = gxml_dom_element_get_elements_by_tag_name (_tmp8_, local_name);
	_tmp10_ = _tmp9_;
	gee_array_list_add_all ((GeeArrayList*) _tmp5_, (GeeCollection*) _tmp10_);
	_g_object_unref0 (_tmp10_);
	_g_object_unref0 (_tmp8_);
	result = (GXmlDomHTMLCollection*) l;
	return result;
}

static GXmlDomHTMLCollection*
gxml_xdocument_real_get_elements_by_tag_name_ns (GXmlDomDocument* base,
                                                 const gchar* ns,
                                                 const gchar* local_name)
{
	GXmlXDocument * self;
	GXmlHTMLCollection* l = NULL;
	GXmlHTMLCollection* _tmp0_;
	GXmlDomElement* _tmp1_;
	GXmlDomElement* _tmp2_;
	GXmlDomElement* _tmp3_;
	gboolean _tmp4_;
	GXmlHTMLCollection* _tmp5_;
	GXmlDomElement* _tmp6_;
	GXmlDomElement* _tmp7_;
	GXmlDomElement* _tmp8_;
	GXmlDomHTMLCollection* _tmp9_;
	GXmlDomHTMLCollection* _tmp10_;
	GXmlDomHTMLCollection* result;
	self = (GXmlXDocument*) base;
	g_return_val_if_fail (local_name != NULL, NULL);
	_tmp0_ = gxml_html_collection_new ();
	l = _tmp0_;
	_tmp1_ = gxml_dom_document_get_document_element ((GXmlDomDocument*) self);
	_tmp2_ = _tmp1_;
	_tmp3_ = _tmp2_;
	_tmp4_ = _tmp3_ == NULL;
	_g_object_unref0 (_tmp3_);
	if (_tmp4_) {
		result = (GXmlDomHTMLCollection*) l;
		return result;
	}
	_tmp5_ = l;
	_tmp6_ = gxml_dom_document_get_document_element ((GXmlDomDocument*) self);
	_tmp7_ = _tmp6_;
	_tmp8_ = _tmp7_;
	_tmp9_ = gxml_dom_element_get_elements_by_tag_name_ns (_tmp8_, ns, local_name);
	_tmp10_ = _tmp9_;
	gee_array_list_add_all ((GeeArrayList*) _tmp5_, (GeeCollection*) _tmp10_);
	_g_object_unref0 (_tmp10_);
	_g_object_unref0 (_tmp8_);
	result = (GXmlDomHTMLCollection*) l;
	return result;
}

static GXmlDomHTMLCollection*
gxml_xdocument_real_get_elements_by_class_name (GXmlDomDocument* base,
                                                const gchar* class_names)
{
	GXmlXDocument * self;
	GXmlHTMLCollection* l = NULL;
	GXmlHTMLCollection* _tmp0_;
	GXmlDomElement* _tmp1_;
	GXmlDomElement* _tmp2_;
	GXmlDomElement* _tmp3_;
	gboolean _tmp4_;
	GXmlHTMLCollection* _tmp5_;
	GXmlDomElement* _tmp6_;
	GXmlDomElement* _tmp7_;
	GXmlDomElement* _tmp8_;
	GXmlDomHTMLCollection* _tmp9_;
	GXmlDomHTMLCollection* _tmp10_;
	GXmlDomHTMLCollection* result;
	self = (GXmlXDocument*) base;
	g_return_val_if_fail (class_names != NULL, NULL);
	_tmp0_ = gxml_html_collection_new ();
	l = _tmp0_;
	_tmp1_ = gxml_dom_document_get_document_element ((GXmlDomDocument*) self);
	_tmp2_ = _tmp1_;
	_tmp3_ = _tmp2_;
	_tmp4_ = _tmp3_ == NULL;
	_g_object_unref0 (_tmp3_);
	if (_tmp4_) {
		result = (GXmlDomHTMLCollection*) l;
		return result;
	}
	_tmp5_ = l;
	_tmp6_ = gxml_dom_document_get_document_element ((GXmlDomDocument*) self);
	_tmp7_ = _tmp6_;
	_tmp8_ = _tmp7_;
	_tmp9_ = gxml_dom_element_get_elements_by_class_name (_tmp8_, class_names);
	_tmp10_ = _tmp9_;
	gee_array_list_add_all ((GeeArrayList*) _tmp5_, (GeeCollection*) _tmp10_);
	_g_object_unref0 (_tmp10_);
	_g_object_unref0 (_tmp8_);
	result = (GXmlDomHTMLCollection*) l;
	return result;
}

static GXmlDomDocumentFragment*
gxml_xdocument_real_create_document_fragment (GXmlDomDocument* base)
{
	GXmlXDocument * self;
	GXmlXDocumentFragment* _tmp0_;
	GXmlDomDocumentFragment* result;
	self = (GXmlXDocument*) base;
	_tmp0_ = gxml_xdocument_fragment_new (self);
	result = (GXmlDomDocumentFragment*) _tmp0_;
	return result;
}

static GXmlDomText*
gxml_xdocument_real_create_text_node (GXmlDomDocument* base,
                                      const gchar* data,
                                      GError** error)
{
	GXmlXDocument * self;
	GXmlDomNode* _tmp0_;
	GXmlDomText* result;
	self = (GXmlXDocument*) base;
	g_return_val_if_fail (data != NULL, NULL);
	_tmp0_ = gxml_xdocument_create_text (self, data);
	result = G_TYPE_CHECK_INSTANCE_CAST (_tmp0_, GXML_TYPE_DOM_TEXT, GXmlDomText);
	return result;
}

static GXmlDomComment*
gxml_xdocument_real_gxml_dom_document_create_comment (GXmlDomDocument* base,
                                                      const gchar* data,
                                                      GError** error)
{
	GXmlXDocument * self;
	xmlNode* c = NULL;
	xmlDoc* _tmp0_;
	xmlNode* _tmp1_;
	GXmlXComment* _tmp2_;
	GXmlDomComment* result;
	self = (GXmlXDocument*) base;
	g_return_val_if_fail (data != NULL, NULL);
	_tmp0_ = self->doc;
	_tmp1_ = xmlNewDocComment (_tmp0_, (xmlChar*) data);
	c = _tmp1_;
	_tmp2_ = gxml_xcomment_new (self, c);
	result = (GXmlDomComment*) _tmp2_;
	return result;
}

static GXmlDomProcessingInstruction*
gxml_xdocument_real_create_processing_instruction (GXmlDomDocument* base,
                                                   const gchar* target,
                                                   const gchar* data,
                                                   GError** error)
{
	GXmlXDocument * self;
	GXmlDomNode* _tmp0_;
	GXmlDomProcessingInstruction* result;
	self = (GXmlXDocument*) base;
	g_return_val_if_fail (target != NULL, NULL);
	g_return_val_if_fail (data != NULL, NULL);
	_tmp0_ = gxml_xdocument_create_pi (self, target, data);
	result = G_TYPE_CHECK_INSTANCE_CAST (_tmp0_, GXML_TYPE_DOM_PROCESSING_INSTRUCTION, GXmlDomProcessingInstruction);
	return result;
}

static GXmlDomNode*
gxml_xdocument_real_import_node (GXmlDomDocument* base,
                                 GXmlDomNode* node,
                                 gboolean deep,
                                 GError** error)
{
	GXmlXDocument * self;
	gboolean _tmp1_ = FALSE;
	GXmlDomNode* dst = NULL;
	GXmlDomNode* _tmp45_;
	GXmlDomNode* _tmp52_;
	GError* _inner_error0_ = NULL;
	GXmlDomNode* result;
	self = (GXmlXDocument*) base;
	g_return_val_if_fail (node != NULL, NULL);
	if (GXML_IS_DOM_DOCUMENT (node)) {
		GError* _tmp0_;
		_tmp0_ = g_error_new_literal (GXML_DOM_ERROR, GXML_DOM_ERROR_NOT_SUPPORTED_ERROR, _ ("Can't import a Document"));
		_inner_error0_ = _tmp0_;
		g_propagate_error (error, _inner_error0_);
		return NULL;
	}
	if (!GXML_IS_DOM_ELEMENT (node)) {
		GXmlDomElement* _tmp2_;
		GXmlDomElement* _tmp3_;
		GXmlDomElement* _tmp4_;
		_tmp2_ = gxml_dom_document_get_document_element ((GXmlDomDocument*) self);
		_tmp3_ = _tmp2_;
		_tmp4_ = _tmp3_;
		_tmp1_ = _tmp4_ == NULL;
		_g_object_unref0 (_tmp4_);
	} else {
		_tmp1_ = FALSE;
	}
	if (_tmp1_) {
		GError* _tmp5_;
		_tmp5_ = g_error_new_literal (GXML_DOM_ERROR, GXML_DOM_ERROR_HIERARCHY_REQUEST_ERROR, _ ("Can't import a non Element type node to a Document"));
		_inner_error0_ = _tmp5_;
		g_propagate_error (error, _inner_error0_);
		return NULL;
	}
	dst = NULL;
	if (GXML_IS_DOM_ELEMENT (node)) {
		GXmlDomElement* _tmp6_ = NULL;
		gchar* _tmp7_;
		gchar* _tmp8_;
		gchar* _tmp9_;
		GXmlDomElement* _tmp10_;
		GXmlDomElement* _tmp11_;
		GXmlDomElement* _tmp12_;
		GXmlDomNode* _tmp13_;
		GXmlDomElement* _tmp14_;
		GXmlDomElement* _tmp15_;
		GXmlDomElement* _tmp16_;
		gboolean _tmp17_;
		_tmp7_ = gxml_dom_node_get_node_name (node);
		_tmp8_ = _tmp7_;
		_tmp9_ = _tmp8_;
		_tmp10_ = gxml_dom_document_create_element (G_TYPE_CHECK_INSTANCE_CAST (self, GXML_TYPE_DOM_DOCUMENT, GXmlDomDocument), _tmp9_, &_inner_error0_);
		_tmp11_ = _tmp10_;
		_g_free0 (_tmp9_);
		_tmp6_ = _tmp11_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			g_propagate_error (error, _inner_error0_);
			_g_object_unref0 (dst);
			return NULL;
		}
		_tmp12_ = _tmp6_;
		_tmp6_ = NULL;
		_g_object_unref0 (dst);
		dst = (GXmlDomNode*) _tmp12_;
		_tmp13_ = dst;
		gxml_dom_node_copy ((GXmlDomDocument*) self, G_TYPE_CHECK_INSTANCE_CAST (_tmp13_, GXML_TYPE_DOM_NODE, GXmlDomNode), G_TYPE_CHECK_INSTANCE_CAST (node, GXML_TYPE_DOM_NODE, GXmlDomNode), deep, &_inner_error0_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			g_propagate_error (error, _inner_error0_);
			_g_object_unref0 (_tmp6_);
			_g_object_unref0 (dst);
			return NULL;
		}
		_tmp14_ = gxml_dom_document_get_document_element ((GXmlDomDocument*) self);
		_tmp15_ = _tmp14_;
		_tmp16_ = _tmp15_;
		_tmp17_ = _tmp16_ == NULL;
		_g_object_unref0 (_tmp16_);
		if (_tmp17_) {
			GXmlDomNode* _tmp18_;
			GXmlDomNode* _tmp19_;
			GXmlDomNode* _tmp20_;
			_tmp18_ = dst;
			_tmp19_ = gxml_dom_node_append_child ((GXmlDomNode*) self, _tmp18_, &_inner_error0_);
			_tmp20_ = _tmp19_;
			_g_object_unref0 (_tmp20_);
			if (G_UNLIKELY (_inner_error0_ != NULL)) {
				g_propagate_error (error, _inner_error0_);
				_g_object_unref0 (_tmp6_);
				_g_object_unref0 (dst);
				return NULL;
			}
			result = dst;
			_g_object_unref0 (_tmp6_);
			return result;
		}
		_g_object_unref0 (_tmp6_);
	}
	if (GXML_IS_DOM_TEXT (node)) {
		GXmlDomText* _tmp21_ = NULL;
		gchar* _tmp22_;
		gchar* _tmp23_;
		gchar* _tmp24_;
		GXmlDomText* _tmp25_;
		GXmlDomText* _tmp26_;
		GXmlDomText* _tmp27_;
		_tmp22_ = gxml_dom_character_data_get_data ((GXmlDomCharacterData*) G_TYPE_CHECK_INSTANCE_CAST (node, GXML_TYPE_DOM_TEXT, GXmlDomText));
		_tmp23_ = _tmp22_;
		_tmp24_ = _tmp23_;
		_tmp25_ = gxml_dom_document_create_text_node ((GXmlDomDocument*) self, _tmp24_, &_inner_error0_);
		_tmp26_ = _tmp25_;
		_g_free0 (_tmp24_);
		_tmp21_ = _tmp26_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			g_propagate_error (error, _inner_error0_);
			_g_object_unref0 (dst);
			return NULL;
		}
		_tmp27_ = _tmp21_;
		_tmp21_ = NULL;
		_g_object_unref0 (dst);
		dst = (GXmlDomNode*) _tmp27_;
		_g_object_unref0 (_tmp21_);
	}
	if (GXML_IS_DOM_COMMENT (node)) {
		GXmlDomComment* _tmp28_ = NULL;
		gchar* _tmp29_;
		gchar* _tmp30_;
		gchar* _tmp31_;
		GXmlDomComment* _tmp32_;
		GXmlDomComment* _tmp33_;
		GXmlDomComment* _tmp34_;
		_tmp29_ = gxml_dom_character_data_get_data ((GXmlDomCharacterData*) G_TYPE_CHECK_INSTANCE_CAST (node, GXML_TYPE_DOM_COMMENT, GXmlDomComment));
		_tmp30_ = _tmp29_;
		_tmp31_ = _tmp30_;
		_tmp32_ = gxml_dom_document_create_comment (G_TYPE_CHECK_INSTANCE_CAST (self, GXML_TYPE_DOM_DOCUMENT, GXmlDomDocument), _tmp31_, &_inner_error0_);
		_tmp33_ = _tmp32_;
		_g_free0 (_tmp31_);
		_tmp28_ = _tmp33_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			g_propagate_error (error, _inner_error0_);
			_g_object_unref0 (dst);
			return NULL;
		}
		_tmp34_ = _tmp28_;
		_tmp28_ = NULL;
		_g_object_unref0 (dst);
		dst = (GXmlDomNode*) _tmp34_;
		_g_object_unref0 (_tmp28_);
	}
	if (GXML_IS_DOM_PROCESSING_INSTRUCTION (node)) {
		GXmlDomProcessingInstruction* _tmp35_ = NULL;
		gchar* _tmp36_;
		gchar* _tmp37_;
		gchar* _tmp38_;
		gchar* _tmp39_;
		gchar* _tmp40_;
		gchar* _tmp41_;
		GXmlDomProcessingInstruction* _tmp42_;
		GXmlDomProcessingInstruction* _tmp43_;
		GXmlDomProcessingInstruction* _tmp44_;
		_tmp36_ = gxml_dom_processing_instruction_get_target (G_TYPE_CHECK_INSTANCE_CAST (node, GXML_TYPE_DOM_PROCESSING_INSTRUCTION, GXmlDomProcessingInstruction));
		_tmp37_ = _tmp36_;
		_tmp38_ = _tmp37_;
		_tmp39_ = gxml_dom_character_data_get_data ((GXmlDomCharacterData*) G_TYPE_CHECK_INSTANCE_CAST (node, GXML_TYPE_DOM_PROCESSING_INSTRUCTION, GXmlDomProcessingInstruction));
		_tmp40_ = _tmp39_;
		_tmp41_ = _tmp40_;
		_tmp42_ = gxml_dom_document_create_processing_instruction ((GXmlDomDocument*) self, _tmp38_, _tmp41_, &_inner_error0_);
		_tmp43_ = _tmp42_;
		_g_free0 (_tmp41_);
		_g_free0 (_tmp38_);
		_tmp35_ = _tmp43_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			g_propagate_error (error, _inner_error0_);
			_g_object_unref0 (dst);
			return NULL;
		}
		_tmp44_ = _tmp35_;
		_tmp35_ = NULL;
		_g_object_unref0 (dst);
		dst = (GXmlDomNode*) _tmp44_;
		_g_object_unref0 (_tmp35_);
	}
	_tmp45_ = dst;
	if (_tmp45_ != NULL) {
		GXmlDomElement* _tmp46_;
		GXmlDomElement* _tmp47_;
		GXmlDomElement* _tmp48_;
		GXmlDomNode* _tmp49_;
		GXmlDomNode* _tmp50_;
		GXmlDomNode* _tmp51_;
		_tmp46_ = gxml_dom_document_get_document_element ((GXmlDomDocument*) self);
		_tmp47_ = _tmp46_;
		_tmp48_ = _tmp47_;
		_tmp49_ = dst;
		_tmp50_ = gxml_dom_node_append_child ((GXmlDomNode*) _tmp48_, GXML_IS_DOM_NODE (_tmp49_) ? ((GXmlDomNode*) _tmp49_) : NULL, &_inner_error0_);
		_tmp51_ = _tmp50_;
		_g_object_unref0 (_tmp51_);
		_g_object_unref0 (_tmp48_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			g_propagate_error (error, _inner_error0_);
			_g_object_unref0 (dst);
			return NULL;
		}
		result = dst;
		return result;
	}
	_tmp52_ = _g_object_ref0 (node);
	result = _tmp52_;
	_g_object_unref0 (dst);
	return result;
}

static GXmlDomNode*
gxml_xdocument_real_adopt_node (GXmlDomDocument* base,
                                GXmlDomNode* node,
                                GError** error)
{
	GXmlXDocument * self;
	GXmlDomDocument* _tmp1_;
	GXmlDomDocument* _tmp2_;
	GXmlDomElement* dst = NULL;
	gchar* _tmp4_;
	gchar* _tmp5_;
	gchar* _tmp6_;
	GXmlDomElement* _tmp7_;
	GXmlDomElement* _tmp8_;
	GXmlDomElement* _tmp9_;
	GXmlDomNode* _tmp10_;
	GXmlDomNode* _tmp11_;
	GXmlDomNode* _tmp12_;
	gboolean _tmp13_;
	GXmlDomElement* _tmp28_;
	GXmlDomElement* _tmp29_;
	GXmlDomElement* _tmp30_;
	gboolean _tmp31_;
	GXmlDomElement* _tmp41_;
	GXmlDomNode* _tmp42_;
	GError* _inner_error0_ = NULL;
	GXmlDomNode* result;
	self = (GXmlXDocument*) base;
	g_return_val_if_fail (node != NULL, NULL);
	if (GXML_IS_DOM_DOCUMENT (node)) {
		GError* _tmp0_;
		_tmp0_ = g_error_new_literal (GXML_DOM_ERROR, GXML_DOM_ERROR_NOT_SUPPORTED_ERROR, _ ("Can't adopt a Document"));
		_inner_error0_ = _tmp0_;
		g_propagate_error (error, _inner_error0_);
		return NULL;
	}
	_tmp1_ = gxml_dom_node_get_owner_document (node);
	_tmp2_ = _tmp1_;
	if (G_TYPE_CHECK_INSTANCE_CAST (self, GXML_TYPE_DOM_DOCUMENT, GXmlDomDocument) == _tmp2_) {
		GXmlDomNode* _tmp3_;
		_tmp3_ = _g_object_ref0 (node);
		result = _tmp3_;
		return result;
	}
	_tmp4_ = gxml_dom_node_get_node_name (node);
	_tmp5_ = _tmp4_;
	_tmp6_ = _tmp5_;
	_tmp7_ = gxml_dom_document_create_element ((GXmlDomDocument*) self, _tmp6_, &_inner_error0_);
	_tmp8_ = _tmp7_;
	_g_free0 (_tmp6_);
	dst = _tmp8_;
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		g_propagate_error (error, _inner_error0_);
		return NULL;
	}
	_tmp9_ = dst;
	gxml_dom_node_copy ((GXmlDomDocument*) self, GXML_IS_DOM_NODE (_tmp9_) ? ((GXmlDomNode*) _tmp9_) : NULL, G_TYPE_CHECK_INSTANCE_CAST (node, GXML_TYPE_DOM_NODE, GXmlDomNode), TRUE, &_inner_error0_);
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		g_propagate_error (error, _inner_error0_);
		_g_object_unref0 (dst);
		return NULL;
	}
	_tmp10_ = gxml_dom_node_get_parent_node (node);
	_tmp11_ = _tmp10_;
	_tmp12_ = _tmp11_;
	_tmp13_ = _tmp12_ != NULL;
	_g_object_unref0 (_tmp12_);
	if (_tmp13_) {
		GXmlDomNode* _tmp14_;
		GXmlDomNode* _tmp15_;
		GXmlDomNode* _tmp16_;
		GXmlDomNodeList* _tmp17_;
		GXmlDomNodeList* _tmp18_;
		GXmlDomNodeList* _tmp19_;
		GXmlDomNode* _tmp20_;
		GXmlDomNode* _tmp21_;
		GXmlDomNode* _tmp22_;
		GXmlDomNodeList* _tmp23_;
		GXmlDomNodeList* _tmp24_;
		GXmlDomNodeList* _tmp25_;
		gpointer _tmp26_;
		GXmlDomNode* _tmp27_;
		_tmp14_ = gxml_dom_node_get_parent_node (node);
		_tmp15_ = _tmp14_;
		_tmp16_ = _tmp15_;
		_tmp17_ = gxml_dom_node_get_child_nodes (_tmp16_);
		_tmp18_ = _tmp17_;
		_tmp19_ = _tmp18_;
		_tmp20_ = gxml_dom_node_get_parent_node (node);
		_tmp21_ = _tmp20_;
		_tmp22_ = _tmp21_;
		_tmp23_ = gxml_dom_node_get_child_nodes (_tmp22_);
		_tmp24_ = _tmp23_;
		_tmp25_ = _tmp24_;
		_tmp26_ = gee_list_remove_at ((GeeList*) _tmp19_, gee_list_index_of ((GeeList*) _tmp25_, node));
		_tmp27_ = (GXmlDomNode*) _tmp26_;
		_g_object_unref0 (_tmp27_);
		_g_object_unref0 (_tmp25_);
		_g_object_unref0 (_tmp22_);
		_g_object_unref0 (_tmp19_);
		_g_object_unref0 (_tmp16_);
	}
	_tmp28_ = gxml_dom_document_get_document_element ((GXmlDomDocument*) self);
	_tmp29_ = _tmp28_;
	_tmp30_ = _tmp29_;
	_tmp31_ = _tmp30_ == NULL;
	_g_object_unref0 (_tmp30_);
	if (_tmp31_) {
		GXmlDomElement* _tmp32_;
		GXmlDomNode* _tmp33_;
		GXmlDomNode* _tmp34_;
		_tmp32_ = dst;
		_tmp33_ = gxml_dom_node_append_child ((GXmlDomNode*) self, GXML_IS_DOM_NODE (_tmp32_) ? ((GXmlDomNode*) _tmp32_) : NULL, &_inner_error0_);
		_tmp34_ = _tmp33_;
		_g_object_unref0 (_tmp34_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			g_propagate_error (error, _inner_error0_);
			_g_object_unref0 (dst);
			return NULL;
		}
	} else {
		GXmlDomElement* _tmp35_;
		GXmlDomElement* _tmp36_;
		GXmlDomElement* _tmp37_;
		GXmlDomElement* _tmp38_;
		GXmlDomNode* _tmp39_;
		GXmlDomNode* _tmp40_;
		_tmp35_ = gxml_dom_document_get_document_element ((GXmlDomDocument*) self);
		_tmp36_ = _tmp35_;
		_tmp37_ = _tmp36_;
		_tmp38_ = dst;
		_tmp39_ = gxml_dom_node_append_child ((GXmlDomNode*) _tmp37_, GXML_IS_DOM_NODE (_tmp38_) ? ((GXmlDomNode*) _tmp38_) : NULL, &_inner_error0_);
		_tmp40_ = _tmp39_;
		_g_object_unref0 (_tmp40_);
		_g_object_unref0 (_tmp37_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			g_propagate_error (error, _inner_error0_);
			_g_object_unref0 (dst);
			return NULL;
		}
	}
	_tmp41_ = dst;
	_tmp42_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp41_, GXML_TYPE_DOM_NODE, GXmlDomNode));
	result = _tmp42_;
	_g_object_unref0 (dst);
	return result;
}

static GXmlDomEvent*
gxml_xdocument_real_create_event (GXmlDomDocument* base,
                                  const gchar* iface,
                                  GError** error)
{
	GXmlXDocument * self;
	gchar* s = NULL;
	gchar* _tmp0_;
	const gchar* _tmp1_;
	const gchar* _tmp3_;
	const gchar* _tmp5_;
	const gchar* _tmp7_;
	const gchar* _tmp9_;
	const gchar* _tmp10_;
	const gchar* _tmp11_;
	const gchar* _tmp12_;
	const gchar* _tmp13_;
	const gchar* _tmp14_;
	const gchar* _tmp15_;
	const gchar* _tmp16_;
	GXmlDomEvent* _tmp17_;
	GXmlDomEvent* _tmp18_;
	GXmlDomEvent* result;
	self = (GXmlXDocument*) base;
	g_return_val_if_fail (iface != NULL, NULL);
	_tmp0_ = g_utf8_strdown (iface, (gssize) -1);
	s = _tmp0_;
	_tmp1_ = s;
	if (g_strcmp0 (_tmp1_, "customevent") == 0) {
		GXmlCustomEvent* _tmp2_;
		_tmp2_ = gxml_custom_event_new ();
		_g_object_unref0 (self->_constructor);
		self->_constructor = (GXmlDomEvent*) _tmp2_;
	}
	_tmp3_ = s;
	if (g_strcmp0 (_tmp3_, "event") == 0) {
		GXmlCustomEvent* _tmp4_;
		_tmp4_ = gxml_custom_event_new ();
		_g_object_unref0 (self->_constructor);
		self->_constructor = (GXmlDomEvent*) _tmp4_;
	}
	_tmp5_ = s;
	if (g_strcmp0 (_tmp5_, "events") == 0) {
		GXmlCustomEvent* _tmp6_;
		_tmp6_ = gxml_custom_event_new ();
		_g_object_unref0 (self->_constructor);
		self->_constructor = (GXmlDomEvent*) _tmp6_;
	}
	_tmp7_ = s;
	if (g_strcmp0 (_tmp7_, "htmlevents") == 0) {
		GXmlCustomEvent* _tmp8_;
		_tmp8_ = gxml_custom_event_new ();
		_g_object_unref0 (self->_constructor);
		self->_constructor = (GXmlDomEvent*) _tmp8_;
	}
	_tmp9_ = s;
	if (g_strcmp0 (_tmp9_, "keyboardevent") == 0) {
		_g_object_unref0 (self->_constructor);
		self->_constructor = NULL;
	}
	_tmp10_ = s;
	if (g_strcmp0 (_tmp10_, "keyevents") == 0) {
		_g_object_unref0 (self->_constructor);
		self->_constructor = NULL;
	}
	_tmp11_ = s;
	if (g_strcmp0 (_tmp11_, "messageevent") == 0) {
		_g_object_unref0 (self->_constructor);
		self->_constructor = NULL;
	}
	_tmp12_ = s;
	if (g_strcmp0 (_tmp12_, "mouseevent") == 0) {
		_g_object_unref0 (self->_constructor);
		self->_constructor = NULL;
	}
	_tmp13_ = s;
	if (g_strcmp0 (_tmp13_, "mouseevents") == 0) {
		_g_object_unref0 (self->_constructor);
		self->_constructor = NULL;
	}
	_tmp14_ = s;
	if (g_strcmp0 (_tmp14_, "touchevent") == 0) {
		_g_object_unref0 (self->_constructor);
		self->_constructor = NULL;
	}
	_tmp15_ = s;
	if (g_strcmp0 (_tmp15_, "uievent") == 0) {
		_g_object_unref0 (self->_constructor);
		self->_constructor = NULL;
	}
	_tmp16_ = s;
	if (g_strcmp0 (_tmp16_, "uievents") == 0) {
		_g_object_unref0 (self->_constructor);
		self->_constructor = NULL;
	}
	_tmp17_ = self->_constructor;
	_tmp18_ = _g_object_ref0 (_tmp17_);
	result = _tmp18_;
	_g_free0 (s);
	return result;
}

static GXmlDomRange*
gxml_xdocument_real_create_range (GXmlDomDocument* base)
{
	GXmlXDocument * self;
	GXmlRange* _tmp0_;
	GXmlDomRange* result;
	self = (GXmlXDocument*) base;
	_tmp0_ = gxml_range_new ((GXmlDomDocument*) self);
	result = (GXmlDomRange*) _tmp0_;
	return result;
}

static GXmlDomNodeIterator*
gxml_xdocument_real_create_node_iterator (GXmlDomDocument* base,
                                          GXmlDomNode* root,
                                          gint what_to_show)
{
	GXmlXDocument * self;
	GXmlNodeIterator* _tmp0_;
	GXmlDomNodeIterator* result;
	self = (GXmlXDocument*) base;
	g_return_val_if_fail (root != NULL, NULL);
	_tmp0_ = gxml_node_iterator_new (root, what_to_show);
	result = (GXmlDomNodeIterator*) _tmp0_;
	return result;
}

static GXmlDomTreeWalker*
gxml_xdocument_real_create_tree_walker (GXmlDomDocument* base,
                                        GXmlDomNode* root,
                                        gint what_to_show)
{
	GXmlXDocument * self;
	GXmlTreeWalker* _tmp0_;
	GXmlDomTreeWalker* result;
	self = (GXmlXDocument*) base;
	g_return_val_if_fail (root != NULL, NULL);
	_tmp0_ = gxml_tree_walker_new (root, what_to_show);
	result = (GXmlDomTreeWalker*) _tmp0_;
	return result;
}

static GXmlDomHTMLCollection*
gxml_xdocument_real_get_children (GXmlDomParentNode* base)
{
	GXmlDomHTMLCollection* result;
	GXmlXDocument* self;
	GXmlDomElementList* l = NULL;
	GXmlDomElementList* _tmp0_;
	self = (GXmlXDocument*) base;
	_tmp0_ = gxml_dom_element_list_new ();
	l = _tmp0_;
	{
		GXmlDomNodeList* _n_list = NULL;
		GXmlDomNodeList* _tmp1_;
		GXmlDomNodeList* _tmp2_;
		gint _n_size = 0;
		GXmlDomNodeList* _tmp3_;
		gint _tmp4_;
		gint _tmp5_;
		gint _n_index = 0;
		_tmp1_ = gxml_dom_node_get_child_nodes ((GXmlDomNode*) self);
		_tmp2_ = _tmp1_;
		_n_list = _tmp2_;
		_tmp3_ = _n_list;
		_tmp4_ = gee_collection_get_size ((GeeCollection*) _tmp3_);
		_tmp5_ = _tmp4_;
		_n_size = _tmp5_;
		_n_index = -1;
		while (TRUE) {
			gint _tmp6_;
			gint _tmp7_;
			GXmlDomNode* n = NULL;
			GXmlDomNodeList* _tmp8_;
			gpointer _tmp9_;
			GXmlDomNode* _tmp10_;
			_n_index = _n_index + 1;
			_tmp6_ = _n_index;
			_tmp7_ = _n_size;
			if (!(_tmp6_ < _tmp7_)) {
				break;
			}
			_tmp8_ = _n_list;
			_tmp9_ = gee_list_get ((GeeList*) _tmp8_, _n_index);
			n = (GXmlDomNode*) _tmp9_;
			_tmp10_ = n;
			if (GXML_IS_DOM_ELEMENT (_tmp10_)) {
				GXmlDomElementList* _tmp11_;
				GXmlDomNode* _tmp12_;
				_tmp11_ = l;
				_tmp12_ = n;
				gee_abstract_collection_add ((GeeAbstractCollection*) _tmp11_, G_TYPE_CHECK_INSTANCE_CAST (_tmp12_, GXML_TYPE_DOM_ELEMENT, GXmlDomElement));
			}
			_g_object_unref0 (n);
		}
		_g_object_unref0 (_n_list);
	}
	result = (GXmlDomHTMLCollection*) l;
	return result;
}

static GXmlDomElement*
gxml_xdocument_real_get_first_element_child (GXmlDomParentNode* base)
{
	GXmlDomElement* result;
	GXmlXDocument* self;
	GXmlDomNodeList* _tmp0_;
	GXmlDomNodeList* _tmp1_;
	GXmlDomNodeList* _tmp2_;
	gpointer _tmp3_;
	GXmlDomElement* _tmp4_;
	self = (GXmlXDocument*) base;
	_tmp0_ = gxml_dom_node_get_child_nodes ((GXmlDomNode*) G_TYPE_CHECK_INSTANCE_CAST (self, GXML_TYPE_DOM_DOCUMENT, GXmlDomDocument));
	_tmp1_ = _tmp0_;
	_tmp2_ = _tmp1_;
	_tmp3_ = gee_list_first ((GeeList*) _tmp2_);
	_tmp4_ = G_TYPE_CHECK_INSTANCE_CAST ((GXmlDomNode*) _tmp3_, GXML_TYPE_DOM_ELEMENT, GXmlDomElement);
	_g_object_unref0 (_tmp2_);
	result = _tmp4_;
	return result;
}

static GXmlDomElement*
gxml_xdocument_real_get_last_element_child (GXmlDomParentNode* base)
{
	GXmlDomElement* result;
	GXmlXDocument* self;
	GXmlDomNodeList* _tmp0_;
	GXmlDomNodeList* _tmp1_;
	GXmlDomNodeList* _tmp2_;
	gpointer _tmp3_;
	GXmlDomElement* _tmp4_;
	self = (GXmlXDocument*) base;
	_tmp0_ = gxml_dom_node_get_child_nodes ((GXmlDomNode*) G_TYPE_CHECK_INSTANCE_CAST (self, GXML_TYPE_DOM_DOCUMENT, GXmlDomDocument));
	_tmp1_ = _tmp0_;
	_tmp2_ = _tmp1_;
	_tmp3_ = gee_list_last ((GeeList*) _tmp2_);
	_tmp4_ = G_TYPE_CHECK_INSTANCE_CAST ((GXmlDomNode*) _tmp3_, GXML_TYPE_DOM_ELEMENT, GXmlDomElement);
	_g_object_unref0 (_tmp2_);
	result = _tmp4_;
	return result;
}

static gint
gxml_xdocument_real_get_child_element_count (GXmlDomParentNode* base)
{
	gint result;
	GXmlXDocument* self;
	GXmlDomNodeList* _tmp0_;
	GXmlDomNodeList* _tmp1_;
	GXmlDomNodeList* _tmp2_;
	gint _tmp3_;
	gint _tmp4_;
	gint _tmp5_;
	self = (GXmlXDocument*) base;
	_tmp0_ = gxml_dom_node_get_child_nodes ((GXmlDomNode*) self);
	_tmp1_ = _tmp0_;
	_tmp2_ = _tmp1_;
	_tmp3_ = gee_collection_get_size ((GeeCollection*) _tmp2_);
	_tmp4_ = _tmp3_;
	_tmp5_ = _tmp4_;
	_g_object_unref0 (_tmp2_);
	result = _tmp5_;
	return result;
}

static GXmlDomNodeList*
gxml_xdocument_real_query_selector_all (GXmlDomParentNode* base,
                                        const gchar* selectors,
                                        GError** error)
{
	GXmlXDocument * self;
	GXmlCssSelectorParser* cs = NULL;
	GXmlCssSelectorParser* _tmp0_;
	GXmlCssSelectorParser* _tmp1_;
	GXmlNodeList* l = NULL;
	GXmlNodeList* _tmp2_;
	GError* _inner_error0_ = NULL;
	GXmlDomNodeList* result;
	self = (GXmlXDocument*) base;
	g_return_val_if_fail (selectors != NULL, NULL);
	_tmp0_ = gxml_css_selector_parser_new ();
	cs = _tmp0_;
	_tmp1_ = cs;
	gxml_css_selector_parser_parse (_tmp1_, selectors, &_inner_error0_);
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		g_propagate_error (error, _inner_error0_);
		_g_object_unref0 (cs);
		return NULL;
	}
	_tmp2_ = gxml_node_list_new ();
	l = _tmp2_;
	{
		GeeBidirList* _e_list = NULL;
		GeeBidirList* _tmp3_;
		GeeBidirList* _tmp4_;
		gint _e_size = 0;
		GeeBidirList* _tmp5_;
		gint _tmp6_;
		gint _tmp7_;
		gint _e_index = 0;
		_tmp3_ = gxml_xnode_get_children_nodes ((GXmlXNode*) self);
		_tmp4_ = _tmp3_;
		_e_list = _tmp4_;
		_tmp5_ = _e_list;
		_tmp6_ = gee_collection_get_size ((GeeCollection*) _tmp5_);
		_tmp7_ = _tmp6_;
		_e_size = _tmp7_;
		_e_index = -1;
		while (TRUE) {
			gint _tmp8_;
			gint _tmp9_;
			GXmlDomNode* e = NULL;
			GeeBidirList* _tmp10_;
			gpointer _tmp11_;
			GXmlDomNode* _tmp12_;
			gboolean _tmp13_ = FALSE;
			GXmlCssSelectorParser* _tmp14_;
			GXmlDomNode* _tmp15_;
			GXmlDomNodeList* _tmp18_ = NULL;
			GXmlCssSelectorParser* _tmp19_;
			GXmlDomNode* _tmp20_;
			GXmlDomNodeList* _tmp21_;
			GXmlNodeList* _tmp22_;
			_e_index = _e_index + 1;
			_tmp8_ = _e_index;
			_tmp9_ = _e_size;
			if (!(_tmp8_ < _tmp9_)) {
				break;
			}
			_tmp10_ = _e_list;
			_tmp11_ = gee_list_get ((GeeList*) _tmp10_, _e_index);
			e = (GXmlDomNode*) _tmp11_;
			_tmp12_ = e;
			if (!GXML_IS_DOM_ELEMENT (_tmp12_)) {
				_g_object_unref0 (e);
				continue;
			}
			_tmp14_ = cs;
			_tmp15_ = e;
			_tmp13_ = gxml_css_selector_parser_match (_tmp14_, GXML_IS_DOM_ELEMENT (_tmp15_) ? ((GXmlDomElement*) _tmp15_) : NULL, &_inner_error0_);
			if (G_UNLIKELY (_inner_error0_ != NULL)) {
				g_propagate_error (error, _inner_error0_);
				_g_object_unref0 (e);
				_g_object_unref0 (_e_list);
				_g_object_unref0 (l);
				_g_object_unref0 (cs);
				return NULL;
			}
			if (_tmp13_) {
				GXmlNodeList* _tmp16_;
				GXmlDomNode* _tmp17_;
				_tmp16_ = l;
				_tmp17_ = e;
				gee_abstract_collection_add ((GeeAbstractCollection*) _tmp16_, GXML_IS_DOM_NODE (_tmp17_) ? ((GXmlDomNode*) _tmp17_) : NULL);
			}
			_tmp19_ = cs;
			_tmp20_ = e;
			_tmp21_ = gxml_css_selector_parser_query_selector_all (_tmp19_, GXML_IS_DOM_ELEMENT (_tmp20_) ? ((GXmlDomElement*) _tmp20_) : NULL, &_inner_error0_);
			_tmp18_ = _tmp21_;
			if (G_UNLIKELY (_inner_error0_ != NULL)) {
				g_propagate_error (error, _inner_error0_);
				_g_object_unref0 (e);
				_g_object_unref0 (_e_list);
				_g_object_unref0 (l);
				_g_object_unref0 (cs);
				return NULL;
			}
			_tmp22_ = l;
			gee_array_list_add_all ((GeeArrayList*) _tmp22_, (GeeCollection*) _tmp18_);
			_g_object_unref0 (_tmp18_);
			_g_object_unref0 (e);
		}
		_g_object_unref0 (_e_list);
	}
	result = (GXmlDomNodeList*) l;
	_g_object_unref0 (cs);
	return result;
}

static GXmlDomElement*
gxml_xdocument_real_get_element_by_id (GXmlDomNonElementParentNode* base,
                                       const gchar* element_id,
                                       GError** error)
{
	GXmlXDocument * self;
	GXmlDomElementList* l = NULL;
	GXmlDomElementList* _tmp0_;
	GXmlDomElementList* _tmp1_;
	gint _tmp2_;
	gint _tmp3_;
	GXmlDomElement* result;
	self = (GXmlXDocument*) base;
	g_return_val_if_fail (element_id != NULL, NULL);
	_tmp0_ = gxml_dom_parent_node_get_elements_by_property_value ((GXmlDomParentNode*) self, "id", element_id);
	l = _tmp0_;
	_tmp1_ = l;
	_tmp2_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) _tmp1_);
	_tmp3_ = _tmp2_;
	if (_tmp3_ > 0) {
		GXmlDomElementList* _tmp4_;
		gpointer _tmp5_;
		_tmp4_ = l;
		_tmp5_ = gee_abstract_list_get ((GeeAbstractList*) _tmp4_, 0);
		result = G_TYPE_CHECK_INSTANCE_CAST ((GXmlDomElement*) _tmp5_, GXML_TYPE_DOM_ELEMENT, GXmlDomElement);
		_g_object_unref0 (l);
		return result;
	}
	result = NULL;
	_g_object_unref0 (l);
	return result;
}

/**
   * {@link XPathContext} implementation.
   */
static GXmlXPathObject*
gxml_xdocument_real_evaluate (GXmlXPathContext* base,
                              const gchar* expression,
                              GeeMap* resolver,
                              GError** error)
{
	GXmlXDocument * self;
	GXmlXPathObject* nullobj = NULL;
	GXmlDomElement* _tmp0_;
	GXmlDomElement* _tmp1_;
	GXmlDomElement* _tmp2_;
	gboolean _tmp3_;
	GXmlXPathObject* _tmp4_ = NULL;
	GXmlDomElement* _tmp5_;
	GXmlDomElement* _tmp6_;
	GXmlXPathContext* _tmp7_;
	GXmlXPathObject* _tmp8_;
	GXmlXPathObject* _tmp9_;
	GXmlXPathObject* _tmp10_;
	GError* _inner_error0_ = NULL;
	GXmlXPathObject* result;
	self = (GXmlXDocument*) base;
	g_return_val_if_fail (expression != NULL, NULL);
	nullobj = NULL;
	_tmp0_ = gxml_dom_document_get_document_element ((GXmlDomDocument*) self);
	_tmp1_ = _tmp0_;
	_tmp2_ = _tmp1_;
	_tmp3_ = _tmp2_ == NULL;
	_g_object_unref0 (_tmp2_);
	if (_tmp3_) {
		result = nullobj;
		return result;
	}
	_tmp5_ = gxml_dom_document_get_document_element ((GXmlDomDocument*) self);
	_tmp6_ = _tmp5_;
	_tmp7_ = G_TYPE_CHECK_INSTANCE_CAST (_tmp6_, GXML_TYPE_XPATH_CONTEXT, GXmlXPathContext);
	_tmp8_ = gxml_xpath_context_evaluate (_tmp7_, expression, resolver, &_inner_error0_);
	_tmp9_ = _tmp8_;
	_g_object_unref0 (_tmp7_);
	_tmp4_ = _tmp9_;
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		if (_inner_error0_->domain == GXML_XPATH_OBJECT_ERROR) {
			g_propagate_error (error, _inner_error0_);
			_g_object_unref0 (nullobj);
			return NULL;
		} else {
			_g_object_unref0 (nullobj);
			g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
			g_clear_error (&_inner_error0_);
			return NULL;
		}
	}
	_tmp10_ = _tmp4_;
	_tmp4_ = NULL;
	result = _tmp10_;
	_g_object_unref0 (_tmp4_);
	_g_object_unref0 (nullobj);
	return result;
}

static GObject *
gxml_xdocument_constructor (GType type,
                            guint n_construct_properties,
                            GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	GXmlXDocument * self;
	parent_class = G_OBJECT_CLASS (gxml_xdocument_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GXML_TYPE_XDOCUMENT, GXmlXDocument);
	((GXmlXNode*) self)->_node = NULL;
	return obj;
}

static void
gxml_xdocument_class_init (GXmlXDocumentClass * klass,
                           gpointer klass_data)
{
	gxml_xdocument_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &GXmlXDocument_private_offset);
	((GXmlXNodeClass *) klass)->set_namespace = (gboolean (*) (GXmlXNode*, const gchar*, const gchar*)) gxml_xdocument_real_set_namespace;
	((GXmlXNodeClass *) klass)->to_string = (gchar* (*) (GXmlXNode*)) gxml_xdocument_real_to_string;
	((GXmlXDocumentClass *) klass)->save = (gboolean (*) (GXmlXDocument*, GCancellable*, GError**)) gxml_xdocument_real_save;
	((GXmlXDocumentClass *) klass)->save_as = (gboolean (*) (GXmlXDocument*, GFile*, GCancellable*, GError**)) gxml_xdocument_real_save_as;
	GXML_XNODE_CLASS (klass)->get_attrs = (GeeMap* (*) (GXmlXNode*)) gxml_xdocument_real_get_attrs;
	GXML_XNODE_CLASS (klass)->get_children_nodes = (GeeBidirList* (*) (GXmlXNode*)) gxml_xdocument_real_get_children_nodes;
	GXML_XNODE_CLASS (klass)->get_document = (GXmlDomDocument* (*) (GXmlXNode*)) gxml_xdocument_real_get_document;
	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)->constructor = gxml_xdocument_constructor;
	G_OBJECT_CLASS (klass)->finalize = gxml_xdocument_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), GXML_XDOCUMENT_ATTRS_PROPERTY, gxml_xdocument_properties[GXML_XDOCUMENT_ATTRS_PROPERTY] = g_param_spec_object ("attrs", "attrs", "attrs", GEE_TYPE_MAP, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GXML_XDOCUMENT_CHILDREN_NODES_PROPERTY, gxml_xdocument_properties[GXML_XDOCUMENT_CHILDREN_NODES_PROPERTY] = g_param_spec_object ("children-nodes", "children-nodes", "children-nodes", GEE_TYPE_BIDIR_LIST, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GXML_XDOCUMENT_DOCUMENT_PROPERTY, gxml_xdocument_properties[GXML_XDOCUMENT_DOCUMENT_PROPERTY] = g_param_spec_object ("document", "document", "document", GXML_TYPE_DOM_DOCUMENT, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GXML_XDOCUMENT_INDENT_PROPERTY, gxml_xdocument_properties[GXML_XDOCUMENT_INDENT_PROPERTY] = g_param_spec_boolean ("indent", "indent", "indent", FALSE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GXML_XDOCUMENT_NS_TOP_PROPERTY, gxml_xdocument_properties[GXML_XDOCUMENT_NS_TOP_PROPERTY] = g_param_spec_boolean ("ns-top", "ns-top", "ns-top", FALSE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GXML_XDOCUMENT_PREFIX_DEFAULT_NS_PROPERTY, gxml_xdocument_properties[GXML_XDOCUMENT_PREFIX_DEFAULT_NS_PROPERTY] = g_param_spec_boolean ("prefix-default-ns", "prefix-default-ns", "prefix-default-ns", FALSE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GXML_XDOCUMENT_BACKUP_PROPERTY, gxml_xdocument_properties[GXML_XDOCUMENT_BACKUP_PROPERTY] = g_param_spec_boolean ("backup", "backup", "backup", TRUE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GXML_XDOCUMENT_FILE_PROPERTY, gxml_xdocument_properties[GXML_XDOCUMENT_FILE_PROPERTY] = g_param_spec_object ("file", "file", "file", g_file_get_type (), G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GXML_XDOCUMENT_ROOT_PROPERTY, gxml_xdocument_properties[GXML_XDOCUMENT_ROOT_PROPERTY] = g_param_spec_object ("root", "root", "root", GXML_TYPE_DOM_NODE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GXML_XDOCUMENT_IMPLEMENTATION_PROPERTY, gxml_xdocument_properties[GXML_XDOCUMENT_IMPLEMENTATION_PROPERTY] = g_param_spec_object ("implementation", "implementation", "implementation", GXML_TYPE_DOM_IMPLEMENTATION, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GXML_XDOCUMENT_URL_PROPERTY, gxml_xdocument_properties[GXML_XDOCUMENT_URL_PROPERTY] = g_param_spec_string ("url", "url", "url", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GXML_XDOCUMENT_DOCUMENT_URI_PROPERTY, gxml_xdocument_properties[GXML_XDOCUMENT_DOCUMENT_URI_PROPERTY] = g_param_spec_string ("document-uri", "document-uri", "document-uri", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GXML_XDOCUMENT_ORIGIN_PROPERTY, gxml_xdocument_properties[GXML_XDOCUMENT_ORIGIN_PROPERTY] = g_param_spec_string ("origin", "origin", "origin", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GXML_XDOCUMENT_COMPAT_MODE_PROPERTY, gxml_xdocument_properties[GXML_XDOCUMENT_COMPAT_MODE_PROPERTY] = g_param_spec_string ("compat-mode", "compat-mode", "compat-mode", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GXML_XDOCUMENT_CHARACTER_SET_PROPERTY, gxml_xdocument_properties[GXML_XDOCUMENT_CHARACTER_SET_PROPERTY] = g_param_spec_string ("character-set", "character-set", "character-set", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GXML_XDOCUMENT_CONTENT_TYPE_PROPERTY, gxml_xdocument_properties[GXML_XDOCUMENT_CONTENT_TYPE_PROPERTY] = g_param_spec_string ("content-type", "content-type", "content-type", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GXML_XDOCUMENT_DOCTYPE_PROPERTY, gxml_xdocument_properties[GXML_XDOCUMENT_DOCTYPE_PROPERTY] = g_param_spec_object ("doctype", "doctype", "doctype", GXML_TYPE_DOM_DOCUMENT_TYPE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GXML_XDOCUMENT_DOCUMENT_ELEMENT_PROPERTY, gxml_xdocument_properties[GXML_XDOCUMENT_DOCUMENT_ELEMENT_PROPERTY] = g_param_spec_object ("document-element", "document-element", "document-element", GXML_TYPE_DOM_ELEMENT, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GXML_XDOCUMENT_CHILDREN_PROPERTY, gxml_xdocument_properties[GXML_XDOCUMENT_CHILDREN_PROPERTY] = g_param_spec_object ("children", "children", "children", GXML_TYPE_DOM_HTML_COLLECTION, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GXML_XDOCUMENT_FIRST_ELEMENT_CHILD_PROPERTY, gxml_xdocument_properties[GXML_XDOCUMENT_FIRST_ELEMENT_CHILD_PROPERTY] = g_param_spec_object ("first-element-child", "first-element-child", "first-element-child", GXML_TYPE_DOM_ELEMENT, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GXML_XDOCUMENT_LAST_ELEMENT_CHILD_PROPERTY, gxml_xdocument_properties[GXML_XDOCUMENT_LAST_ELEMENT_CHILD_PROPERTY] = g_param_spec_object ("last-element-child", "last-element-child", "last-element-child", GXML_TYPE_DOM_ELEMENT, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GXML_XDOCUMENT_CHILD_ELEMENT_COUNT_PROPERTY, gxml_xdocument_properties[GXML_XDOCUMENT_CHILD_ELEMENT_COUNT_PROPERTY] = g_param_spec_int ("child-element-count", "child-element-count", "child-element-count", G_MININT, G_MAXINT, 0, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
}

static void
gxml_xdocument_gxml_dom_parent_node_interface_init (GXmlDomParentNodeIface * iface,
                                                    gpointer iface_data)
{
	gxml_xdocument_gxml_dom_parent_node_parent_iface = g_type_interface_peek_parent (iface);
	iface->query_selector_all = (GXmlDomNodeList* (*) (GXmlDomParentNode*, const gchar*, GError**)) gxml_xdocument_real_query_selector_all;
	iface->get_children = gxml_xdocument_real_get_children;
	iface->get_first_element_child = gxml_xdocument_real_get_first_element_child;
	iface->get_last_element_child = gxml_xdocument_real_get_last_element_child;
	iface->get_child_element_count = gxml_xdocument_real_get_child_element_count;
}

static void
gxml_xdocument_gxml_dom_non_element_parent_node_interface_init (GXmlDomNonElementParentNodeIface * iface,
                                                                gpointer iface_data)
{
	gxml_xdocument_gxml_dom_non_element_parent_node_parent_iface = g_type_interface_peek_parent (iface);
	iface->get_element_by_id = (GXmlDomElement* (*) (GXmlDomNonElementParentNode*, const gchar*, GError**)) gxml_xdocument_real_get_element_by_id;
}

static void
gxml_xdocument_gxml_dom_document_interface_init (GXmlDomDocumentIface * iface,
                                                 gpointer iface_data)
{
	gxml_xdocument_gxml_dom_document_parent_iface = g_type_interface_peek_parent (iface);
	iface->get_xml_parser = (GXmlParser* (*) (GXmlDomDocument*)) gxml_xdocument_real_gxml_dom_document_get_xml_parser;
	iface->set_xml_parser = (void (*) (GXmlDomDocument*, GXmlParser*)) gxml_xdocument_real_set_xml_parser;
	iface->create_element = (GXmlDomElement* (*) (GXmlDomDocument*, const gchar*, GError**)) gxml_xdocument_real_gxml_dom_document_create_element;
	iface->create_element_ns = (GXmlDomElement* (*) (GXmlDomDocument*, const gchar*, const gchar*, GError**)) gxml_xdocument_real_gxml_dom_document_create_element_ns;
	iface->get_elements_by_tag_name = (GXmlDomHTMLCollection* (*) (GXmlDomDocument*, const gchar*)) gxml_xdocument_real_get_elements_by_tag_name;
	iface->get_elements_by_tag_name_ns = (GXmlDomHTMLCollection* (*) (GXmlDomDocument*, const gchar*, const gchar*)) gxml_xdocument_real_get_elements_by_tag_name_ns;
	iface->get_elements_by_class_name = (GXmlDomHTMLCollection* (*) (GXmlDomDocument*, const gchar*)) gxml_xdocument_real_get_elements_by_class_name;
	iface->create_document_fragment = (GXmlDomDocumentFragment* (*) (GXmlDomDocument*)) gxml_xdocument_real_create_document_fragment;
	iface->create_text_node = (GXmlDomText* (*) (GXmlDomDocument*, const gchar*, GError**)) gxml_xdocument_real_create_text_node;
	iface->create_comment = (GXmlDomComment* (*) (GXmlDomDocument*, const gchar*, GError**)) gxml_xdocument_real_gxml_dom_document_create_comment;
	iface->create_processing_instruction = (GXmlDomProcessingInstruction* (*) (GXmlDomDocument*, const gchar*, const gchar*, GError**)) gxml_xdocument_real_create_processing_instruction;
	iface->import_node = (GXmlDomNode* (*) (GXmlDomDocument*, GXmlDomNode*, gboolean, GError**)) gxml_xdocument_real_import_node;
	iface->adopt_node = (GXmlDomNode* (*) (GXmlDomDocument*, GXmlDomNode*, GError**)) gxml_xdocument_real_adopt_node;
	iface->create_event = (GXmlDomEvent* (*) (GXmlDomDocument*, const gchar*, GError**)) gxml_xdocument_real_create_event;
	iface->create_range = (GXmlDomRange* (*) (GXmlDomDocument*)) gxml_xdocument_real_create_range;
	iface->create_node_iterator = (GXmlDomNodeIterator* (*) (GXmlDomDocument*, GXmlDomNode*, gint)) gxml_xdocument_real_create_node_iterator;
	iface->create_tree_walker = (GXmlDomTreeWalker* (*) (GXmlDomDocument*, GXmlDomNode*, gint)) gxml_xdocument_real_create_tree_walker;
	iface->get_implementation = gxml_xdocument_real_get_implementation;
	iface->get_url = gxml_xdocument_real_get_url;
	iface->get_document_uri = gxml_xdocument_real_get_document_uri;
	iface->get_origin = gxml_xdocument_real_get_origin;
	iface->get_compat_mode = gxml_xdocument_real_get_compat_mode;
	iface->get_character_set = gxml_xdocument_real_get_character_set;
	iface->get_content_type = gxml_xdocument_real_get_content_type;
	iface->get_doctype = gxml_xdocument_real_get_doctype;
	iface->get_document_element = gxml_xdocument_real_get_document_element;
}

static void
gxml_xdocument_gxml_dom_xml_document_interface_init (GXmlDomXMLDocumentIface * iface,
                                                     gpointer iface_data)
{
	gxml_xdocument_gxml_dom_xml_document_parent_iface = g_type_interface_peek_parent (iface);
}

static void
gxml_xdocument_gxml_xpath_context_interface_init (GXmlXPathContextIface * iface,
                                                  gpointer iface_data)
{
	gxml_xdocument_gxml_xpath_context_parent_iface = g_type_interface_peek_parent (iface);
	iface->evaluate = (GXmlXPathObject* (*) (GXmlXPathContext*, const gchar*, GeeMap*, GError**)) gxml_xdocument_real_evaluate;
}

static void
gxml_xdocument_instance_init (GXmlXDocument * self,
                              gpointer klass)
{
	GXmlXImplementation* _tmp0_;
	gchar* _tmp1_;
	gchar* _tmp2_;
	gchar* _tmp3_;
	gchar* _tmp4_;
	gchar* _tmp5_;
	self->priv = gxml_xdocument_get_instance_private (self);
	self->_parser = NULL;
	self->priv->_indent = FALSE;
	self->priv->_ns_top = FALSE;
	self->priv->_prefix_default_ns = FALSE;
	self->priv->_backup = TRUE;
	_tmp0_ = gxml_ximplementation_new ();
	self->_implementation = (GXmlDomImplementation*) _tmp0_;
	_tmp1_ = g_strdup ("about:blank");
	self->_url = _tmp1_;
	_tmp2_ = g_strdup ("");
	self->_origin = _tmp2_;
	_tmp3_ = g_strdup ("");
	self->_compat_mode = _tmp3_;
	_tmp4_ = g_strdup ("utf-8");
	self->_character_set = _tmp4_;
	_tmp5_ = g_strdup ("application/xml");
	self->_content_type = _tmp5_;
}

static void
gxml_xdocument_finalize (GObject * obj)
{
	GXmlXDocument * self;
	xmlDoc* _tmp0_;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GXML_TYPE_XDOCUMENT, GXmlXDocument);
	_tmp0_ = self->doc;
	_xmlFreeDoc0 (_tmp0_);
	_xmlBufferFree0 (self->_buffer);
	_g_object_unref0 (self->_parser);
	_g_object_unref0 (self->priv->_file);
	_g_object_unref0 (self->_implementation);
	_g_free0 (self->_url);
	_g_free0 (self->_origin);
	_g_free0 (self->_compat_mode);
	_g_free0 (self->_character_set);
	_g_free0 (self->_content_type);
	_g_object_unref0 (self->_constructor);
	G_OBJECT_CLASS (gxml_xdocument_parent_class)->finalize (obj);
}

/**
 * DOM4 class implementing {@link GXml.DomDocument} and {GXml.DomDocument} interface,
 * powered by libxml-2.0 library.
 *
 * This class use {@link Xml.TextWriter} to write down XML documents using
 * its contained {@link GXml.DomNode} children or other XML structures.
 */
static GType
gxml_xdocument_get_type_once (void)
{
	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_dom_parent_node_info = { (GInterfaceInitFunc) gxml_xdocument_gxml_dom_parent_node_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
	static const GInterfaceInfo gxml_dom_non_element_parent_node_info = { (GInterfaceInitFunc) gxml_xdocument_gxml_dom_non_element_parent_node_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
	static const GInterfaceInfo gxml_dom_document_info = { (GInterfaceInitFunc) gxml_xdocument_gxml_dom_document_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
	static const GInterfaceInfo gxml_dom_xml_document_info = { (GInterfaceInitFunc) gxml_xdocument_gxml_dom_xml_document_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
	static const GInterfaceInfo gxml_xpath_context_info = { (GInterfaceInitFunc) gxml_xdocument_gxml_xpath_context_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_DOM_PARENT_NODE, &gxml_dom_parent_node_info);
	g_type_add_interface_static (gxml_xdocument_type_id, GXML_TYPE_DOM_NON_ELEMENT_PARENT_NODE, &gxml_dom_non_element_parent_node_info);
	g_type_add_interface_static (gxml_xdocument_type_id, GXML_TYPE_DOM_DOCUMENT, &gxml_dom_document_info);
	g_type_add_interface_static (gxml_xdocument_type_id, GXML_TYPE_DOM_XML_DOCUMENT, &gxml_dom_xml_document_info);
	g_type_add_interface_static (gxml_xdocument_type_id, GXML_TYPE_XPATH_CONTEXT, &gxml_xpath_context_info);
	GXmlXDocument_private_offset = g_type_add_instance_private (gxml_xdocument_type_id, sizeof (GXmlXDocumentPrivate));
	return gxml_xdocument_type_id;
}

GType
gxml_xdocument_get_type (void)
{
	static volatile gsize gxml_xdocument_type_id__once = 0;
	if (g_once_init_enter (&gxml_xdocument_type_id__once)) {
		GType gxml_xdocument_type_id;
		gxml_xdocument_type_id = gxml_xdocument_get_type_once ();
		g_once_init_leave (&gxml_xdocument_type_id__once, gxml_xdocument_type_id);
	}
	return gxml_xdocument_type_id__once;
}

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_ATTRS_PROPERTY:
		g_value_take_object (value, gxml_xnode_get_attrs ((GXmlXNode*) self));
		break;
		case GXML_XDOCUMENT_CHILDREN_NODES_PROPERTY:
		g_value_take_object (value, gxml_xnode_get_children_nodes ((GXmlXNode*) self));
		break;
		case GXML_XDOCUMENT_DOCUMENT_PROPERTY:
		g_value_set_object (value, gxml_xnode_get_document ((GXmlXNode*) self));
		break;
		case GXML_XDOCUMENT_INDENT_PROPERTY:
		g_value_set_boolean (value, gxml_xdocument_get_indent (self));
		break;
		case GXML_XDOCUMENT_NS_TOP_PROPERTY:
		g_value_set_boolean (value, gxml_xdocument_get_ns_top (self));
		break;
		case GXML_XDOCUMENT_PREFIX_DEFAULT_NS_PROPERTY:
		g_value_set_boolean (value, gxml_xdocument_get_prefix_default_ns (self));
		break;
		case GXML_XDOCUMENT_BACKUP_PROPERTY:
		g_value_set_boolean (value, gxml_xdocument_get_backup (self));
		break;
		case GXML_XDOCUMENT_FILE_PROPERTY:
		g_value_set_object (value, gxml_xdocument_get_file (self));
		break;
		case GXML_XDOCUMENT_ROOT_PROPERTY:
		g_value_take_object (value, gxml_xdocument_get_root (self));
		break;
		case GXML_XDOCUMENT_IMPLEMENTATION_PROPERTY:
		g_value_set_object (value, gxml_dom_document_get_implementation ((GXmlDomDocument*) self));
		break;
		case GXML_XDOCUMENT_URL_PROPERTY:
		g_value_set_string (value, gxml_dom_document_get_url ((GXmlDomDocument*) self));
		break;
		case GXML_XDOCUMENT_DOCUMENT_URI_PROPERTY:
		g_value_set_string (value, gxml_dom_document_get_document_uri ((GXmlDomDocument*) self));
		break;
		case GXML_XDOCUMENT_ORIGIN_PROPERTY:
		g_value_set_string (value, gxml_dom_document_get_origin ((GXmlDomDocument*) self));
		break;
		case GXML_XDOCUMENT_COMPAT_MODE_PROPERTY:
		g_value_set_string (value, gxml_dom_document_get_compat_mode ((GXmlDomDocument*) self));
		break;
		case GXML_XDOCUMENT_CHARACTER_SET_PROPERTY:
		g_value_set_string (value, gxml_dom_document_get_character_set ((GXmlDomDocument*) self));
		break;
		case GXML_XDOCUMENT_CONTENT_TYPE_PROPERTY:
		g_value_set_string (value, gxml_dom_document_get_content_type ((GXmlDomDocument*) self));
		break;
		case GXML_XDOCUMENT_DOCTYPE_PROPERTY:
		g_value_take_object (value, gxml_dom_document_get_doctype ((GXmlDomDocument*) self));
		break;
		case GXML_XDOCUMENT_DOCUMENT_ELEMENT_PROPERTY:
		g_value_take_object (value, gxml_dom_document_get_document_element ((GXmlDomDocument*) self));
		break;
		case GXML_XDOCUMENT_CHILDREN_PROPERTY:
		g_value_take_object (value, gxml_dom_parent_node_get_children ((GXmlDomParentNode*) self));
		break;
		case GXML_XDOCUMENT_FIRST_ELEMENT_CHILD_PROPERTY:
		g_value_take_object (value, gxml_dom_parent_node_get_first_element_child ((GXmlDomParentNode*) self));
		break;
		case GXML_XDOCUMENT_LAST_ELEMENT_CHILD_PROPERTY:
		g_value_take_object (value, gxml_dom_parent_node_get_last_element_child ((GXmlDomParentNode*) self));
		break;
		case GXML_XDOCUMENT_CHILD_ELEMENT_COUNT_PROPERTY:
		g_value_set_int (value, gxml_dom_parent_node_get_child_element_count ((GXmlDomParentNode*) 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_INDENT_PROPERTY:
		gxml_xdocument_set_indent (self, g_value_get_boolean (value));
		break;
		case GXML_XDOCUMENT_NS_TOP_PROPERTY:
		gxml_xdocument_set_ns_top (self, g_value_get_boolean (value));
		break;
		case GXML_XDOCUMENT_PREFIX_DEFAULT_NS_PROPERTY:
		gxml_xdocument_set_prefix_default_ns (self, g_value_get_boolean (value));
		break;
		case GXML_XDOCUMENT_BACKUP_PROPERTY:
		gxml_xdocument_set_backup (self, g_value_get_boolean (value));
		break;
		case GXML_XDOCUMENT_FILE_PROPERTY:
		gxml_xdocument_set_file (self, g_value_get_object (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static GXmlDomDocumentType*
gxml_ximplementation_real_create_document_type (GXmlDomImplementation* base,
                                                const gchar* qualified_name,
                                                const gchar* public_id,
                                                const gchar* system_id,
                                                GError** error)
{
	GXmlXImplementation * self;
	GXmlXDocumentType* _tmp0_;
	GXmlDomDocumentType* result;
	self = (GXmlXImplementation*) base;
	g_return_val_if_fail (qualified_name != NULL, NULL);
	g_return_val_if_fail (public_id != NULL, NULL);
	g_return_val_if_fail (system_id != NULL, NULL);
	_tmp0_ = gxml_xdocument_type_new_with_ids (qualified_name, public_id, system_id);
	result = (GXmlDomDocumentType*) _tmp0_;
	return result;
}

static GXmlDomXMLDocument*
gxml_ximplementation_real_create_document (GXmlDomImplementation* base,
                                           const gchar* namespace,
                                           const gchar* qualified_name,
                                           GXmlDomDocumentType* doctype,
                                           GError** error)
{
	GXmlXImplementation * self;
	GXmlXDocument* _tmp0_;
	GXmlDomXMLDocument* result;
	self = (GXmlXImplementation*) base;
	_tmp0_ = gxml_xdocument_new ();
	result = (GXmlDomXMLDocument*) _tmp0_;
	return result;
}

static GXmlDomDocument*
gxml_ximplementation_real_create_html_document (GXmlDomImplementation* base,
                                                const gchar* title)
{
	GXmlXImplementation * self;
	GXmlXHtmlDocument* _tmp0_;
	GXmlDomDocument* result;
	self = (GXmlXImplementation*) base;
	g_return_val_if_fail (title != NULL, NULL);
	_tmp0_ = gxml_xhtml_document_new ();
	result = (GXmlDomDocument*) _tmp0_;
	return result;
}

GXmlXImplementation*
gxml_ximplementation_construct (GType object_type)
{
	GXmlXImplementation * self = NULL;
	self = (GXmlXImplementation*) g_object_new (object_type, NULL);
	return self;
}

GXmlXImplementation*
gxml_ximplementation_new (void)
{
	return gxml_ximplementation_construct (GXML_TYPE_XIMPLEMENTATION);
}

static void
gxml_ximplementation_class_init (GXmlXImplementationClass * klass,
                                 gpointer klass_data)
{
	gxml_ximplementation_parent_class = g_type_class_peek_parent (klass);
}

static void
gxml_ximplementation_gxml_dom_implementation_interface_init (GXmlDomImplementationIface * iface,
                                                             gpointer iface_data)
{
	gxml_ximplementation_gxml_dom_implementation_parent_iface = g_type_interface_peek_parent (iface);
	iface->create_document_type = (GXmlDomDocumentType* (*) (GXmlDomImplementation*, const gchar*, const gchar*, const gchar*, GError**)) gxml_ximplementation_real_create_document_type;
	iface->create_document = (GXmlDomXMLDocument* (*) (GXmlDomImplementation*, const gchar*, const gchar*, GXmlDomDocumentType*, GError**)) gxml_ximplementation_real_create_document;
	iface->create_html_document = (GXmlDomDocument* (*) (GXmlDomImplementation*, const gchar*)) gxml_ximplementation_real_create_html_document;
}

static void
gxml_ximplementation_instance_init (GXmlXImplementation * self,
                                    gpointer klass)
{
}

static GType
gxml_ximplementation_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (GXmlXImplementationClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) gxml_ximplementation_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GXmlXImplementation), 0, (GInstanceInitFunc) gxml_ximplementation_instance_init, NULL };
	static const GInterfaceInfo gxml_dom_implementation_info = { (GInterfaceInitFunc) gxml_ximplementation_gxml_dom_implementation_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
	GType gxml_ximplementation_type_id;
	gxml_ximplementation_type_id = g_type_register_static (G_TYPE_OBJECT, "GXmlXImplementation", &g_define_type_info, 0);
	g_type_add_interface_static (gxml_ximplementation_type_id, GXML_TYPE_DOM_IMPLEMENTATION, &gxml_dom_implementation_info);
	return gxml_ximplementation_type_id;
}

GType
gxml_ximplementation_get_type (void)
{
	static volatile gsize gxml_ximplementation_type_id__once = 0;
	if (g_once_init_enter (&gxml_ximplementation_type_id__once)) {
		GType gxml_ximplementation_type_id;
		gxml_ximplementation_type_id = gxml_ximplementation_get_type_once ();
		g_once_init_leave (&gxml_ximplementation_type_id__once, gxml_ximplementation_type_id);
	}
	return gxml_ximplementation_type_id__once;
}

static const gchar*
gxml_xdocument_type_real_get_name (GXmlDomDocumentType* base)
{
	const gchar* result;
	GXmlXDocumentType* self;
	const gchar* _tmp0_;
	self = (GXmlXDocumentType*) base;
	_tmp0_ = self->_name;
	result = _tmp0_;
	return result;
}

static const gchar*
gxml_xdocument_type_real_get_public_id (GXmlDomDocumentType* base)
{
	const gchar* result;
	GXmlXDocumentType* self;
	const gchar* _tmp0_;
	self = (GXmlXDocumentType*) base;
	_tmp0_ = self->_public_id;
	result = _tmp0_;
	return result;
}

static const gchar*
gxml_xdocument_type_real_get_system_id (GXmlDomDocumentType* base)
{
	const gchar* result;
	GXmlXDocumentType* self;
	const gchar* _tmp0_;
	self = (GXmlXDocumentType*) base;
	_tmp0_ = self->_system_id;
	result = _tmp0_;
	return result;
}

GXmlXDocumentType*
gxml_xdocument_type_construct_with_name (GType object_type,
                                         const gchar* name)
{
	GXmlXDocumentType * self = NULL;
	gchar* _tmp0_;
	gchar* _tmp1_;
	gchar* _tmp2_;
	g_return_val_if_fail (name != NULL, NULL);
	self = (GXmlXDocumentType*) gxml_xchild_node_construct (object_type);
	_tmp0_ = g_strdup (name);
	_g_free0 (self->_name);
	self->_name = _tmp0_;
	_tmp1_ = g_strdup ("");
	_g_free0 (self->_public_id);
	self->_public_id = _tmp1_;
	_tmp2_ = g_strdup ("");
	_g_free0 (self->_system_id);
	self->_system_id = _tmp2_;
	return self;
}

GXmlXDocumentType*
gxml_xdocument_type_new_with_name (const gchar* name)
{
	return gxml_xdocument_type_construct_with_name (GXML_TYPE_XDOCUMENT_TYPE, name);
}

GXmlXDocumentType*
gxml_xdocument_type_construct_with_ids (GType object_type,
                                        const gchar* name,
                                        const gchar* public_id,
                                        const gchar* system_id)
{
	GXmlXDocumentType * self = NULL;
	gchar* _tmp0_;
	gchar* _tmp1_;
	gchar* _tmp2_;
	g_return_val_if_fail (name != NULL, NULL);
	g_return_val_if_fail (public_id != NULL, NULL);
	g_return_val_if_fail (system_id != NULL, NULL);
	self = (GXmlXDocumentType*) gxml_xchild_node_construct (object_type);
	_tmp0_ = g_strdup (name);
	_g_free0 (self->_name);
	self->_name = _tmp0_;
	_tmp1_ = g_strdup (public_id);
	_g_free0 (self->_public_id);
	self->_public_id = _tmp1_;
	_tmp2_ = g_strdup (system_id);
	_g_free0 (self->_system_id);
	self->_system_id = _tmp2_;
	return self;
}

GXmlXDocumentType*
gxml_xdocument_type_new_with_ids (const gchar* name,
                                  const gchar* public_id,
                                  const gchar* system_id)
{
	return gxml_xdocument_type_construct_with_ids (GXML_TYPE_XDOCUMENT_TYPE, name, public_id, system_id);
}

static void
gxml_xdocument_type_real_remove (GXmlDomChildNode* base)
{
	GXmlXDocumentType * self;
	xmlNode* _tmp0_;
	self = (GXmlXDocumentType*) base;
	_tmp0_ = gxml_xnode_get_internal_node ((GXmlXNode*) self);
	xmlUnlinkNode (_tmp0_);
}

GXmlXDocumentType*
gxml_xdocument_type_construct (GType object_type)
{
	GXmlXDocumentType * self = NULL;
	self = (GXmlXDocumentType*) gxml_xchild_node_construct (object_type);
	return self;
}

GXmlXDocumentType*
gxml_xdocument_type_new (void)
{
	return gxml_xdocument_type_construct (GXML_TYPE_XDOCUMENT_TYPE);
}

static void
gxml_xdocument_type_class_init (GXmlXDocumentTypeClass * klass,
                                gpointer klass_data)
{
	gxml_xdocument_type_parent_class = g_type_class_peek_parent (klass);
	G_OBJECT_CLASS (klass)->get_property = _vala_gxml_xdocument_type_get_property;
	G_OBJECT_CLASS (klass)->finalize = gxml_xdocument_type_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), GXML_XDOCUMENT_TYPE_NAME_PROPERTY, gxml_xdocument_type_properties[GXML_XDOCUMENT_TYPE_NAME_PROPERTY] = g_param_spec_string ("name", "name", "name", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GXML_XDOCUMENT_TYPE_PUBLIC_ID_PROPERTY, gxml_xdocument_type_properties[GXML_XDOCUMENT_TYPE_PUBLIC_ID_PROPERTY] = g_param_spec_string ("public-id", "public-id", "public-id", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GXML_XDOCUMENT_TYPE_SYSTEM_ID_PROPERTY, gxml_xdocument_type_properties[GXML_XDOCUMENT_TYPE_SYSTEM_ID_PROPERTY] = g_param_spec_string ("system-id", "system-id", "system-id", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
}

static void
gxml_xdocument_type_gxml_dom_node_interface_init (GXmlDomNodeIface * iface,
                                                  gpointer iface_data)
{
	gxml_xdocument_type_gxml_dom_node_parent_iface = g_type_interface_peek_parent (iface);
}

static void
gxml_xdocument_type_gxml_dom_child_node_interface_init (GXmlDomChildNodeIface * iface,
                                                        gpointer iface_data)
{
	gxml_xdocument_type_gxml_dom_child_node_parent_iface = g_type_interface_peek_parent (iface);
	iface->remove = (void (*) (GXmlDomChildNode*)) gxml_xdocument_type_real_remove;
}

static void
gxml_xdocument_type_gxml_dom_document_type_interface_init (GXmlDomDocumentTypeIface * iface,
                                                           gpointer iface_data)
{
	gxml_xdocument_type_gxml_dom_document_type_parent_iface = g_type_interface_peek_parent (iface);
	iface->get_name = gxml_xdocument_type_real_get_name;
	iface->get_public_id = gxml_xdocument_type_real_get_public_id;
	iface->get_system_id = gxml_xdocument_type_real_get_system_id;
}

static void
gxml_xdocument_type_instance_init (GXmlXDocumentType * self,
                                   gpointer klass)
{
	gchar* _tmp0_;
	gchar* _tmp1_;
	gchar* _tmp2_;
	_tmp0_ = g_strdup ("");
	self->_name = _tmp0_;
	_tmp1_ = g_strdup ("");
	self->_public_id = _tmp1_;
	_tmp2_ = g_strdup ("");
	self->_system_id = _tmp2_;
}

static void
gxml_xdocument_type_finalize (GObject * obj)
{
	GXmlXDocumentType * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GXML_TYPE_XDOCUMENT_TYPE, GXmlXDocumentType);
	_g_free0 (self->_name);
	_g_free0 (self->_public_id);
	_g_free0 (self->_system_id);
	G_OBJECT_CLASS (gxml_xdocument_type_parent_class)->finalize (obj);
}

static GType
gxml_xdocument_type_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (GXmlXDocumentTypeClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) gxml_xdocument_type_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GXmlXDocumentType), 0, (GInstanceInitFunc) gxml_xdocument_type_instance_init, NULL };
	static const GInterfaceInfo gxml_dom_node_info = { (GInterfaceInitFunc) gxml_xdocument_type_gxml_dom_node_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
	static const GInterfaceInfo gxml_dom_child_node_info = { (GInterfaceInitFunc) gxml_xdocument_type_gxml_dom_child_node_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
	static const GInterfaceInfo gxml_dom_document_type_info = { (GInterfaceInitFunc) gxml_xdocument_type_gxml_dom_document_type_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
	GType gxml_xdocument_type_type_id;
	gxml_xdocument_type_type_id = g_type_register_static (GXML_TYPE_XCHILD_NODE, "GXmlXDocumentType", &g_define_type_info, 0);
	g_type_add_interface_static (gxml_xdocument_type_type_id, GXML_TYPE_DOM_NODE, &gxml_dom_node_info);
	g_type_add_interface_static (gxml_xdocument_type_type_id, GXML_TYPE_DOM_CHILD_NODE, &gxml_dom_child_node_info);
	g_type_add_interface_static (gxml_xdocument_type_type_id, GXML_TYPE_DOM_DOCUMENT_TYPE, &gxml_dom_document_type_info);
	return gxml_xdocument_type_type_id;
}

GType
gxml_xdocument_type_get_type (void)
{
	static volatile gsize gxml_xdocument_type_type_id__once = 0;
	if (g_once_init_enter (&gxml_xdocument_type_type_id__once)) {
		GType gxml_xdocument_type_type_id;
		gxml_xdocument_type_type_id = gxml_xdocument_type_get_type_once ();
		g_once_init_leave (&gxml_xdocument_type_type_id__once, gxml_xdocument_type_type_id);
	}
	return gxml_xdocument_type_type_id__once;
}

static void
_vala_gxml_xdocument_type_get_property (GObject * object,
                                        guint property_id,
                                        GValue * value,
                                        GParamSpec * pspec)
{
	GXmlXDocumentType * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, GXML_TYPE_XDOCUMENT_TYPE, GXmlXDocumentType);
	switch (property_id) {
		case GXML_XDOCUMENT_TYPE_NAME_PROPERTY:
		g_value_set_string (value, gxml_dom_document_type_get_name ((GXmlDomDocumentType*) self));
		break;
		case GXML_XDOCUMENT_TYPE_PUBLIC_ID_PROPERTY:
		g_value_set_string (value, gxml_dom_document_type_get_public_id ((GXmlDomDocumentType*) self));
		break;
		case GXML_XDOCUMENT_TYPE_SYSTEM_ID_PROPERTY:
		g_value_set_string (value, gxml_dom_document_type_get_system_id ((GXmlDomDocumentType*) self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

GXmlXDocumentFragment*
gxml_xdocument_fragment_construct (GType object_type,
                                   GXmlXDocument* d)
{
	GXmlXDocumentFragment * self = NULL;
	GXmlXDocument* _tmp0_;
	GXmlXDocument* _tmp1_;
	g_return_val_if_fail (d != NULL, NULL);
	self = (GXmlXDocumentFragment*) gxml_xdocument_construct (object_type);
	_tmp0_ = ((GXmlXNode*) d)->_doc;
	_tmp1_ = _g_object_ref0 (_tmp0_);
	_g_object_unref0 (((GXmlXNode*) self)->_doc);
	((GXmlXNode*) self)->_doc = _tmp1_;
	return self;
}

GXmlXDocumentFragment*
gxml_xdocument_fragment_new (GXmlXDocument* d)
{
	return gxml_xdocument_fragment_construct (GXML_TYPE_XDOCUMENT_FRAGMENT, d);
}

static void
gxml_xdocument_fragment_class_init (GXmlXDocumentFragmentClass * klass,
                                    gpointer klass_data)
{
	gxml_xdocument_fragment_parent_class = g_type_class_peek_parent (klass);
}

static void
gxml_xdocument_fragment_gxml_dom_document_fragment_interface_init (GXmlDomDocumentFragmentIface * iface,
                                                                   gpointer iface_data)
{
	gxml_xdocument_fragment_gxml_dom_document_fragment_parent_iface = g_type_interface_peek_parent (iface);
}

static void
gxml_xdocument_fragment_instance_init (GXmlXDocumentFragment * self,
                                       gpointer klass)
{
}

static GType
gxml_xdocument_fragment_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (GXmlXDocumentFragmentClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) gxml_xdocument_fragment_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GXmlXDocumentFragment), 0, (GInstanceInitFunc) gxml_xdocument_fragment_instance_init, NULL };
	static const GInterfaceInfo gxml_dom_document_fragment_info = { (GInterfaceInitFunc) gxml_xdocument_fragment_gxml_dom_document_fragment_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
	GType gxml_xdocument_fragment_type_id;
	gxml_xdocument_fragment_type_id = g_type_register_static (GXML_TYPE_XDOCUMENT, "GXmlXDocumentFragment", &g_define_type_info, 0);
	g_type_add_interface_static (gxml_xdocument_fragment_type_id, GXML_TYPE_DOM_DOCUMENT_FRAGMENT, &gxml_dom_document_fragment_info);
	return gxml_xdocument_fragment_type_id;
}

GType
gxml_xdocument_fragment_get_type (void)
{
	static volatile gsize gxml_xdocument_fragment_type_id__once = 0;
	if (g_once_init_enter (&gxml_xdocument_fragment_type_id__once)) {
		GType gxml_xdocument_fragment_type_id;
		gxml_xdocument_fragment_type_id = gxml_xdocument_fragment_get_type_once ();
		g_once_init_leave (&gxml_xdocument_fragment_type_id__once, gxml_xdocument_fragment_type_id);
	}
	return gxml_xdocument_fragment_type_id__once;
}

static void
_vala_array_destroy (gpointer array,
                     gssize array_length,
                     GDestroyNotify destroy_func)
{
	if ((array != NULL) && (destroy_func != NULL)) {
		gssize i;
		for (i = 0; i < array_length; i = i + 1) {
			if (((gpointer*) array)[i] != NULL) {
				destroy_func (((gpointer*) array)[i]);
			}
		}
	}
}

static void
_vala_array_free (gpointer array,
                  gssize array_length,
                  GDestroyNotify destroy_func)
{
	_vala_array_destroy (array, array_length, destroy_func);
	g_free (array);
}

static gssize
_vala_array_length (gpointer array)
{
	gssize length;
	length = 0;
	if (array) {
		while (((gpointer*) array)[length]) {
			length++;
		}
	}
	return length;
}

static inline gpointer
_vala_memdup2 (gconstpointer mem,
               gsize byte_size)
{
	gpointer new_mem;
	if (mem && byte_size != 0) {
		new_mem = g_malloc (byte_size);
		memcpy (new_mem, mem, byte_size);
	} else {
		new_mem = NULL;
	}
	return new_mem;
}

