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

/* -*- Mode: vala; indent-tabs-mode: nil; c-basic-offset: 0; tab-width: 2 -*- */
/* ObjectModel.vala
 *
 * Copyright (C) 2015  Daniel Espinosa <esodan@gmail.com>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.

 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, see <http://www.gnu.org/licenses/>.
 *
 * Authors:
 *      Daniel Espinosa <esodan@gmail.com>
 */

#include "gxml/gxml.h"
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include <gee.h>
#include <glib-object.h>
#include <libxml/tree.h>
#include <libxml/xmlerror.h>
#include <glib/gi18n-lib.h>
#include <libxml/parser.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_XNODE_0_PROPERTY,
	GXML_XNODE_ATTRS_PROPERTY,
	GXML_XNODE_CHILDREN_NODES_PROPERTY,
	GXML_XNODE_DOCUMENT_PROPERTY,
	GXML_XNODE_PARENT_PROPERTY,
	GXML_XNODE_TYPE_NODE_PROPERTY,
	GXML_XNODE_NAME_PROPERTY,
	GXML_XNODE_VALUE_PROPERTY,
	GXML_XNODE_NODE_TYPE_PROPERTY,
	GXML_XNODE_NODE_NAME_PROPERTY,
	GXML_XNODE_BASE_URI_PROPERTY,
	GXML_XNODE_OWNER_DOCUMENT_PROPERTY,
	GXML_XNODE_PARENT_NODE_PROPERTY,
	GXML_XNODE_PARENT_ELEMENT_PROPERTY,
	GXML_XNODE_CHILD_NODES_PROPERTY,
	GXML_XNODE_FIRST_CHILD_PROPERTY,
	GXML_XNODE_LAST_CHILD_PROPERTY,
	GXML_XNODE_PREVIOUS_SIBLING_PROPERTY,
	GXML_XNODE_NEXT_SIBLING_PROPERTY,
	GXML_XNODE_NODE_VALUE_PROPERTY,
	GXML_XNODE_TEXT_CONTENT_PROPERTY,
	GXML_XNODE_NUM_PROPERTIES
};
static GParamSpec* gxml_xnode_properties[GXML_XNODE_NUM_PROPERTIES];
#define _xmlFreeNode0(var) ((var == NULL) ? NULL : (var = (xmlFreeNode (var), NULL)))
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))
#define _g_regex_unref0(var) ((var == NULL) ? NULL : (var = (g_regex_unref (var), NULL)))
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))

/**
 * Auxiliary error codes for parsing/writing libxml2 powered classes
 */

static gpointer gxml_xnode_parent_class = NULL;
static GXmlDomEventTargetIface * gxml_xnode_gxml_dom_event_target_parent_iface = NULL;
static GXmlDomNodeIface * gxml_xnode_gxml_dom_node_parent_iface = NULL;

VALA_EXTERN gchar* gxml_xnode_libxml2_error_to_string (xmlError* e);
static const char* _xml_error_level_to_string (xmlErrorLevel value);
static gboolean gxml_xnode_real_set_namespace (GXmlXNode* self,
                                        const gchar* uri,
                                        const gchar* prefix);
static gchar* gxml_xnode_real_to_string (GXmlXNode* self);
VALA_EXTERN void gxml_xnode_take_node (GXmlXNode* self);
VALA_EXTERN void gxml_xnode_release_node (GXmlXNode* self);
static gboolean gxml_xnode_real_has_child_nodes (GXmlDomNode* base);
static void gxml_xnode_real_normalize (GXmlDomNode* base);
static gboolean gxml_xnode_real_is_equal_node (GXmlDomNode* base,
                                        GXmlDomNode* node);
static GXmlDomNodeDocumentPosition gxml_xnode_real_compare_document_position (GXmlDomNode* base,
                                                                       GXmlDomNode* other);
static gboolean gxml_xnode_real_contains (GXmlDomNode* base,
                                   GXmlDomNode* other);
static gchar* gxml_xnode_real_lookup_prefix (GXmlDomNode* base,
                                      const gchar* nspace);
static gchar* gxml_xnode_real_lookup_namespace_uri (GXmlDomNode* base,
                                             const gchar* prefix);
static gboolean gxml_xnode_real_is_default_namespace (GXmlDomNode* base,
                                               const gchar* nspace);
static GXmlDomNode* gxml_xnode_real_insert_before (GXmlDomNode* base,
                                            GXmlDomNode* node,
                                            GXmlDomNode* child,
                                            GError** error);
static GXmlDomNode* gxml_xnode_real_append_child (GXmlDomNode* base,
                                           GXmlDomNode* node,
                                           GError** error);
static GXmlDomNode* gxml_xnode_real_replace_child (GXmlDomNode* base,
                                            GXmlDomNode* node,
                                            GXmlDomNode* child,
                                            GError** error);
static GXmlDomNode* gxml_xnode_real_remove_child (GXmlDomNode* base,
                                           GXmlDomNode* child,
                                           GError** error);
static void gxml_xnode_real_add_event_listener (GXmlDomEventTarget* base,
                                         const gchar* type,
                                         GXmlDomEventListener* callback,
                                         gboolean capture);
static void gxml_xnode_real_remove_event_listener (GXmlDomEventTarget* base,
                                            const gchar* type,
                                            GXmlDomEventListener* callback,
                                            gboolean capture);
static gboolean gxml_xnode_real_dispatch_event (GXmlDomEventTarget* base,
                                         GXmlDomEvent* event,
                                         GError** error);
static GObject * gxml_xnode_constructor (GType type,
                                  guint n_construct_properties,
                                  GObjectConstructParam * construct_properties);
VALA_EXTERN void gxml_init_init (void);
static void gxml_xnode_finalize (GObject * obj);
static GType gxml_xnode_get_type_once (void);
static void _vala_gxml_xnode_get_property (GObject * object,
                                    guint property_id,
                                    GValue * value,
                                    GParamSpec * pspec);
static void _vala_gxml_xnode_set_property (GObject * object,
                                    guint property_id,
                                    const GValue * value,
                                    GParamSpec * pspec);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

GQuark
gxml_error_quark (void)
{
	return g_quark_from_static_string ("gxml-error-quark");
}

static GType
gxml_error_get_type_once (void)
{
	static const GEnumValue values[] = {{GXML_ERROR_NOT_SUPPORTED, "GXML_ERROR_NOT_SUPPORTED", "not-supported"}, {GXML_ERROR_PARSER, "GXML_ERROR_PARSER", "parser"}, {GXML_ERROR_WRITER, "GXML_ERROR_WRITER", "writer"}, {0, NULL, NULL}};
	GType gxml_error_type_id;
	gxml_error_type_id = g_enum_register_static ("GXmlError", values);
	return gxml_error_type_id;
}

GType
gxml_error_get_type (void)
{
	static volatile gsize gxml_error_type_id__once = 0;
	if (g_once_init_enter (&gxml_error_type_id__once)) {
		GType gxml_error_type_id;
		gxml_error_type_id = gxml_error_get_type_once ();
		g_once_init_leave (&gxml_error_type_id__once, gxml_error_type_id);
	}
	return gxml_error_type_id__once;
}

static const char*
_xml_error_level_to_string (xmlErrorLevel value)
{
	switch (value) {
		case XML_ERR_NONE:
		return "XML_ERR_NONE";
		case XML_ERR_WARNING:
		return "XML_ERR_WARNING";
		case XML_ERR_ERROR:
		return "XML_ERR_ERROR";
		case XML_ERR_FATAL:
		return "XML_ERR_FATAL";
	}
	return NULL;
}

static gchar*
string_replace (const gchar* self,
                const gchar* old,
                const gchar* replacement)
{
	gboolean _tmp0_ = FALSE;
	gboolean _tmp1_ = FALSE;
	GError* _inner_error0_ = NULL;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (old != NULL, NULL);
	g_return_val_if_fail (replacement != NULL, NULL);
	if ((*((gchar*) self)) == '\0') {
		_tmp1_ = TRUE;
	} else {
		_tmp1_ = (*((gchar*) old)) == '\0';
	}
	if (_tmp1_) {
		_tmp0_ = TRUE;
	} else {
		_tmp0_ = g_strcmp0 (old, replacement) == 0;
	}
	if (_tmp0_) {
		gchar* _tmp2_;
		_tmp2_ = g_strdup (self);
		result = _tmp2_;
		return result;
	}
	{
		GRegex* regex = NULL;
		gchar* _tmp3_;
		gchar* _tmp4_;
		GRegex* _tmp5_;
		GRegex* _tmp6_;
		gchar* _tmp7_ = NULL;
		GRegex* _tmp8_;
		gchar* _tmp9_;
		gchar* _tmp10_;
		_tmp3_ = g_regex_escape_string (old, -1);
		_tmp4_ = _tmp3_;
		_tmp5_ = g_regex_new (_tmp4_, 0, 0, &_inner_error0_);
		_tmp6_ = _tmp5_;
		_g_free0 (_tmp4_);
		regex = _tmp6_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			if (_inner_error0_->domain == G_REGEX_ERROR) {
				goto __catch0_g_regex_error;
			}
			g_critical ("file %s: line %d: unexpected 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;
		}
		_tmp8_ = regex;
		_tmp9_ = g_regex_replace_literal (_tmp8_, self, (gssize) -1, 0, replacement, 0, &_inner_error0_);
		_tmp7_ = _tmp9_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			_g_regex_unref0 (regex);
			if (_inner_error0_->domain == G_REGEX_ERROR) {
				goto __catch0_g_regex_error;
			}
			g_critical ("file %s: line %d: unexpected 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_ = _tmp7_;
		_tmp7_ = NULL;
		result = _tmp10_;
		_g_free0 (_tmp7_);
		_g_regex_unref0 (regex);
		return result;
	}
	goto __finally0;
	__catch0_g_regex_error:
	{
		g_clear_error (&_inner_error0_);
		g_assert_not_reached ();
	}
	__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;
}

gchar*
gxml_xnode_libxml2_error_to_string (xmlError* e)
{
	const gchar* _tmp0_ = NULL;
	const gchar* _tmp1_;
	const gchar* _tmp3_;
	gchar* _tmp4_;
	gchar* _tmp5_;
	gchar* _tmp6_;
	gchar* _tmp7_;
	gchar* _tmp8_;
	gchar* _tmp9_;
	const gchar* _tmp10_;
	gchar* _tmp11_;
	gchar* _tmp12_;
	gchar* result;
	_tmp1_ = (*e).file;
	if (_tmp1_ == NULL) {
		_tmp0_ = "<io>";
	} else {
		const gchar* _tmp2_;
		_tmp2_ = (*e).file;
		_tmp0_ = _tmp2_;
	}
	_tmp3_ = _xml_error_level_to_string ((*e).level);
	_tmp4_ = string_replace (_tmp3_, "XML_ERR_", "");
	_tmp5_ = _tmp4_;
	_tmp6_ = g_strdup_printf ("%i", (*e).domain);
	_tmp7_ = _tmp6_;
	_tmp8_ = string_replace (_tmp7_, "XML_FROM_", "");
	_tmp9_ = _tmp8_;
	_tmp10_ = (*e).message;
	_tmp11_ = g_strdup_printf (_ ("%s:%s:%d: %s:%d: %s"), _tmp5_, _tmp9_, (*e).code, _tmp0_, (*e).line, _tmp10_);
	_tmp12_ = _tmp11_;
	_g_free0 (_tmp9_);
	_g_free0 (_tmp7_);
	_g_free0 (_tmp5_);
	result = _tmp12_;
	return result;
}

static gboolean
gxml_xnode_real_set_namespace (GXmlXNode* self,
                               const gchar* uri,
                               const gchar* prefix)
{
	xmlNode* _tmp0_;
	xmlNode* _tmp1_;
	xmlNs* _tmp2_;
	gboolean result;
	g_return_val_if_fail (uri != NULL, FALSE);
	_tmp0_ = self->_node;
	if (_tmp0_ == NULL) {
		result = FALSE;
		return result;
	}
	_tmp1_ = self->_node;
	_tmp2_ = xmlNewNs (_tmp1_, (xmlChar*) uri, (xmlChar*) prefix);
	result = _tmp2_ != NULL;
	return result;
}

gboolean
gxml_xnode_set_namespace (GXmlXNode* self,
                          const gchar* uri,
                          const gchar* prefix)
{
	GXmlXNodeClass* _klass_;
	g_return_val_if_fail (self != NULL, FALSE);
	_klass_ = GXML_XNODE_GET_CLASS (self);
	if (_klass_->set_namespace) {
		return _klass_->set_namespace (self, uri, prefix);
	}
	return FALSE;
}

GeeMap*
gxml_xnode_get_attrs (GXmlXNode* self)
{
	GXmlXNodeClass* _klass_;
	g_return_val_if_fail (self != NULL, NULL);
	_klass_ = GXML_XNODE_GET_CLASS (self);
	if (_klass_->get_attrs) {
		return _klass_->get_attrs (self);
	}
	return NULL;
}

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

GeeBidirList*
gxml_xnode_get_children_nodes (GXmlXNode* self)
{
	GXmlXNodeClass* _klass_;
	g_return_val_if_fail (self != NULL, NULL);
	_klass_ = GXML_XNODE_GET_CLASS (self);
	if (_klass_->get_children_nodes) {
		return _klass_->get_children_nodes (self);
	}
	return NULL;
}

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

GXmlDomDocument*
gxml_xnode_get_document (GXmlXNode* self)
{
	GXmlXNodeClass* _klass_;
	g_return_val_if_fail (self != NULL, NULL);
	_klass_ = GXML_XNODE_GET_CLASS (self);
	if (_klass_->get_document) {
		return _klass_->get_document (self);
	}
	return NULL;
}

static GXmlDomDocument*
gxml_xnode_real_get_document (GXmlXNode* base)
{
	GXmlDomDocument* result;
	GXmlXNode* self;
	GXmlXDocument* _tmp0_;
	self = base;
	_tmp0_ = self->_doc;
	result = (GXmlDomDocument*) _tmp0_;
	return result;
}

GXmlDomNode*
gxml_xnode_get_parent (GXmlXNode* self)
{
	GXmlXNodeClass* _klass_;
	g_return_val_if_fail (self != NULL, NULL);
	_klass_ = GXML_XNODE_GET_CLASS (self);
	if (_klass_->get_parent) {
		return _klass_->get_parent (self);
	}
	return NULL;
}

static GXmlDomNode*
gxml_xnode_real_get_parent (GXmlXNode* base)
{
	GXmlDomNode* result;
	GXmlXNode* self;
	GXmlDomNode* nullnode = NULL;
	xmlNode* _tmp0_;
	GXmlDomDocument* _tmp1_;
	GXmlDomDocument* _tmp2_;
	xmlNode* _tmp3_;
	xmlNode* _tmp4_;
	GXmlDomNode* _tmp5_;
	self = base;
	nullnode = NULL;
	_tmp0_ = self->_node;
	if (_tmp0_ == NULL) {
		result = nullnode;
		return result;
	}
	_tmp1_ = gxml_xnode_get_document (self);
	_tmp2_ = _tmp1_;
	_tmp3_ = self->_node;
	_tmp4_ = _tmp3_->parent;
	_tmp5_ = gxml_xnode_to_gnode (GXML_IS_XDOCUMENT (_tmp2_) ? ((GXmlXDocument*) _tmp2_) : NULL, _tmp4_, FALSE);
	result = _tmp5_;
	_g_object_unref0 (nullnode);
	return result;
}

GXmlNodeType
gxml_xnode_get_type_node (GXmlXNode* self)
{
	GXmlXNodeClass* _klass_;
	g_return_val_if_fail (self != NULL, 0);
	_klass_ = GXML_XNODE_GET_CLASS (self);
	if (_klass_->get_type_node) {
		return _klass_->get_type_node (self);
	}
	return 0;
}

static GXmlNodeType
gxml_xnode_real_get_type_node (GXmlXNode* base)
{
	GXmlNodeType result;
	GXmlXNode* self;
	xmlNode* _tmp0_;
	xmlNode* _tmp1_;
	self = base;
	_tmp0_ = self->_node;
	if (_tmp0_ == NULL) {
		result = GXML_NODE_TYPE_INVALID;
		return result;
	}
	_tmp1_ = self->_node;
	result = (GXmlNodeType) _tmp1_->type;
	return result;
}

gchar*
gxml_xnode_get_name (GXmlXNode* self)
{
	GXmlXNodeClass* _klass_;
	g_return_val_if_fail (self != NULL, NULL);
	_klass_ = GXML_XNODE_GET_CLASS (self);
	if (_klass_->get_name) {
		return _klass_->get_name (self);
	}
	return NULL;
}

static gchar*
gxml_xnode_real_get_name (GXmlXNode* base)
{
	gchar* result;
	GXmlXNode* self;
	xmlNode* _tmp0_;
	xmlNode* _tmp2_;
	const gchar* _tmp3_;
	gchar* _tmp4_;
	self = base;
	_tmp0_ = self->_node;
	if (_tmp0_ == NULL) {
		gchar* _tmp1_;
		_tmp1_ = g_strdup ("#noname");
		result = _tmp1_;
		return result;
	}
	_tmp2_ = self->_node;
	_tmp3_ = _tmp2_->name;
	_tmp4_ = g_strdup (_tmp3_);
	result = _tmp4_;
	return result;
}

gchar*
gxml_xnode_get_value (GXmlXNode* self)
{
	GXmlXNodeClass* _klass_;
	g_return_val_if_fail (self != NULL, NULL);
	_klass_ = GXML_XNODE_GET_CLASS (self);
	if (_klass_->get_value) {
		return _klass_->get_value (self);
	}
	return NULL;
}

static gchar*
gxml_xnode_real_get_value (GXmlXNode* base)
{
	gchar* result;
	GXmlXNode* self;
	xmlNode* _tmp0_;
	xmlNode* _tmp2_;
	gchar* _tmp3_;
	self = base;
	_tmp0_ = self->_node;
	if (_tmp0_ == NULL) {
		gchar* _tmp1_;
		_tmp1_ = g_strdup ("");
		result = _tmp1_;
		return result;
	}
	_tmp2_ = self->_node;
	_tmp3_ = (gchar*) xmlNodeGetContent (_tmp2_);
	result = _tmp3_;
	return result;
}

void
gxml_xnode_set_value (GXmlXNode* self,
                      const gchar* value)
{
	GXmlXNodeClass* _klass_;
	g_return_if_fail (self != NULL);
	_klass_ = GXML_XNODE_GET_CLASS (self);
	if (_klass_->set_value) {
		_klass_->set_value (self, value);
	}
}

static void
gxml_xnode_real_set_value (GXmlXNode* base,
                           const gchar* value)
{
	GXmlXNode* self;
	xmlNode* _tmp0_;
	xmlNode* _tmp1_;
	self = base;
	_tmp0_ = self->_node;
	if (_tmp0_ == NULL) {
		return;
	}
	_tmp1_ = self->_node;
	xmlNodeSetContent (_tmp1_, (xmlChar*) value);
	g_object_notify_by_pspec ((GObject *) self, gxml_xnode_properties[GXML_XNODE_VALUE_PROPERTY]);
}

static gchar*
gxml_xnode_real_to_string (GXmlXNode* self)
{
	const gchar* _tmp0_;
	gchar* _tmp1_;
	gchar* result;
	_tmp0_ = g_type_name (G_TYPE_FROM_INSTANCE ((GObject*) self));
	_tmp1_ = g_strdup (_tmp0_);
	result = _tmp1_;
	return result;
}

gchar*
gxml_xnode_to_string (GXmlXNode* self)
{
	GXmlXNodeClass* _klass_;
	g_return_val_if_fail (self != NULL, NULL);
	_klass_ = GXML_XNODE_GET_CLASS (self);
	if (_klass_->to_string) {
		return _klass_->to_string (self);
	}
	return NULL;
}

/**
   * Access to {@link Xml.Node} referenced
   */
xmlNode*
gxml_xnode_get_internal_node (GXmlXNode* self)
{
	xmlNode* _tmp0_;
	xmlNode* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->_node;
	result = _tmp0_;
	return result;
}

void
gxml_xnode_take_node (GXmlXNode* self)
{
	g_return_if_fail (self != NULL);
	self->owned_node = TRUE;
}

void
gxml_xnode_release_node (GXmlXNode* self)
{
	g_return_if_fail (self != NULL);
	self->owned_node = FALSE;
}

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

GXmlDomNode*
gxml_xnode_to_gnode (GXmlXDocument* doc,
                     xmlNode* node,
                     gboolean take_node)
{
	GXmlXNode* n = NULL;
	GXmlNodeType t = 0;
	gboolean _tmp6_ = FALSE;
	GXmlDomNode* result;
	g_return_val_if_fail (doc != NULL, NULL);
	n = NULL;
	t = (GXmlNodeType) node->type;
	switch (t) {
		case GXML_NODE_TYPE_ELEMENT:
		{
			GXmlXElement* _tmp0_;
			_tmp0_ = gxml_xelement_new (doc, node);
			_g_object_unref0 (n);
			n = (GXmlXNode*) _tmp0_;
			break;
		}
		case GXML_NODE_TYPE_ATTRIBUTE:
		{
			GXmlXAttribute* _tmp1_;
			_tmp1_ = gxml_xattribute_new (doc, (xmlAttr*) node);
			_g_object_unref0 (n);
			n = (GXmlXNode*) _tmp1_;
			break;
		}
		case GXML_NODE_TYPE_TEXT:
		{
			GXmlXText* _tmp2_;
			_tmp2_ = gxml_xtext_new (doc, node);
			_g_object_unref0 (n);
			n = (GXmlXNode*) _tmp2_;
			break;
		}
		case GXML_NODE_TYPE_ENTITY_REFERENCE:
		{
			_g_object_unref0 (n);
			n = NULL;
			break;
		}
		case GXML_NODE_TYPE_ENTITY:
		{
			_g_object_unref0 (n);
			n = NULL;
			break;
		}
		case GXML_NODE_TYPE_PROCESSING_INSTRUCTION:
		{
			GXmlXProcessingInstruction* _tmp3_;
			_tmp3_ = gxml_xprocessing_instruction_new (doc, node);
			_g_object_unref0 (n);
			n = (GXmlXNode*) _tmp3_;
			break;
		}
		case GXML_NODE_TYPE_COMMENT:
		{
			GXmlXComment* _tmp4_;
			_tmp4_ = gxml_xcomment_new (doc, node);
			_g_object_unref0 (n);
			n = (GXmlXNode*) _tmp4_;
			break;
		}
		case GXML_NODE_TYPE_DOCUMENT:
		{
			GXmlXNode* _tmp5_;
			_tmp5_ = _g_object_ref0 ((GXmlXNode*) doc);
			_g_object_unref0 (n);
			n = _tmp5_;
			break;
		}
		case GXML_NODE_TYPE_DOCUMENT_TYPE:
		{
			_g_object_unref0 (n);
			n = NULL;
			break;
		}
		case GXML_NODE_TYPE_DOCUMENT_FRAGMENT:
		{
			_g_object_unref0 (n);
			n = NULL;
			break;
		}
		case GXML_NODE_TYPE_NOTATION:
		{
			_g_object_unref0 (n);
			n = NULL;
			break;
		}
		case GXML_NODE_TYPE_CDATA_SECTION:
		case GXML_NODE_TYPE_INVALID:
		{
			_g_object_unref0 (n);
			n = NULL;
			break;
		}
		default:
		break;
	}
	if (take_node) {
		GXmlXNode* _tmp7_;
		_tmp7_ = n;
		_tmp6_ = _tmp7_ != NULL;
	} else {
		_tmp6_ = FALSE;
	}
	if (_tmp6_) {
		GXmlXNode* _tmp8_;
		_tmp8_ = n;
		gxml_xnode_take_node (_tmp8_);
	}
	result = (GXmlDomNode*) n;
	return result;
}

static GXmlDomNodeNodeType
gxml_xnode_real_get_node_type (GXmlDomNode* base)
{
	GXmlDomNodeNodeType result;
	GXmlXNode* self;
	xmlNode* _tmp0_;
	xmlNode* _tmp1_;
	self = (GXmlXNode*) base;
	_tmp0_ = self->_node;
	if (_tmp0_ == NULL) {
		result = GXML_DOM_NODE_NODE_TYPE_INVALID;
		return result;
	}
	_tmp1_ = self->_node;
	switch (_tmp1_->type) {
		case XML_ELEMENT_NODE:
		{
			result = GXML_DOM_NODE_NODE_TYPE_ELEMENT_NODE;
			return result;
		}
		case XML_ATTRIBUTE_NODE:
		{
			result = GXML_DOM_NODE_NODE_TYPE_ATTRIBUTE_NODE;
			return result;
		}
		case XML_TEXT_NODE:
		{
			result = GXML_DOM_NODE_NODE_TYPE_TEXT_NODE;
			return result;
		}
		case XML_CDATA_SECTION_NODE:
		{
			result = GXML_DOM_NODE_NODE_TYPE_CDATA_SECTION_NODE;
			return result;
		}
		case XML_ENTITY_REF_NODE:
		{
			result = GXML_DOM_NODE_NODE_TYPE_ENTITY_REFERENCE_NODE;
			return result;
		}
		case XML_ENTITY_NODE:
		{
			result = GXML_DOM_NODE_NODE_TYPE_ENTITY_NODE;
			return result;
		}
		case XML_PI_NODE:
		{
			result = GXML_DOM_NODE_NODE_TYPE_PROCESSING_INSTRUCTION_NODE;
			return result;
		}
		case XML_COMMENT_NODE:
		{
			result = GXML_DOM_NODE_NODE_TYPE_COMMENT_NODE;
			return result;
		}
		case XML_DOCUMENT_NODE:
		{
			result = GXML_DOM_NODE_NODE_TYPE_DOCUMENT_NODE;
			return result;
		}
		case XML_DOCUMENT_TYPE_NODE:
		{
			result = GXML_DOM_NODE_NODE_TYPE_DOCUMENT_TYPE_NODE;
			return result;
		}
		case XML_DOCUMENT_FRAG_NODE:
		{
			result = GXML_DOM_NODE_NODE_TYPE_DOCUMENT_FRAGMENT_NODE;
			return result;
		}
		case XML_NOTATION_NODE:
		{
			result = GXML_DOM_NODE_NODE_TYPE_NOTATION_NODE;
			return result;
		}
		case XML_ATTRIBUTE_DECL:
		case XML_XINCLUDE_START:
		case XML_DTD_NODE:
		case XML_ENTITY_DECL:
		case XML_XINCLUDE_END:
		case XML_ELEMENT_DECL:
		case XML_NAMESPACE_DECL:
		case XML_DOCB_DOCUMENT_NODE:
		case XML_HTML_DOCUMENT_NODE:
		{
			result = GXML_DOM_NODE_NODE_TYPE_INVALID;
			return result;
		}
		default:
		break;
	}
	result = GXML_DOM_NODE_NODE_TYPE_INVALID;
	return result;
}

static gchar*
gxml_xnode_real_get_node_name (GXmlDomNode* base)
{
	gchar* result;
	GXmlXNode* self;
	gchar* _tmp0_;
	gchar* _tmp1_;
	self = (GXmlXNode*) base;
	_tmp0_ = gxml_xnode_get_name (self);
	_tmp1_ = _tmp0_;
	result = _tmp1_;
	return result;
}

static const gchar*
gxml_xnode_real_get_base_uri (GXmlDomNode* base)
{
	const gchar* result;
	GXmlXNode* self;
	const gchar* _tmp0_;
	self = (GXmlXNode*) base;
	_tmp0_ = self->_base_uri;
	result = _tmp0_;
	return result;
}

static GXmlDomDocument*
gxml_xnode_real_get_owner_document (GXmlDomNode* base)
{
	GXmlDomDocument* result;
	GXmlXNode* self;
	GXmlXDocument* _tmp0_;
	self = (GXmlXNode*) base;
	_tmp0_ = self->_doc;
	result = (GXmlDomDocument*) _tmp0_;
	return result;
}

static void
gxml_xnode_real_set_owner_document (GXmlDomNode* base,
                                    GXmlDomDocument* value)
{
	GXmlXNode* self;
	GXmlXDocument* _tmp0_;
	self = (GXmlXNode*) base;
	_tmp0_ = _g_object_ref0 (GXML_IS_XDOCUMENT (value) ? ((GXmlXDocument*) value) : NULL);
	_g_object_unref0 (self->_doc);
	self->_doc = _tmp0_;
	g_object_notify_by_pspec ((GObject *) self, gxml_xnode_properties[GXML_XNODE_OWNER_DOCUMENT_PROPERTY]);
}

static GXmlDomNode*
gxml_xnode_real_get_parent_node (GXmlDomNode* base)
{
	GXmlDomNode* result;
	GXmlXNode* self;
	GXmlDomNode* _tmp0_;
	GXmlDomNode* _tmp1_;
	GXmlDomNode* _tmp2_;
	self = (GXmlXNode*) base;
	_tmp0_ = gxml_xnode_get_parent (self);
	_tmp1_ = _tmp0_;
	_tmp2_ = GXML_IS_DOM_NODE (_tmp1_) ? ((GXmlDomNode*) _tmp1_) : NULL;
	if (_tmp2_ == NULL) {
		_g_object_unref0 (_tmp1_);
	}
	result = _tmp2_;
	return result;
}

static GXmlDomElement*
gxml_xnode_real_get_parent_element (GXmlDomNode* base)
{
	GXmlDomElement* result;
	GXmlXNode* self;
	GXmlDomElement* nullnode = NULL;
	GXmlDomNode* _tmp0_;
	GXmlDomNode* _tmp1_;
	GXmlDomNode* _tmp2_;
	gboolean _tmp3_;
	self = (GXmlXNode*) base;
	nullnode = NULL;
	_tmp0_ = gxml_xnode_get_parent (self);
	_tmp1_ = _tmp0_;
	_tmp2_ = _tmp1_;
	_tmp3_ = GXML_IS_DOM_ELEMENT (_tmp2_);
	_g_object_unref0 (_tmp2_);
	if (_tmp3_) {
		GXmlDomNode* _tmp4_;
		GXmlDomNode* _tmp5_;
		GXmlDomElement* _tmp6_;
		_tmp4_ = gxml_xnode_get_parent (self);
		_tmp5_ = _tmp4_;
		_tmp6_ = GXML_IS_DOM_ELEMENT (_tmp5_) ? ((GXmlDomElement*) _tmp5_) : NULL;
		if (_tmp6_ == NULL) {
			_g_object_unref0 (_tmp5_);
		}
		result = _tmp6_;
		_g_object_unref0 (nullnode);
		return result;
	}
	result = nullnode;
	return result;
}

static GXmlDomNodeList*
gxml_xnode_real_get_child_nodes (GXmlDomNode* base)
{
	GXmlDomNodeList* result;
	GXmlXNode* self;
	GeeBidirList* _tmp0_;
	GeeBidirList* _tmp1_;
	GXmlDomNodeList* _tmp2_;
	self = (GXmlXNode*) base;
	_tmp0_ = gxml_xnode_get_children_nodes (self);
	_tmp1_ = _tmp0_;
	_tmp2_ = GXML_IS_DOM_NODE_LIST (_tmp1_) ? ((GXmlDomNodeList*) _tmp1_) : NULL;
	if (_tmp2_ == NULL) {
		_g_object_unref0 (_tmp1_);
	}
	result = _tmp2_;
	return result;
}

static GXmlDomNode*
gxml_xnode_real_get_first_child (GXmlDomNode* base)
{
	GXmlDomNode* result;
	GXmlXNode* self;
	GeeBidirList* _tmp0_;
	GeeBidirList* _tmp1_;
	GeeBidirList* _tmp2_;
	gpointer _tmp3_;
	GXmlDomNode* _tmp4_;
	GXmlDomNode* _tmp5_;
	GXmlDomNode* _tmp6_;
	self = (GXmlXNode*) base;
	_tmp0_ = gxml_xnode_get_children_nodes (self);
	_tmp1_ = _tmp0_;
	_tmp2_ = _tmp1_;
	_tmp3_ = gee_list_first ((GeeList*) _tmp2_);
	_tmp4_ = (GXmlDomNode*) _tmp3_;
	_tmp5_ = GXML_IS_DOM_NODE (_tmp4_) ? ((GXmlDomNode*) _tmp4_) : NULL;
	if (_tmp5_ == NULL) {
		_g_object_unref0 (_tmp4_);
	}
	_tmp6_ = _tmp5_;
	_g_object_unref0 (_tmp2_);
	result = _tmp6_;
	return result;
}

static GXmlDomNode*
gxml_xnode_real_get_last_child (GXmlDomNode* base)
{
	GXmlDomNode* result;
	GXmlXNode* self;
	GeeBidirList* _tmp0_;
	GeeBidirList* _tmp1_;
	GeeBidirList* _tmp2_;
	gpointer _tmp3_;
	GXmlDomNode* _tmp4_;
	GXmlDomNode* _tmp5_;
	GXmlDomNode* _tmp6_;
	self = (GXmlXNode*) base;
	_tmp0_ = gxml_xnode_get_children_nodes (self);
	_tmp1_ = _tmp0_;
	_tmp2_ = _tmp1_;
	_tmp3_ = gee_list_last ((GeeList*) _tmp2_);
	_tmp4_ = (GXmlDomNode*) _tmp3_;
	_tmp5_ = GXML_IS_DOM_NODE (_tmp4_) ? ((GXmlDomNode*) _tmp4_) : NULL;
	if (_tmp5_ == NULL) {
		_g_object_unref0 (_tmp4_);
	}
	_tmp6_ = _tmp5_;
	_g_object_unref0 (_tmp2_);
	result = _tmp6_;
	return result;
}

static GXmlDomNode*
gxml_xnode_real_get_previous_sibling (GXmlDomNode* base)
{
	GXmlDomNode* result;
	GXmlXNode* self;
	xmlNode* _tmp0_;
	xmlNode* _tmp1_;
	xmlNode* _tmp2_;
	GXmlXDocument* _tmp3_;
	xmlNode* _tmp4_;
	xmlNode* _tmp5_;
	GXmlDomNode* _tmp6_;
	GXmlDomNode* _tmp7_;
	self = (GXmlXNode*) base;
	_tmp0_ = self->_node;
	if (_tmp0_ == NULL) {
		result = NULL;
		return result;
	}
	_tmp1_ = self->_node;
	_tmp2_ = _tmp1_->prev;
	if (_tmp2_ == NULL) {
		result = NULL;
		return result;
	}
	_tmp3_ = self->_doc;
	_tmp4_ = self->_node;
	_tmp5_ = _tmp4_->prev;
	_tmp6_ = gxml_xnode_to_gnode (_tmp3_, _tmp5_, FALSE);
	_tmp7_ = GXML_IS_DOM_NODE (_tmp6_) ? ((GXmlDomNode*) _tmp6_) : NULL;
	if (_tmp7_ == NULL) {
		_g_object_unref0 (_tmp6_);
	}
	result = _tmp7_;
	return result;
}

static GXmlDomNode*
gxml_xnode_real_get_next_sibling (GXmlDomNode* base)
{
	GXmlDomNode* result;
	GXmlXNode* self;
	xmlNode* _tmp0_;
	xmlNode* _tmp1_;
	xmlNode* _tmp2_;
	GXmlXDocument* _tmp3_;
	xmlNode* _tmp4_;
	xmlNode* _tmp5_;
	GXmlDomNode* _tmp6_;
	GXmlDomNode* _tmp7_;
	self = (GXmlXNode*) base;
	_tmp0_ = self->_node;
	if (_tmp0_ == NULL) {
		result = NULL;
		return result;
	}
	_tmp1_ = self->_node;
	_tmp2_ = _tmp1_->next;
	if (_tmp2_ == NULL) {
		result = NULL;
		return result;
	}
	_tmp3_ = self->_doc;
	_tmp4_ = self->_node;
	_tmp5_ = _tmp4_->next;
	_tmp6_ = gxml_xnode_to_gnode (_tmp3_, _tmp5_, FALSE);
	_tmp7_ = GXML_IS_DOM_NODE (_tmp6_) ? ((GXmlDomNode*) _tmp6_) : NULL;
	if (_tmp7_ == NULL) {
		_g_object_unref0 (_tmp6_);
	}
	result = _tmp7_;
	return result;
}

static gchar*
gxml_xnode_real_get_node_value (GXmlDomNode* base)
{
	gchar* result;
	GXmlXNode* self;
	gchar* _tmp0_;
	gchar* _tmp1_;
	self = (GXmlXNode*) base;
	_tmp0_ = gxml_xnode_get_value (self);
	_tmp1_ = _tmp0_;
	result = _tmp1_;
	return result;
}

static void
gxml_xnode_real_set_node_value (GXmlDomNode* base,
                                const gchar* value)
{
	GXmlXNode* self;
	self = (GXmlXNode*) base;
	gxml_xnode_set_value (self, value);
	g_object_notify_by_pspec ((GObject *) self, gxml_xnode_properties[GXML_XNODE_NODE_VALUE_PROPERTY]);
}

static gchar*
gxml_xnode_real_get_text_content (GXmlDomNode* base)
{
	gchar* result;
	GXmlXNode* self;
	gchar* t = NULL;
	gboolean _tmp6_ = FALSE;
	self = (GXmlXNode*) base;
	t = NULL;
	if (GXML_IS_DOM_TEXT (self)) {
		gchar* _tmp0_;
		gchar* _tmp1_;
		_tmp0_ = gxml_dom_character_data_get_data ((GXmlDomCharacterData*) G_TYPE_CHECK_INSTANCE_CAST (self, GXML_TYPE_DOM_TEXT, GXmlDomText));
		_tmp1_ = _tmp0_;
		result = _tmp1_;
		_g_free0 (t);
		return result;
	}
	if (GXML_IS_DOM_PROCESSING_INSTRUCTION (self)) {
		gchar* _tmp2_;
		gchar* _tmp3_;
		_tmp2_ = gxml_xnode_get_value (self);
		_tmp3_ = _tmp2_;
		result = _tmp3_;
		_g_free0 (t);
		return result;
	}
	if (GXML_IS_DOM_COMMENT (self)) {
		gchar* _tmp4_;
		gchar* _tmp5_;
		_tmp4_ = gxml_xnode_get_value (self);
		_tmp5_ = _tmp4_;
		result = _tmp5_;
		_g_free0 (t);
		return result;
	}
	if (GXML_IS_DOM_DOCUMENT (self)) {
		_tmp6_ = TRUE;
	} else {
		_tmp6_ = GXML_IS_DOM_ELEMENT (self);
	}
	if (_tmp6_) {
		{
			GeeBidirList* _n_list = NULL;
			GeeBidirList* _tmp7_;
			GeeBidirList* _tmp8_;
			gint _n_size = 0;
			GeeBidirList* _tmp9_;
			gint _tmp10_;
			gint _tmp11_;
			gint _n_index = 0;
			_tmp7_ = gxml_xnode_get_children_nodes (self);
			_tmp8_ = _tmp7_;
			_n_list = _tmp8_;
			_tmp9_ = _n_list;
			_tmp10_ = gee_collection_get_size ((GeeCollection*) _tmp9_);
			_tmp11_ = _tmp10_;
			_n_size = _tmp11_;
			_n_index = -1;
			while (TRUE) {
				gint _tmp12_;
				gint _tmp13_;
				GXmlDomNode* n = NULL;
				GeeBidirList* _tmp14_;
				gpointer _tmp15_;
				GXmlDomNode* _tmp16_;
				_n_index = _n_index + 1;
				_tmp12_ = _n_index;
				_tmp13_ = _n_size;
				if (!(_tmp12_ < _tmp13_)) {
					break;
				}
				_tmp14_ = _n_list;
				_tmp15_ = gee_list_get ((GeeList*) _tmp14_, _n_index);
				n = (GXmlDomNode*) _tmp15_;
				_tmp16_ = n;
				if (GXML_IS_DOM_TEXT (_tmp16_)) {
					const gchar* _tmp17_;
					_tmp17_ = t;
					if (_tmp17_ == NULL) {
						GXmlDomNode* _tmp18_;
						gchar* _tmp19_;
						gchar* _tmp20_;
						_tmp18_ = n;
						_tmp19_ = gxml_xnode_get_value (G_TYPE_CHECK_INSTANCE_CAST (_tmp18_, GXML_TYPE_XNODE, GXmlXNode));
						_tmp20_ = _tmp19_;
						_g_free0 (t);
						t = _tmp20_;
					} else {
						const gchar* _tmp21_;
						GXmlDomNode* _tmp22_;
						gchar* _tmp23_;
						gchar* _tmp24_;
						gchar* _tmp25_;
						gchar* _tmp26_;
						_tmp21_ = t;
						_tmp22_ = n;
						_tmp23_ = gxml_xnode_get_value (G_TYPE_CHECK_INSTANCE_CAST (_tmp22_, GXML_TYPE_XNODE, GXmlXNode));
						_tmp24_ = _tmp23_;
						_tmp25_ = _tmp24_;
						_tmp26_ = g_strconcat (_tmp21_, _tmp25_, NULL);
						_g_free0 (t);
						t = _tmp26_;
						_g_free0 (_tmp25_);
					}
				}
				_g_object_unref0 (n);
			}
			_g_object_unref0 (_n_list);
		}
	}
	result = t;
	return result;
}

static void
gxml_xnode_real_set_text_content (GXmlDomNode* base,
                                  const gchar* value)
{
	GXmlXNode* self;
	gboolean _tmp0_ = FALSE;
	gboolean _tmp12_ = FALSE;
	gboolean _tmp13_ = FALSE;
	GError* _inner_error0_ = NULL;
	self = (GXmlXNode*) base;
	if (GXML_IS_DOM_DOCUMENT (self)) {
		_tmp0_ = TRUE;
	} else {
		_tmp0_ = GXML_IS_DOM_ELEMENT (self);
	}
	if (_tmp0_) {
		{
			GXmlDomText* t = NULL;
			GXmlDomDocument* _tmp1_;
			GXmlDomDocument* _tmp2_;
			GXmlDomText* _tmp3_;
			GXmlDomDocument* _tmp4_;
			GXmlDomDocument* _tmp5_;
			GXmlDomNodeList* _tmp6_;
			GXmlDomNodeList* _tmp7_;
			GXmlDomNodeList* _tmp8_;
			GXmlDomText* _tmp9_;
			_tmp1_ = gxml_xnode_get_document (self);
			_tmp2_ = _tmp1_;
			_tmp3_ = gxml_dom_document_create_text_node (_tmp2_, value, &_inner_error0_);
			t = _tmp3_;
			if (G_UNLIKELY (_inner_error0_ != NULL)) {
				goto __catch0_g_error;
			}
			_tmp4_ = gxml_xnode_get_document (self);
			_tmp5_ = _tmp4_;
			_tmp6_ = gxml_dom_node_get_child_nodes ((GXmlDomNode*) _tmp5_);
			_tmp7_ = _tmp6_;
			_tmp8_ = _tmp7_;
			_tmp9_ = t;
			gee_collection_add ((GeeCollection*) _tmp8_, (GXmlDomNode*) _tmp9_);
			_g_object_unref0 (_tmp8_);
			_g_object_unref0 (t);
		}
		goto __finally0;
		__catch0_g_error:
		{
			GError* e = NULL;
			GError* _tmp10_;
			const gchar* _tmp11_;
			e = _inner_error0_;
			_inner_error0_ = NULL;
			_tmp10_ = e;
			_tmp11_ = _tmp10_->message;
			g_warning (_ ("Error while setting text content to node: %s"), _tmp11_);
			_g_error_free0 (e);
		}
		__finally0:
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			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;
		}
	}
	if (GXML_IS_DOM_TEXT (self)) {
		_tmp13_ = TRUE;
	} else {
		_tmp13_ = GXML_IS_DOM_COMMENT (self);
	}
	if (_tmp13_) {
		_tmp12_ = TRUE;
	} else {
		_tmp12_ = GXML_IS_DOM_PROCESSING_INSTRUCTION (self);
	}
	if (!_tmp12_) {
		return;
	}
	gxml_xnode_set_value (self, value);
	g_object_notify_by_pspec ((GObject *) self, gxml_xnode_properties[GXML_XNODE_TEXT_CONTENT_PROPERTY]);
}

static gboolean
gxml_xnode_real_has_child_nodes (GXmlDomNode* base)
{
	GXmlXNode * self;
	GeeBidirList* _tmp0_;
	GeeBidirList* _tmp1_;
	GeeBidirList* _tmp2_;
	gint _tmp3_;
	gint _tmp4_;
	gboolean _tmp5_;
	gboolean result;
	self = (GXmlXNode*) base;
	_tmp0_ = gxml_xnode_get_children_nodes (self);
	_tmp1_ = _tmp0_;
	_tmp2_ = _tmp1_;
	_tmp3_ = gee_collection_get_size ((GeeCollection*) _tmp2_);
	_tmp4_ = _tmp3_;
	_tmp5_ = _tmp4_ > 0;
	_g_object_unref0 (_tmp2_);
	result = _tmp5_;
	return result;
}

static void
gxml_xnode_real_normalize (GXmlDomNode* base)
{
	GXmlXNode * self;
	self = (GXmlXNode*) base;
	{
		gint i = 0;
		i = 0;
		{
			gboolean _tmp0_ = FALSE;
			_tmp0_ = TRUE;
			while (TRUE) {
				GeeBidirList* _tmp2_;
				GeeBidirList* _tmp3_;
				GeeBidirList* _tmp4_;
				gint _tmp5_;
				gint _tmp6_;
				gboolean _tmp7_;
				GXmlDomNode* n = NULL;
				GeeBidirList* _tmp8_;
				GeeBidirList* _tmp9_;
				GeeBidirList* _tmp10_;
				gpointer _tmp11_;
				GXmlDomNode* _tmp12_;
				GXmlDomNode* _tmp13_;
				if (!_tmp0_) {
					gint _tmp1_;
					_tmp1_ = i;
					i = _tmp1_ + 1;
				}
				_tmp0_ = FALSE;
				_tmp2_ = gxml_xnode_get_children_nodes (self);
				_tmp3_ = _tmp2_;
				_tmp4_ = _tmp3_;
				_tmp5_ = gee_collection_get_size ((GeeCollection*) _tmp4_);
				_tmp6_ = _tmp5_;
				_tmp7_ = !(i < _tmp6_);
				_g_object_unref0 (_tmp4_);
				if (_tmp7_) {
					break;
				}
				_tmp8_ = gxml_xnode_get_children_nodes (self);
				_tmp9_ = _tmp8_;
				_tmp10_ = _tmp9_;
				_tmp11_ = gee_list_get ((GeeList*) _tmp10_, i);
				_tmp12_ = (GXmlDomNode*) _tmp11_;
				_g_object_unref0 (_tmp10_);
				n = _tmp12_;
				_tmp13_ = n;
				if (GXML_IS_DOM_TEXT (_tmp13_)) {
					GXmlDomNodeList* _tmp14_;
					GXmlDomNodeList* _tmp15_;
					GXmlDomNodeList* _tmp16_;
					gpointer _tmp17_;
					GXmlDomNode* _tmp18_;
					_tmp14_ = gxml_dom_node_get_child_nodes ((GXmlDomNode*) self);
					_tmp15_ = _tmp14_;
					_tmp16_ = _tmp15_;
					_tmp17_ = gee_list_remove_at ((GeeList*) _tmp16_, i);
					_tmp18_ = (GXmlDomNode*) _tmp17_;
					_g_object_unref0 (_tmp18_);
					_g_object_unref0 (_tmp16_);
				}
				_g_object_unref0 (n);
			}
		}
	}
}

GXmlDomNode*
gxml_xnode_clone_node (GXmlXNode* self,
                       gboolean deep)
{
	GXmlDomNode* nullnode = NULL;
	xmlNode* n = NULL;
	xmlNode* _tmp4_;
	GXmlXDocument* _tmp5_;
	xmlNode* _tmp6_;
	GXmlDomNode* _tmp7_;
	GXmlDomNode* result;
	g_return_val_if_fail (self != NULL, NULL);
	nullnode = NULL;
	n = NULL;
	if (deep) {
		xmlNode* _tmp0_;
		xmlNode* _tmp1_;
		_tmp0_ = self->_node;
		_tmp1_ = xmlCopyNode (_tmp0_, 1);
		n = _tmp1_;
	} else {
		xmlNode* _tmp2_;
		xmlNode* _tmp3_;
		_tmp2_ = self->_node;
		_tmp3_ = xmlCopyNode (_tmp2_, 2);
		n = _tmp3_;
	}
	_tmp4_ = n;
	if (_tmp4_ == NULL) {
		result = nullnode;
		return result;
	}
	_tmp5_ = self->_doc;
	_tmp6_ = n;
	_tmp7_ = gxml_xnode_to_gnode (_tmp5_, _tmp6_, TRUE);
	result = G_TYPE_CHECK_INSTANCE_CAST (_tmp7_, GXML_TYPE_DOM_NODE, GXmlDomNode);
	_g_object_unref0 (nullnode);
	return result;
}

static gboolean
gxml_xnode_real_is_equal_node (GXmlDomNode* base,
                               GXmlDomNode* node)
{
	GXmlXNode * self;
	GeeBidirList* _tmp0_;
	GeeBidirList* _tmp1_;
	GeeBidirList* _tmp2_;
	gint _tmp3_;
	gint _tmp4_;
	GXmlDomNodeList* _tmp5_;
	GXmlDomNodeList* _tmp6_;
	GXmlDomNodeList* _tmp7_;
	gint _tmp8_;
	gint _tmp9_;
	gboolean _tmp10_;
	gboolean result;
	self = (GXmlXNode*) base;
	if (!GXML_IS_DOM_NODE (node)) {
		result = FALSE;
		return result;
	}
	if (node == NULL) {
		result = FALSE;
		return result;
	}
	_tmp0_ = gxml_xnode_get_children_nodes (self);
	_tmp1_ = _tmp0_;
	_tmp2_ = _tmp1_;
	_tmp3_ = gee_collection_get_size ((GeeCollection*) _tmp2_);
	_tmp4_ = _tmp3_;
	_tmp5_ = gxml_dom_node_get_child_nodes (node);
	_tmp6_ = _tmp5_;
	_tmp7_ = _tmp6_;
	_tmp8_ = gee_collection_get_size ((GeeCollection*) _tmp7_);
	_tmp9_ = _tmp8_;
	_tmp10_ = _tmp4_ != _tmp9_;
	_g_object_unref0 (_tmp7_);
	_g_object_unref0 (_tmp2_);
	if (_tmp10_) {
		result = FALSE;
		return result;
	}
	{
		GeeIterator* _a_it = NULL;
		GeeMap* _tmp11_;
		GeeMap* _tmp12_;
		GeeMap* _tmp13_;
		GeeCollection* _tmp14_;
		GeeCollection* _tmp15_;
		GeeCollection* _tmp16_;
		GeeIterator* _tmp17_;
		GeeIterator* _tmp18_;
		_tmp11_ = gxml_xnode_get_attrs (self);
		_tmp12_ = _tmp11_;
		_tmp13_ = _tmp12_;
		_tmp14_ = gee_map_get_values (_tmp13_);
		_tmp15_ = _tmp14_;
		_tmp16_ = _tmp15_;
		_tmp17_ = gee_iterable_iterator ((GeeIterable*) _tmp16_);
		_tmp18_ = _tmp17_;
		_g_object_unref0 (_tmp16_);
		_g_object_unref0 (_tmp13_);
		_a_it = _tmp18_;
		while (TRUE) {
			GeeIterator* _tmp19_;
			GXmlDomNode* a = NULL;
			GeeIterator* _tmp20_;
			gpointer _tmp21_;
			GeeMap* _tmp22_;
			GeeMap* _tmp23_;
			GeeMap* _tmp24_;
			GXmlDomNode* _tmp25_;
			gchar* _tmp26_;
			gchar* _tmp27_;
			gchar* _tmp28_;
			gboolean _tmp29_;
			GXmlDomNode* _tmp30_;
			gchar* _tmp31_;
			gchar* _tmp32_;
			gchar* _tmp33_;
			GeeMap* _tmp34_;
			GeeMap* _tmp35_;
			GeeMap* _tmp36_;
			GXmlDomNode* _tmp37_;
			gchar* _tmp38_;
			gchar* _tmp39_;
			gchar* _tmp40_;
			gpointer _tmp41_;
			GXmlXNode* _tmp42_;
			gchar* _tmp43_;
			gchar* _tmp44_;
			gchar* _tmp45_;
			gboolean _tmp46_;
			_tmp19_ = _a_it;
			if (!gee_iterator_next (_tmp19_)) {
				break;
			}
			_tmp20_ = _a_it;
			_tmp21_ = gee_iterator_get (_tmp20_);
			a = (GXmlDomNode*) _tmp21_;
			_tmp22_ = gxml_xnode_get_attrs (G_TYPE_CHECK_INSTANCE_CAST (node, GXML_TYPE_XNODE, GXmlXNode));
			_tmp23_ = _tmp22_;
			_tmp24_ = _tmp23_;
			_tmp25_ = a;
			_tmp26_ = gxml_dom_node_get_node_name (_tmp25_);
			_tmp27_ = _tmp26_;
			_tmp28_ = _tmp27_;
			_tmp29_ = !gee_map_has_key (_tmp24_, _tmp28_);
			_g_free0 (_tmp28_);
			_g_object_unref0 (_tmp24_);
			if (_tmp29_) {
				result = FALSE;
				_g_object_unref0 (a);
				_g_object_unref0 (_a_it);
				return result;
			}
			_tmp30_ = a;
			_tmp31_ = gxml_xnode_get_value (G_TYPE_CHECK_INSTANCE_CAST (_tmp30_, GXML_TYPE_XNODE, GXmlXNode));
			_tmp32_ = _tmp31_;
			_tmp33_ = _tmp32_;
			_tmp34_ = gxml_xnode_get_attrs (G_TYPE_CHECK_INSTANCE_CAST (node, GXML_TYPE_XNODE, GXmlXNode));
			_tmp35_ = _tmp34_;
			_tmp36_ = _tmp35_;
			_tmp37_ = a;
			_tmp38_ = gxml_dom_node_get_node_name (_tmp37_);
			_tmp39_ = _tmp38_;
			_tmp40_ = _tmp39_;
			_tmp41_ = gee_map_get (_tmp36_, _tmp40_);
			_tmp42_ = G_TYPE_CHECK_INSTANCE_CAST ((GXmlDomNode*) _tmp41_, GXML_TYPE_XNODE, GXmlXNode);
			_tmp43_ = gxml_xnode_get_value (_tmp42_);
			_tmp44_ = _tmp43_;
			_tmp45_ = _tmp44_;
			_tmp46_ = g_strcmp0 (_tmp33_, _tmp45_) != 0;
			_g_free0 (_tmp45_);
			_g_object_unref0 (_tmp42_);
			_g_free0 (_tmp40_);
			_g_object_unref0 (_tmp36_);
			_g_free0 (_tmp33_);
			if (_tmp46_) {
				result = FALSE;
				_g_object_unref0 (a);
				_g_object_unref0 (_a_it);
				return result;
			}
			_g_object_unref0 (a);
		}
		_g_object_unref0 (_a_it);
	}
	{
		gint i = 0;
		i = 0;
		{
			gboolean _tmp47_ = FALSE;
			_tmp47_ = TRUE;
			while (TRUE) {
				GeeBidirList* _tmp49_;
				GeeBidirList* _tmp50_;
				GeeBidirList* _tmp51_;
				gint _tmp52_;
				gint _tmp53_;
				gboolean _tmp54_;
				GeeBidirList* _tmp55_;
				GeeBidirList* _tmp56_;
				GeeBidirList* _tmp57_;
				gpointer _tmp58_;
				GXmlDomNode* _tmp59_;
				GXmlDomNodeList* _tmp60_;
				GXmlDomNodeList* _tmp61_;
				GXmlDomNodeList* _tmp62_;
				gpointer _tmp63_;
				GXmlDomNode* _tmp64_;
				gboolean _tmp65_;
				if (!_tmp47_) {
					gint _tmp48_;
					_tmp48_ = i;
					i = _tmp48_ + 1;
				}
				_tmp47_ = FALSE;
				_tmp49_ = gxml_xnode_get_children_nodes (self);
				_tmp50_ = _tmp49_;
				_tmp51_ = _tmp50_;
				_tmp52_ = gee_collection_get_size ((GeeCollection*) _tmp51_);
				_tmp53_ = _tmp52_;
				_tmp54_ = !(i < _tmp53_);
				_g_object_unref0 (_tmp51_);
				if (_tmp54_) {
					break;
				}
				_tmp55_ = gxml_xnode_get_children_nodes (self);
				_tmp56_ = _tmp55_;
				_tmp57_ = _tmp56_;
				_tmp58_ = gee_list_get ((GeeList*) _tmp57_, i);
				_tmp59_ = G_TYPE_CHECK_INSTANCE_CAST ((GXmlDomNode*) _tmp58_, GXML_TYPE_DOM_NODE, GXmlDomNode);
				_tmp60_ = gxml_dom_node_get_child_nodes (G_TYPE_CHECK_INSTANCE_CAST (node, GXML_TYPE_DOM_NODE, GXmlDomNode));
				_tmp61_ = _tmp60_;
				_tmp62_ = _tmp61_;
				_tmp63_ = gee_list_get ((GeeList*) _tmp62_, i);
				_tmp64_ = (GXmlDomNode*) _tmp63_;
				_tmp65_ = !gxml_dom_node_is_equal_node (_tmp59_, _tmp64_);
				_g_object_unref0 (_tmp64_);
				_g_object_unref0 (_tmp62_);
				_g_object_unref0 (_tmp59_);
				_g_object_unref0 (_tmp57_);
				if (_tmp65_) {
					result = FALSE;
					return result;
				}
			}
		}
	}
	result = TRUE;
	return result;
}

static GXmlDomNodeDocumentPosition
gxml_xnode_real_compare_document_position (GXmlDomNode* base,
                                           GXmlDomNode* other)
{
	GXmlXNode * self;
	gboolean _tmp0_ = FALSE;
	GXmlDomDocument* _tmp1_;
	GXmlDomDocument* _tmp2_;
	GXmlDomDocument* _tmp3_;
	GXmlDomDocument* _tmp4_;
	GXmlDomNode* _tmp8_;
	GXmlDomNode* _tmp9_;
	GXmlDomNode* _tmp10_;
	gboolean _tmp11_;
	GXmlDomNodeDocumentPosition result;
	self = (GXmlXNode*) base;
	g_return_val_if_fail (other != NULL, 0U);
	if ((GXML_IS_DOM_NODE (self) ? ((GXmlDomNode*) self) : NULL) == other) {
		result = GXML_DOM_NODE_DOCUMENT_POSITION_NONE;
		return result;
	}
	_tmp1_ = gxml_xnode_get_document (self);
	_tmp2_ = _tmp1_;
	_tmp3_ = gxml_dom_node_get_owner_document (G_TYPE_CHECK_INSTANCE_CAST (other, GXML_TYPE_DOM_NODE, GXmlDomNode));
	_tmp4_ = _tmp3_;
	if (_tmp2_ != _tmp4_) {
		_tmp0_ = TRUE;
	} else {
		GXmlDomNode* _tmp5_;
		GXmlDomNode* _tmp6_;
		GXmlDomNode* _tmp7_;
		_tmp5_ = gxml_dom_node_get_parent_node (other);
		_tmp6_ = _tmp5_;
		_tmp7_ = _tmp6_;
		_tmp0_ = _tmp7_ == NULL;
		_g_object_unref0 (_tmp7_);
	}
	if (_tmp0_) {
		GXmlDomNodeDocumentPosition p = 0U;
		p = GXML_DOM_NODE_DOCUMENT_POSITION_DISCONNECTED & GXML_DOM_NODE_DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC;
		if ((&self) > (&other)) {
			p = p & GXML_DOM_NODE_DOCUMENT_POSITION_PRECEDING;
		} else {
			p = p & GXML_DOM_NODE_DOCUMENT_POSITION_FOLLOWING;
		}
		result = p;
		return result;
	}
	if (gxml_dom_node_contains (G_TYPE_CHECK_INSTANCE_CAST (self, GXML_TYPE_DOM_NODE, GXmlDomNode), other)) {
		result = GXML_DOM_NODE_DOCUMENT_POSITION_CONTAINED_BY & GXML_DOM_NODE_DOCUMENT_POSITION_FOLLOWING;
		return result;
	}
	_tmp8_ = gxml_dom_node_get_parent_node ((GXmlDomNode*) self);
	_tmp9_ = _tmp8_;
	_tmp10_ = _tmp9_;
	_tmp11_ = gxml_dom_node_contains (_tmp10_, other);
	_g_object_unref0 (_tmp10_);
	if (_tmp11_) {
		GXmlDomNode* par = NULL;
		GXmlDomNode* _tmp12_;
		GXmlDomNode* _tmp13_;
		GXmlDomNode* _tmp14_;
		GXmlDomNodeList* _tmp15_;
		GXmlDomNodeList* _tmp16_;
		GXmlDomNodeList* _tmp17_;
		GXmlDomNode* _tmp18_;
		GXmlDomNodeList* _tmp19_;
		GXmlDomNodeList* _tmp20_;
		GXmlDomNodeList* _tmp21_;
		gboolean _tmp22_;
		_tmp12_ = gxml_dom_node_get_parent_node ((GXmlDomNode*) self);
		_tmp13_ = _tmp12_;
		par = _tmp13_;
		_tmp14_ = par;
		_tmp15_ = gxml_dom_node_get_child_nodes (_tmp14_);
		_tmp16_ = _tmp15_;
		_tmp17_ = _tmp16_;
		_tmp18_ = par;
		_tmp19_ = gxml_dom_node_get_child_nodes (_tmp18_);
		_tmp20_ = _tmp19_;
		_tmp21_ = _tmp20_;
		_tmp22_ = gee_list_index_of ((GeeList*) _tmp17_, (GXmlDomNode*) self) > gee_list_index_of ((GeeList*) _tmp21_, other);
		_g_object_unref0 (_tmp21_);
		_g_object_unref0 (_tmp17_);
		if (_tmp22_) {
			result = GXML_DOM_NODE_DOCUMENT_POSITION_PRECEDING;
			_g_object_unref0 (par);
			return result;
		} else {
			result = GXML_DOM_NODE_DOCUMENT_POSITION_FOLLOWING;
			_g_object_unref0 (par);
			return result;
		}
		_g_object_unref0 (par);
	}
	if (gxml_dom_node_contains (other, (GXmlDomNode*) self)) {
		result = GXML_DOM_NODE_DOCUMENT_POSITION_CONTAINS & GXML_DOM_NODE_DOCUMENT_POSITION_PRECEDING;
		return result;
	}
	g_warning ("XNode.vala:328: %s", _ ("Can't find node position"));
	result = GXML_DOM_NODE_DOCUMENT_POSITION_NONE;
	return result;
}

static gboolean
gxml_xnode_real_contains (GXmlDomNode* base,
                          GXmlDomNode* other)
{
	GXmlXNode * self;
	GXmlDomNodeList* _tmp0_;
	GXmlDomNodeList* _tmp1_;
	GXmlDomNodeList* _tmp2_;
	gboolean _tmp3_;
	gboolean result;
	self = (GXmlXNode*) base;
	if (other == NULL) {
		result = FALSE;
		return result;
	}
	_tmp0_ = gxml_dom_node_get_child_nodes ((GXmlDomNode*) self);
	_tmp1_ = _tmp0_;
	_tmp2_ = _tmp1_;
	_tmp3_ = gee_collection_contains ((GeeCollection*) _tmp2_, other);
	_g_object_unref0 (_tmp2_);
	result = _tmp3_;
	return result;
}

static gchar*
gxml_xnode_real_lookup_prefix (GXmlDomNode* base,
                               const gchar* nspace)
{
	GXmlXNode * self;
	xmlNode* _tmp0_;
	GXmlDomNode* _tmp1_;
	GXmlDomNode* _tmp2_;
	GXmlDomNode* _tmp3_;
	gboolean _tmp4_;
	gboolean _tmp5_ = FALSE;
	xmlNs* ns = NULL;
	xmlNode* _tmp6_;
	xmlDoc* _tmp7_;
	xmlNode* _tmp8_;
	xmlNs* _tmp9_;
	xmlNs* _tmp10_;
	xmlNs* _tmp11_;
	const gchar* _tmp12_;
	gchar* _tmp13_;
	gchar* result;
	self = (GXmlXNode*) base;
	_tmp0_ = self->_node;
	if (_tmp0_ == NULL) {
		result = NULL;
		return result;
	}
	_tmp1_ = gxml_xnode_get_parent (self);
	_tmp2_ = _tmp1_;
	_tmp3_ = _tmp2_;
	_tmp4_ = _tmp3_ == NULL;
	_g_object_unref0 (_tmp3_);
	if (_tmp4_) {
		result = NULL;
		return result;
	}
	if (GXML_IS_DOM_DOCUMENT_TYPE (self)) {
		_tmp5_ = TRUE;
	} else {
		_tmp5_ = GXML_IS_DOM_DOCUMENT_FRAGMENT (self);
	}
	if (_tmp5_) {
		result = NULL;
		return result;
	}
	_tmp6_ = self->_node;
	_tmp7_ = _tmp6_->doc;
	_tmp8_ = self->_node;
	_tmp9_ = xmlSearchNsByHref (_tmp7_, _tmp8_, nspace);
	ns = _tmp9_;
	_tmp10_ = ns;
	if (_tmp10_ == NULL) {
		result = NULL;
		return result;
	}
	_tmp11_ = ns;
	_tmp12_ = _tmp11_->prefix;
	_tmp13_ = g_strdup (_tmp12_);
	result = _tmp13_;
	return result;
}

static gchar*
gxml_xnode_real_lookup_namespace_uri (GXmlDomNode* base,
                                      const gchar* prefix)
{
	GXmlXNode * self;
	gboolean _tmp0_ = FALSE;
	xmlNs* ns = NULL;
	xmlNode* _tmp1_;
	xmlDoc* _tmp2_;
	xmlNode* _tmp3_;
	xmlNs* _tmp4_;
	xmlNs* _tmp5_;
	xmlNs* _tmp6_;
	const gchar* _tmp7_;
	gchar* _tmp8_;
	gchar* result;
	self = (GXmlXNode*) base;
	if (GXML_IS_DOM_DOCUMENT_TYPE (self)) {
		_tmp0_ = TRUE;
	} else {
		_tmp0_ = GXML_IS_DOM_DOCUMENT_FRAGMENT (self);
	}
	if (_tmp0_) {
		result = NULL;
		return result;
	}
	_tmp1_ = self->_node;
	_tmp2_ = _tmp1_->doc;
	_tmp3_ = self->_node;
	_tmp4_ = xmlSearchNs (_tmp2_, _tmp3_, prefix);
	ns = _tmp4_;
	_tmp5_ = ns;
	if (_tmp5_ == NULL) {
		result = NULL;
		return result;
	}
	_tmp6_ = ns;
	_tmp7_ = _tmp6_->href;
	_tmp8_ = g_strdup (_tmp7_);
	result = _tmp8_;
	return result;
}

static gboolean
gxml_xnode_real_is_default_namespace (GXmlDomNode* base,
                                      const gchar* nspace)
{
	GXmlXNode * self;
	gchar* ns = NULL;
	gchar* _tmp0_;
	const gchar* _tmp1_;
	gboolean result;
	self = (GXmlXNode*) base;
	if (nspace == NULL) {
		result = FALSE;
		return result;
	}
	_tmp0_ = gxml_dom_node_lookup_namespace_uri ((GXmlDomNode*) self, NULL);
	ns = _tmp0_;
	_tmp1_ = ns;
	if (g_strcmp0 (_tmp1_, nspace) == 0) {
		result = TRUE;
		_g_free0 (ns);
		return result;
	}
	result = FALSE;
	_g_free0 (ns);
	return result;
}

static GXmlDomNode*
gxml_xnode_real_insert_before (GXmlDomNode* base,
                               GXmlDomNode* node,
                               GXmlDomNode* child,
                               GError** error)
{
	GXmlXNode * self;
	gboolean _tmp1_ = FALSE;
	gboolean _tmp3_ = FALSE;
	gboolean _tmp4_ = FALSE;
	gboolean _tmp6_ = FALSE;
	gboolean _tmp7_ = FALSE;
	gboolean _tmp8_ = FALSE;
	gboolean _tmp9_ = FALSE;
	gboolean _tmp10_ = FALSE;
	gboolean _tmp12_ = FALSE;
	gboolean _tmp13_ = FALSE;
	GeeBidirList* _tmp24_;
	GeeBidirList* _tmp25_;
	GeeBidirList* _tmp26_;
	GXmlDomNode* _tmp27_;
	GError* _inner_error0_ = NULL;
	GXmlDomNode* result;
	self = (GXmlXNode*) base;
	g_return_val_if_fail (node != NULL, NULL);
	if (!GXML_IS_XNODE (node)) {
		GError* _tmp0_;
		_tmp0_ = g_error_new_literal (GXML_DOM_ERROR, GXML_DOM_ERROR_INVALID_NODE_TYPE_ERROR, _ ("Invalid attempt to add invalid node type"));
		_inner_error0_ = _tmp0_;
		g_propagate_error (error, _inner_error0_);
		return NULL;
	}
	if (child != NULL) {
		_tmp1_ = !gxml_dom_node_contains ((GXmlDomNode*) self, child);
	} else {
		_tmp1_ = FALSE;
	}
	if (_tmp1_) {
		GError* _tmp2_;
		_tmp2_ = g_error_new_literal (GXML_DOM_ERROR, GXML_DOM_ERROR_NOT_FOUND_ERROR, _ ("Can't find child to insert node before"));
		_inner_error0_ = _tmp2_;
		g_propagate_error (error, _inner_error0_);
		return NULL;
	}
	if (GXML_IS_DOM_DOCUMENT (self)) {
		_tmp4_ = TRUE;
	} else {
		_tmp4_ = GXML_IS_DOM_ELEMENT (self);
	}
	if (_tmp4_) {
		_tmp3_ = TRUE;
	} else {
		_tmp3_ = GXML_IS_DOM_DOCUMENT_FRAGMENT (self);
	}
	if (!_tmp3_) {
		GError* _tmp5_;
		_tmp5_ = g_error_new_literal (GXML_DOM_ERROR, GXML_DOM_ERROR_HIERARCHY_REQUEST_ERROR, _ ("Invalid attempt to insert a node"));
		_inner_error0_ = _tmp5_;
		g_propagate_error (error, _inner_error0_);
		return NULL;
	}
	if (GXML_IS_DOM_DOCUMENT_FRAGMENT (node)) {
		_tmp10_ = TRUE;
	} else {
		_tmp10_ = GXML_IS_DOM_DOCUMENT_TYPE (node);
	}
	if (_tmp10_) {
		_tmp9_ = TRUE;
	} else {
		_tmp9_ = GXML_IS_DOM_ELEMENT (node);
	}
	if (_tmp9_) {
		_tmp8_ = TRUE;
	} else {
		_tmp8_ = GXML_IS_DOM_TEXT (node);
	}
	if (_tmp8_) {
		_tmp7_ = TRUE;
	} else {
		_tmp7_ = GXML_IS_DOM_PROCESSING_INSTRUCTION (node);
	}
	if (_tmp7_) {
		_tmp6_ = TRUE;
	} else {
		_tmp6_ = GXML_IS_DOM_COMMENT (node);
	}
	if (!_tmp6_) {
		GError* _tmp11_;
		_tmp11_ = g_error_new_literal (GXML_DOM_ERROR, GXML_DOM_ERROR_HIERARCHY_REQUEST_ERROR, _ ("Invalid attempt to insert an invalid node type"));
		_inner_error0_ = _tmp11_;
		g_propagate_error (error, _inner_error0_);
		return NULL;
	}
	if (GXML_IS_DOM_TEXT (node)) {
		_tmp13_ = GXML_IS_DOM_DOCUMENT (self);
	} else {
		_tmp13_ = FALSE;
	}
	if (_tmp13_) {
		_tmp12_ = TRUE;
	} else {
		gboolean _tmp14_ = FALSE;
		if (GXML_IS_DOM_DOCUMENT_TYPE (node)) {
			_tmp14_ = !GXML_IS_DOM_DOCUMENT (self);
		} else {
			_tmp14_ = FALSE;
		}
		_tmp12_ = _tmp14_;
	}
	if (_tmp12_) {
		GError* _tmp15_;
		_tmp15_ = g_error_new_literal (GXML_DOM_ERROR, GXML_DOM_ERROR_HIERARCHY_REQUEST_ERROR, _ ("Invalid attempt to insert a document's type or text node to an invalid" \
" parent"));
		_inner_error0_ = _tmp15_;
		g_propagate_error (error, _inner_error0_);
		return NULL;
	}
	if (child != NULL) {
		gint i = 0;
		GeeBidirList* _tmp16_;
		GeeBidirList* _tmp17_;
		GeeBidirList* _tmp18_;
		gint _tmp19_;
		GeeBidirList* _tmp20_;
		GeeBidirList* _tmp21_;
		GeeBidirList* _tmp22_;
		GXmlDomNode* _tmp23_;
		_tmp16_ = gxml_xnode_get_children_nodes (self);
		_tmp17_ = _tmp16_;
		_tmp18_ = _tmp17_;
		_tmp19_ = gee_list_index_of ((GeeList*) _tmp18_, GXML_IS_DOM_NODE (child) ? ((GXmlDomNode*) child) : NULL);
		_g_object_unref0 (_tmp18_);
		i = _tmp19_;
		_tmp20_ = gxml_xnode_get_children_nodes (self);
		_tmp21_ = _tmp20_;
		_tmp22_ = _tmp21_;
		gee_list_insert ((GeeList*) _tmp22_, i, GXML_IS_DOM_NODE (node) ? ((GXmlDomNode*) node) : NULL);
		_g_object_unref0 (_tmp22_);
		_tmp23_ = _g_object_ref0 (node);
		result = _tmp23_;
		return result;
	}
	_tmp24_ = gxml_xnode_get_children_nodes (self);
	_tmp25_ = _tmp24_;
	_tmp26_ = _tmp25_;
	gee_collection_add ((GeeCollection*) _tmp26_, GXML_IS_DOM_NODE (node) ? ((GXmlDomNode*) node) : NULL);
	_g_object_unref0 (_tmp26_);
	_tmp27_ = _g_object_ref0 (node);
	result = _tmp27_;
	return result;
}

static GXmlDomNode*
gxml_xnode_real_append_child (GXmlDomNode* base,
                              GXmlDomNode* node,
                              GError** error)
{
	GXmlXNode * self;
	GXmlDomNode* _tmp0_ = NULL;
	GXmlDomNode* _tmp1_;
	GXmlDomNode* _tmp2_;
	GError* _inner_error0_ = NULL;
	GXmlDomNode* result;
	self = (GXmlXNode*) base;
	g_return_val_if_fail (node != NULL, NULL);
	_tmp1_ = gxml_dom_node_insert_before ((GXmlDomNode*) self, node, NULL, &_inner_error0_);
	_tmp0_ = _tmp1_;
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		g_propagate_error (error, _inner_error0_);
		return NULL;
	}
	_tmp2_ = _tmp0_;
	_tmp0_ = NULL;
	result = _tmp2_;
	_g_object_unref0 (_tmp0_);
	return result;
}

static GXmlDomNode*
gxml_xnode_real_replace_child (GXmlDomNode* base,
                               GXmlDomNode* node,
                               GXmlDomNode* child,
                               GError** error)
{
	GXmlXNode * self;
	gboolean _tmp2_ = FALSE;
	gboolean _tmp4_ = FALSE;
	gboolean _tmp5_ = FALSE;
	gboolean _tmp7_ = FALSE;
	gboolean _tmp8_ = FALSE;
	gboolean _tmp9_ = FALSE;
	gboolean _tmp10_ = FALSE;
	gboolean _tmp11_ = FALSE;
	gboolean _tmp14_ = FALSE;
	gboolean _tmp15_ = FALSE;
	gint i = 0;
	GeeBidirList* _tmp18_;
	GeeBidirList* _tmp19_;
	GeeBidirList* _tmp20_;
	gint _tmp21_;
	GXmlDomNode* rch = NULL;
	GeeBidirList* _tmp22_;
	GeeBidirList* _tmp23_;
	GeeBidirList* _tmp24_;
	gpointer _tmp25_;
	GXmlDomNode* _tmp26_;
	GeeBidirList* _tmp27_;
	GeeBidirList* _tmp28_;
	GeeBidirList* _tmp29_;
	gint _tmp30_;
	gint _tmp31_;
	gboolean _tmp32_;
	GeeBidirList* _tmp36_;
	GeeBidirList* _tmp37_;
	GeeBidirList* _tmp38_;
	gint _tmp39_;
	gint _tmp40_;
	gboolean _tmp41_;
	GXmlDomNode* _tmp45_;
	GXmlDomNode* _tmp46_;
	GError* _inner_error0_ = NULL;
	GXmlDomNode* result;
	self = (GXmlXNode*) base;
	g_return_val_if_fail (node != NULL, NULL);
	g_return_val_if_fail (child != NULL, NULL);
	if (!GXML_IS_XNODE (node)) {
		const gchar* _tmp0_;
		GError* _tmp1_;
		_tmp0_ = g_type_name (G_TYPE_FROM_INSTANCE ((GObject*) node));
		_tmp1_ = g_error_new (GXML_DOM_ERROR, GXML_DOM_ERROR_INVALID_NODE_TYPE_ERROR, _ ("Only GXml.XNode nodes are supported. Given a %s type"), _tmp0_);
		_inner_error0_ = _tmp1_;
		g_propagate_error (error, _inner_error0_);
		return NULL;
	}
	if (child == NULL) {
		_tmp2_ = TRUE;
	} else {
		_tmp2_ = !gxml_dom_node_contains ((GXmlDomNode*) self, child);
	}
	if (_tmp2_) {
		GError* _tmp3_;
		_tmp3_ = g_error_new_literal (GXML_DOM_ERROR, GXML_DOM_ERROR_NOT_FOUND_ERROR, _ ("Can't find child node to replace or child have a different parent"));
		_inner_error0_ = _tmp3_;
		g_propagate_error (error, _inner_error0_);
		return NULL;
	}
	if (GXML_IS_DOM_DOCUMENT (self)) {
		_tmp5_ = TRUE;
	} else {
		_tmp5_ = GXML_IS_DOM_ELEMENT (self);
	}
	if (_tmp5_) {
		_tmp4_ = TRUE;
	} else {
		_tmp4_ = GXML_IS_DOM_DOCUMENT_FRAGMENT (self);
	}
	if (!_tmp4_) {
		GError* _tmp6_;
		_tmp6_ = g_error_new_literal (GXML_DOM_ERROR, GXML_DOM_ERROR_HIERARCHY_REQUEST_ERROR, _ ("Invalid attempt to replace a node on unsupported parent"));
		_inner_error0_ = _tmp6_;
		g_propagate_error (error, _inner_error0_);
		return NULL;
	}
	if (GXML_IS_DOM_DOCUMENT_FRAGMENT (node)) {
		_tmp11_ = TRUE;
	} else {
		_tmp11_ = GXML_IS_DOM_DOCUMENT_TYPE (node);
	}
	if (_tmp11_) {
		_tmp10_ = TRUE;
	} else {
		_tmp10_ = GXML_IS_DOM_ELEMENT (node);
	}
	if (_tmp10_) {
		_tmp9_ = TRUE;
	} else {
		_tmp9_ = GXML_IS_DOM_TEXT (node);
	}
	if (_tmp9_) {
		_tmp8_ = TRUE;
	} else {
		_tmp8_ = GXML_IS_DOM_PROCESSING_INSTRUCTION (node);
	}
	if (_tmp8_) {
		_tmp7_ = TRUE;
	} else {
		_tmp7_ = GXML_IS_DOM_COMMENT (node);
	}
	if (!_tmp7_) {
		const gchar* _tmp12_;
		GError* _tmp13_;
		_tmp12_ = g_type_name (G_TYPE_FROM_INSTANCE ((GObject*) node));
		_tmp13_ = g_error_new (GXML_DOM_ERROR, GXML_DOM_ERROR_HIERARCHY_REQUEST_ERROR, _ ("Invalid attempt to replace invalid node type: %s"), _tmp12_);
		_inner_error0_ = _tmp13_;
		g_propagate_error (error, _inner_error0_);
		return NULL;
	}
	if (GXML_IS_DOM_TEXT (node)) {
		_tmp15_ = GXML_IS_DOM_DOCUMENT (self);
	} else {
		_tmp15_ = FALSE;
	}
	if (_tmp15_) {
		_tmp14_ = TRUE;
	} else {
		gboolean _tmp16_ = FALSE;
		if (GXML_IS_DOM_DOCUMENT_TYPE (node)) {
			_tmp16_ = !GXML_IS_DOM_DOCUMENT (self);
		} else {
			_tmp16_ = FALSE;
		}
		_tmp14_ = _tmp16_;
	}
	if (_tmp14_) {
		GError* _tmp17_;
		_tmp17_ = g_error_new_literal (GXML_DOM_ERROR, GXML_DOM_ERROR_HIERARCHY_REQUEST_ERROR, _ ("Invalid attempt to replace a node on a document or text node"));
		_inner_error0_ = _tmp17_;
		g_propagate_error (error, _inner_error0_);
		return NULL;
	}
	_tmp18_ = gxml_xnode_get_children_nodes (self);
	_tmp19_ = _tmp18_;
	_tmp20_ = _tmp19_;
	_tmp21_ = gee_list_index_of ((GeeList*) _tmp20_, GXML_IS_DOM_NODE (child) ? ((GXmlDomNode*) child) : NULL);
	_g_object_unref0 (_tmp20_);
	i = _tmp21_;
	_tmp22_ = gxml_xnode_get_children_nodes (self);
	_tmp23_ = _tmp22_;
	_tmp24_ = _tmp23_;
	_tmp25_ = gee_list_remove_at ((GeeList*) _tmp24_, i);
	_tmp26_ = (GXmlDomNode*) _tmp25_;
	_g_object_unref0 (_tmp24_);
	rch = _tmp26_;
	_tmp27_ = gxml_xnode_get_children_nodes (self);
	_tmp28_ = _tmp27_;
	_tmp29_ = _tmp28_;
	_tmp30_ = gee_collection_get_size ((GeeCollection*) _tmp29_);
	_tmp31_ = _tmp30_;
	_tmp32_ = i < _tmp31_;
	_g_object_unref0 (_tmp29_);
	if (_tmp32_) {
		GeeBidirList* _tmp33_;
		GeeBidirList* _tmp34_;
		GeeBidirList* _tmp35_;
		_tmp33_ = gxml_xnode_get_children_nodes (self);
		_tmp34_ = _tmp33_;
		_tmp35_ = _tmp34_;
		gee_list_insert ((GeeList*) _tmp35_, i, GXML_IS_DOM_NODE (node) ? ((GXmlDomNode*) node) : NULL);
		_g_object_unref0 (_tmp35_);
	}
	_tmp36_ = gxml_xnode_get_children_nodes (self);
	_tmp37_ = _tmp36_;
	_tmp38_ = _tmp37_;
	_tmp39_ = gee_collection_get_size ((GeeCollection*) _tmp38_);
	_tmp40_ = _tmp39_;
	_tmp41_ = i >= _tmp40_;
	_g_object_unref0 (_tmp38_);
	if (_tmp41_) {
		GXmlDomNodeList* _tmp42_;
		GXmlDomNodeList* _tmp43_;
		GXmlDomNodeList* _tmp44_;
		_tmp42_ = gxml_dom_node_get_child_nodes ((GXmlDomNode*) self);
		_tmp43_ = _tmp42_;
		_tmp44_ = _tmp43_;
		gee_collection_add ((GeeCollection*) _tmp44_, node);
		_g_object_unref0 (_tmp44_);
	}
	_tmp45_ = rch;
	gxml_xnode_release_node (G_TYPE_CHECK_INSTANCE_CAST (_tmp45_, GXML_TYPE_XNODE, GXmlXNode));
	gxml_xnode_take_node (G_TYPE_CHECK_INSTANCE_CAST (child, GXML_TYPE_XNODE, GXmlXNode));
	_tmp46_ = _g_object_ref0 (child);
	result = _tmp46_;
	_g_object_unref0 (rch);
	return result;
}

static GXmlDomNode*
gxml_xnode_real_remove_child (GXmlDomNode* base,
                              GXmlDomNode* child,
                              GError** error)
{
	GXmlXNode * self;
	gint i = 0;
	GeeBidirList* _tmp1_;
	GeeBidirList* _tmp2_;
	GeeBidirList* _tmp3_;
	gint _tmp4_;
	GXmlXNode* n = NULL;
	GeeBidirList* _tmp5_;
	GeeBidirList* _tmp6_;
	GeeBidirList* _tmp7_;
	gpointer _tmp8_;
	GXmlXNode* _tmp9_;
	GXmlDomNode* _tmp10_;
	GError* _inner_error0_ = NULL;
	GXmlDomNode* result;
	self = (GXmlXNode*) base;
	g_return_val_if_fail (child != NULL, NULL);
	if (!gxml_dom_node_contains ((GXmlDomNode*) self, child)) {
		GError* _tmp0_;
		_tmp0_ = g_error_new_literal (GXML_DOM_ERROR, GXML_DOM_ERROR_NOT_FOUND_ERROR, _ ("Can't find child node to remove or child have a different parent"));
		_inner_error0_ = _tmp0_;
		g_propagate_error (error, _inner_error0_);
		return NULL;
	}
	_tmp1_ = gxml_xnode_get_children_nodes (self);
	_tmp2_ = _tmp1_;
	_tmp3_ = _tmp2_;
	_tmp4_ = gee_list_index_of ((GeeList*) _tmp3_, GXML_IS_DOM_NODE (child) ? ((GXmlDomNode*) child) : NULL);
	_g_object_unref0 (_tmp3_);
	i = _tmp4_;
	_tmp5_ = gxml_xnode_get_children_nodes (self);
	_tmp6_ = _tmp5_;
	_tmp7_ = _tmp6_;
	_tmp8_ = gee_list_remove_at ((GeeList*) _tmp7_, i);
	_tmp9_ = G_TYPE_CHECK_INSTANCE_CAST ((GXmlDomNode*) _tmp8_, GXML_TYPE_XNODE, GXmlXNode);
	_g_object_unref0 (_tmp7_);
	n = _tmp9_;
	gxml_xnode_release_node (n);
	gxml_xnode_take_node (G_TYPE_CHECK_INSTANCE_CAST (child, GXML_TYPE_XNODE, GXmlXNode));
	_tmp10_ = _g_object_ref0 (child);
	result = _tmp10_;
	_g_object_unref0 (n);
	return result;
}

static void
gxml_xnode_real_add_event_listener (GXmlDomEventTarget* base,
                                    const gchar* type,
                                    GXmlDomEventListener* callback,
                                    gboolean capture)
{
	GXmlXNode * self;
	self = (GXmlXNode*) base;
	g_return_if_fail (type != NULL);
	return;
}

static void
gxml_xnode_real_remove_event_listener (GXmlDomEventTarget* base,
                                       const gchar* type,
                                       GXmlDomEventListener* callback,
                                       gboolean capture)
{
	GXmlXNode * self;
	self = (GXmlXNode*) base;
	g_return_if_fail (type != NULL);
	return;
}

static gboolean
gxml_xnode_real_dispatch_event (GXmlDomEventTarget* base,
                                GXmlDomEvent* event,
                                GError** error)
{
	GXmlXNode * self;
	gboolean result;
	self = (GXmlXNode*) base;
	g_return_val_if_fail (event != NULL, FALSE);
	result = FALSE;
	return result;
}

GXmlXNode*
gxml_xnode_construct (GType object_type)
{
	GXmlXNode * self = NULL;
	self = (GXmlXNode*) g_object_new (object_type, NULL);
	return self;
}

static GObject *
gxml_xnode_constructor (GType type,
                        guint n_construct_properties,
                        GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	GXmlXNode * self;
	parent_class = G_OBJECT_CLASS (gxml_xnode_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GXML_TYPE_XNODE, GXmlXNode);
	gxml_init_init ();
	return obj;
}

static void
gxml_xnode_class_init (GXmlXNodeClass * klass,
                       gpointer klass_data)
{
	gxml_xnode_parent_class = g_type_class_peek_parent (klass);
	((GXmlXNodeClass *) klass)->set_namespace = (gboolean (*) (GXmlXNode*, const gchar*, const gchar*)) gxml_xnode_real_set_namespace;
	((GXmlXNodeClass *) klass)->to_string = (gchar* (*) (GXmlXNode*)) gxml_xnode_real_to_string;
	GXML_XNODE_CLASS (klass)->get_attrs = (GeeMap* (*) (GXmlXNode*)) gxml_xnode_real_get_attrs;
	GXML_XNODE_CLASS (klass)->get_children_nodes = (GeeBidirList* (*) (GXmlXNode*)) gxml_xnode_real_get_children_nodes;
	GXML_XNODE_CLASS (klass)->get_document = (GXmlDomDocument* (*) (GXmlXNode*)) gxml_xnode_real_get_document;
	GXML_XNODE_CLASS (klass)->get_parent = (GXmlDomNode* (*) (GXmlXNode*)) gxml_xnode_real_get_parent;
	GXML_XNODE_CLASS (klass)->get_type_node = (GXmlNodeType (*) (GXmlXNode*)) gxml_xnode_real_get_type_node;
	GXML_XNODE_CLASS (klass)->get_name = (gchar* (*) (GXmlXNode*)) gxml_xnode_real_get_name;
	GXML_XNODE_CLASS (klass)->get_value = (gchar* (*) (GXmlXNode*)) gxml_xnode_real_get_value;
	GXML_XNODE_CLASS (klass)->set_value = (void (*) (GXmlXNode*, const gchar*)) gxml_xnode_real_set_value;
	G_OBJECT_CLASS (klass)->get_property = _vala_gxml_xnode_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_gxml_xnode_set_property;
	G_OBJECT_CLASS (klass)->constructor = gxml_xnode_constructor;
	G_OBJECT_CLASS (klass)->finalize = gxml_xnode_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), GXML_XNODE_ATTRS_PROPERTY, gxml_xnode_properties[GXML_XNODE_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_XNODE_CHILDREN_NODES_PROPERTY, gxml_xnode_properties[GXML_XNODE_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_XNODE_DOCUMENT_PROPERTY, gxml_xnode_properties[GXML_XNODE_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_XNODE_PARENT_PROPERTY, gxml_xnode_properties[GXML_XNODE_PARENT_PROPERTY] = g_param_spec_object ("parent", "parent", "parent", GXML_TYPE_DOM_NODE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GXML_XNODE_TYPE_NODE_PROPERTY, gxml_xnode_properties[GXML_XNODE_TYPE_NODE_PROPERTY] = g_param_spec_enum ("type-node", "type-node", "type-node", GXML_TYPE_NODE_TYPE, 0, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GXML_XNODE_NAME_PROPERTY, gxml_xnode_properties[GXML_XNODE_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_XNODE_VALUE_PROPERTY, gxml_xnode_properties[GXML_XNODE_VALUE_PROPERTY] = g_param_spec_string ("value", "value", "value", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GXML_XNODE_NODE_TYPE_PROPERTY, gxml_xnode_properties[GXML_XNODE_NODE_TYPE_PROPERTY] = g_param_spec_enum ("node-type", "node-type", "node-type", GXML_DOM_NODE_TYPE_NODE_TYPE, 0, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GXML_XNODE_NODE_NAME_PROPERTY, gxml_xnode_properties[GXML_XNODE_NODE_NAME_PROPERTY] = g_param_spec_string ("node-name", "node-name", "node-name", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GXML_XNODE_BASE_URI_PROPERTY, gxml_xnode_properties[GXML_XNODE_BASE_URI_PROPERTY] = g_param_spec_string ("base-uri", "base-uri", "base-uri", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GXML_XNODE_OWNER_DOCUMENT_PROPERTY, gxml_xnode_properties[GXML_XNODE_OWNER_DOCUMENT_PROPERTY] = g_param_spec_object ("owner-document", "owner-document", "owner-document", GXML_TYPE_DOM_DOCUMENT, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GXML_XNODE_PARENT_NODE_PROPERTY, gxml_xnode_properties[GXML_XNODE_PARENT_NODE_PROPERTY] = g_param_spec_object ("parent-node", "parent-node", "parent-node", GXML_TYPE_DOM_NODE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GXML_XNODE_PARENT_ELEMENT_PROPERTY, gxml_xnode_properties[GXML_XNODE_PARENT_ELEMENT_PROPERTY] = g_param_spec_object ("parent-element", "parent-element", "parent-element", GXML_TYPE_DOM_ELEMENT, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GXML_XNODE_CHILD_NODES_PROPERTY, gxml_xnode_properties[GXML_XNODE_CHILD_NODES_PROPERTY] = g_param_spec_object ("child-nodes", "child-nodes", "child-nodes", GXML_TYPE_DOM_NODE_LIST, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GXML_XNODE_FIRST_CHILD_PROPERTY, gxml_xnode_properties[GXML_XNODE_FIRST_CHILD_PROPERTY] = g_param_spec_object ("first-child", "first-child", "first-child", GXML_TYPE_DOM_NODE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GXML_XNODE_LAST_CHILD_PROPERTY, gxml_xnode_properties[GXML_XNODE_LAST_CHILD_PROPERTY] = g_param_spec_object ("last-child", "last-child", "last-child", GXML_TYPE_DOM_NODE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GXML_XNODE_PREVIOUS_SIBLING_PROPERTY, gxml_xnode_properties[GXML_XNODE_PREVIOUS_SIBLING_PROPERTY] = g_param_spec_object ("previous-sibling", "previous-sibling", "previous-sibling", GXML_TYPE_DOM_NODE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GXML_XNODE_NEXT_SIBLING_PROPERTY, gxml_xnode_properties[GXML_XNODE_NEXT_SIBLING_PROPERTY] = g_param_spec_object ("next-sibling", "next-sibling", "next-sibling", GXML_TYPE_DOM_NODE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GXML_XNODE_NODE_VALUE_PROPERTY, gxml_xnode_properties[GXML_XNODE_NODE_VALUE_PROPERTY] = g_param_spec_string ("node-value", "node-value", "node-value", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GXML_XNODE_TEXT_CONTENT_PROPERTY, gxml_xnode_properties[GXML_XNODE_TEXT_CONTENT_PROPERTY] = g_param_spec_string ("text-content", "text-content", "text-content", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
}

static void
gxml_xnode_gxml_dom_event_target_interface_init (GXmlDomEventTargetIface * iface,
                                                 gpointer iface_data)
{
	gxml_xnode_gxml_dom_event_target_parent_iface = g_type_interface_peek_parent (iface);
	iface->add_event_listener = (void (*) (GXmlDomEventTarget*, const gchar*, GXmlDomEventListener*, gboolean)) gxml_xnode_real_add_event_listener;
	iface->remove_event_listener = (void (*) (GXmlDomEventTarget*, const gchar*, GXmlDomEventListener*, gboolean)) gxml_xnode_real_remove_event_listener;
	iface->dispatch_event = (gboolean (*) (GXmlDomEventTarget*, GXmlDomEvent*, GError**)) gxml_xnode_real_dispatch_event;
}

static void
gxml_xnode_gxml_dom_node_interface_init (GXmlDomNodeIface * iface,
                                         gpointer iface_data)
{
	gxml_xnode_gxml_dom_node_parent_iface = g_type_interface_peek_parent (iface);
	iface->has_child_nodes = (gboolean (*) (GXmlDomNode*)) gxml_xnode_real_has_child_nodes;
	iface->normalize = (void (*) (GXmlDomNode*)) gxml_xnode_real_normalize;
	iface->is_equal_node = (gboolean (*) (GXmlDomNode*, GXmlDomNode*)) gxml_xnode_real_is_equal_node;
	iface->compare_document_position = (GXmlDomNodeDocumentPosition (*) (GXmlDomNode*, GXmlDomNode*)) gxml_xnode_real_compare_document_position;
	iface->contains = (gboolean (*) (GXmlDomNode*, GXmlDomNode*)) gxml_xnode_real_contains;
	iface->lookup_prefix = (gchar* (*) (GXmlDomNode*, const gchar*)) gxml_xnode_real_lookup_prefix;
	iface->lookup_namespace_uri = (gchar* (*) (GXmlDomNode*, const gchar*)) gxml_xnode_real_lookup_namespace_uri;
	iface->is_default_namespace = (gboolean (*) (GXmlDomNode*, const gchar*)) gxml_xnode_real_is_default_namespace;
	iface->insert_before = (GXmlDomNode* (*) (GXmlDomNode*, GXmlDomNode*, GXmlDomNode*, GError**)) gxml_xnode_real_insert_before;
	iface->append_child = (GXmlDomNode* (*) (GXmlDomNode*, GXmlDomNode*, GError**)) gxml_xnode_real_append_child;
	iface->replace_child = (GXmlDomNode* (*) (GXmlDomNode*, GXmlDomNode*, GXmlDomNode*, GError**)) gxml_xnode_real_replace_child;
	iface->remove_child = (GXmlDomNode* (*) (GXmlDomNode*, GXmlDomNode*, GError**)) gxml_xnode_real_remove_child;
	iface->get_node_type = gxml_xnode_real_get_node_type;
	iface->get_node_name = gxml_xnode_real_get_node_name;
	iface->get_base_uri = gxml_xnode_real_get_base_uri;
	iface->get_owner_document = gxml_xnode_real_get_owner_document;
	iface->set_owner_document = gxml_xnode_real_set_owner_document;
	iface->get_parent_node = gxml_xnode_real_get_parent_node;
	iface->get_parent_element = gxml_xnode_real_get_parent_element;
	iface->get_child_nodes = gxml_xnode_real_get_child_nodes;
	iface->get_first_child = gxml_xnode_real_get_first_child;
	iface->get_last_child = gxml_xnode_real_get_last_child;
	iface->get_previous_sibling = gxml_xnode_real_get_previous_sibling;
	iface->get_next_sibling = gxml_xnode_real_get_next_sibling;
	iface->get_node_value = gxml_xnode_real_get_node_value;
	iface->set_node_value = gxml_xnode_real_set_node_value;
	iface->get_text_content = gxml_xnode_real_get_text_content;
	iface->set_text_content = gxml_xnode_real_set_text_content;
}

static void
gxml_xnode_instance_init (GXmlXNode * self,
                          gpointer klass)
{
	self->owned_node = FALSE;
	self->_base_uri = NULL;
}

static void
gxml_xnode_finalize (GObject * obj)
{
	GXmlXNode * self;
	gboolean _tmp0_ = FALSE;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GXML_TYPE_XNODE, GXmlXNode);
	if (self->owned_node) {
		xmlNode* _tmp1_;
		_tmp1_ = self->_node;
		_tmp0_ = _tmp1_ != NULL;
	} else {
		_tmp0_ = FALSE;
	}
	if (_tmp0_) {
		xmlNode* _tmp2_;
		_tmp2_ = self->_node;
		_xmlFreeNode0 (_tmp2_);
		self->_node = NULL;
	}
	_g_object_unref0 (self->_doc);
	_g_free0 (self->_base_uri);
	G_OBJECT_CLASS (gxml_xnode_parent_class)->finalize (obj);
}

/**
 * DOM4 Base interface providing basic functionalities to all libxml2 DOM4 implementations.
 */
static GType
gxml_xnode_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (GXmlXNodeClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) gxml_xnode_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GXmlXNode), 0, (GInstanceInitFunc) gxml_xnode_instance_init, NULL };
	static const GInterfaceInfo gxml_dom_event_target_info = { (GInterfaceInitFunc) gxml_xnode_gxml_dom_event_target_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
	static const GInterfaceInfo gxml_dom_node_info = { (GInterfaceInitFunc) gxml_xnode_gxml_dom_node_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
	GType gxml_xnode_type_id;
	gxml_xnode_type_id = g_type_register_static (G_TYPE_OBJECT, "GXmlXNode", &g_define_type_info, G_TYPE_FLAG_ABSTRACT);
	g_type_add_interface_static (gxml_xnode_type_id, GXML_TYPE_DOM_EVENT_TARGET, &gxml_dom_event_target_info);
	g_type_add_interface_static (gxml_xnode_type_id, GXML_TYPE_DOM_NODE, &gxml_dom_node_info);
	return gxml_xnode_type_id;
}

GType
gxml_xnode_get_type (void)
{
	static volatile gsize gxml_xnode_type_id__once = 0;
	if (g_once_init_enter (&gxml_xnode_type_id__once)) {
		GType gxml_xnode_type_id;
		gxml_xnode_type_id = gxml_xnode_get_type_once ();
		g_once_init_leave (&gxml_xnode_type_id__once, gxml_xnode_type_id);
	}
	return gxml_xnode_type_id__once;
}

static void
_vala_gxml_xnode_get_property (GObject * object,
                               guint property_id,
                               GValue * value,
                               GParamSpec * pspec)
{
	GXmlXNode * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, GXML_TYPE_XNODE, GXmlXNode);
	switch (property_id) {
		case GXML_XNODE_ATTRS_PROPERTY:
		g_value_take_object (value, gxml_xnode_get_attrs (self));
		break;
		case GXML_XNODE_CHILDREN_NODES_PROPERTY:
		g_value_take_object (value, gxml_xnode_get_children_nodes (self));
		break;
		case GXML_XNODE_DOCUMENT_PROPERTY:
		g_value_set_object (value, gxml_xnode_get_document (self));
		break;
		case GXML_XNODE_PARENT_PROPERTY:
		g_value_take_object (value, gxml_xnode_get_parent (self));
		break;
		case GXML_XNODE_TYPE_NODE_PROPERTY:
		g_value_set_enum (value, gxml_xnode_get_type_node (self));
		break;
		case GXML_XNODE_NAME_PROPERTY:
		g_value_take_string (value, gxml_xnode_get_name (self));
		break;
		case GXML_XNODE_VALUE_PROPERTY:
		g_value_take_string (value, gxml_xnode_get_value (self));
		break;
		case GXML_XNODE_NODE_TYPE_PROPERTY:
		g_value_set_enum (value, gxml_dom_node_get_node_type ((GXmlDomNode*) self));
		break;
		case GXML_XNODE_NODE_NAME_PROPERTY:
		g_value_take_string (value, gxml_dom_node_get_node_name ((GXmlDomNode*) self));
		break;
		case GXML_XNODE_BASE_URI_PROPERTY:
		g_value_set_string (value, gxml_dom_node_get_base_uri ((GXmlDomNode*) self));
		break;
		case GXML_XNODE_OWNER_DOCUMENT_PROPERTY:
		g_value_set_object (value, gxml_dom_node_get_owner_document ((GXmlDomNode*) self));
		break;
		case GXML_XNODE_PARENT_NODE_PROPERTY:
		g_value_take_object (value, gxml_dom_node_get_parent_node ((GXmlDomNode*) self));
		break;
		case GXML_XNODE_PARENT_ELEMENT_PROPERTY:
		g_value_take_object (value, gxml_dom_node_get_parent_element ((GXmlDomNode*) self));
		break;
		case GXML_XNODE_CHILD_NODES_PROPERTY:
		g_value_take_object (value, gxml_dom_node_get_child_nodes ((GXmlDomNode*) self));
		break;
		case GXML_XNODE_FIRST_CHILD_PROPERTY:
		g_value_take_object (value, gxml_dom_node_get_first_child ((GXmlDomNode*) self));
		break;
		case GXML_XNODE_LAST_CHILD_PROPERTY:
		g_value_take_object (value, gxml_dom_node_get_last_child ((GXmlDomNode*) self));
		break;
		case GXML_XNODE_PREVIOUS_SIBLING_PROPERTY:
		g_value_take_object (value, gxml_dom_node_get_previous_sibling ((GXmlDomNode*) self));
		break;
		case GXML_XNODE_NEXT_SIBLING_PROPERTY:
		g_value_take_object (value, gxml_dom_node_get_next_sibling ((GXmlDomNode*) self));
		break;
		case GXML_XNODE_NODE_VALUE_PROPERTY:
		g_value_take_string (value, gxml_dom_node_get_node_value ((GXmlDomNode*) self));
		break;
		case GXML_XNODE_TEXT_CONTENT_PROPERTY:
		g_value_take_string (value, gxml_dom_node_get_text_content ((GXmlDomNode*) self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_gxml_xnode_set_property (GObject * object,
                               guint property_id,
                               const GValue * value,
                               GParamSpec * pspec)
{
	GXmlXNode * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, GXML_TYPE_XNODE, GXmlXNode);
	switch (property_id) {
		case GXML_XNODE_VALUE_PROPERTY:
		gxml_xnode_set_value (self, g_value_get_string (value));
		break;
		case GXML_XNODE_OWNER_DOCUMENT_PROPERTY:
		gxml_dom_node_set_owner_document ((GXmlDomNode*) self, g_value_get_object (value));
		break;
		case GXML_XNODE_NODE_VALUE_PROPERTY:
		gxml_dom_node_set_node_value ((GXmlDomNode*) self, g_value_get_string (value));
		break;
		case GXML_XNODE_TEXT_CONTENT_PROPERTY:
		gxml_dom_node_set_text_content ((GXmlDomNode*) self, g_value_get_string (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

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;
}

