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

/* GElement.vala
 *
 * Copyright (C) 2016  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 <glib.h>
#include <glib-object.h>
#include <stdlib.h>
#include <string.h>
#include <gee.h>
#include <gio/gio.h>
#include <libxml/tree.h>
#include <libxml/parser.h>


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

typedef struct _GXmlNode GXmlNode;
typedef struct _GXmlNodeIface GXmlNodeIface;

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

typedef struct _GXmlElementList GXmlElementList;
typedef struct _GXmlElementListClass GXmlElementListClass;

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

typedef struct _GXmlNamespace GXmlNamespace;
typedef struct _GXmlNamespaceIface GXmlNamespaceIface;

#define GXML_TYPE_NODE_TYPE (gxml_node_type_get_type ())

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

typedef struct _GXmlDocument GXmlDocument;
typedef struct _GXmlDocumentIface GXmlDocumentIface;

#define GXML_TYPE_GNODE (gxml_gnode_get_type ())
#define GXML_GNODE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GXML_TYPE_GNODE, GXmlGNode))
#define GXML_GNODE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GXML_TYPE_GNODE, GXmlGNodeClass))
#define GXML_IS_GNODE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GXML_TYPE_GNODE))
#define GXML_IS_GNODE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GXML_TYPE_GNODE))
#define GXML_GNODE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GXML_TYPE_GNODE, GXmlGNodeClass))

typedef struct _GXmlGNode GXmlGNode;
typedef struct _GXmlGNodeClass GXmlGNodeClass;
typedef struct _GXmlGNodePrivate GXmlGNodePrivate;

#define GXML_TYPE_GDOCUMENT (gxml_gdocument_get_type ())
#define GXML_GDOCUMENT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GXML_TYPE_GDOCUMENT, GXmlGDocument))
#define GXML_GDOCUMENT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GXML_TYPE_GDOCUMENT, GXmlGDocumentClass))
#define GXML_IS_GDOCUMENT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GXML_TYPE_GDOCUMENT))
#define GXML_IS_GDOCUMENT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GXML_TYPE_GDOCUMENT))
#define GXML_GDOCUMENT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GXML_TYPE_GDOCUMENT, GXmlGDocumentClass))

typedef struct _GXmlGDocument GXmlGDocument;
typedef struct _GXmlGDocumentClass GXmlGDocumentClass;

#define GXML_TYPE_ELEMENT (gxml_element_get_type ())
#define GXML_ELEMENT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GXML_TYPE_ELEMENT, GXmlElement))
#define GXML_IS_ELEMENT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GXML_TYPE_ELEMENT))
#define GXML_ELEMENT_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), GXML_TYPE_ELEMENT, GXmlElementIface))

typedef struct _GXmlElement GXmlElement;
typedef struct _GXmlElementIface GXmlElementIface;

#define GXML_TYPE_GELEMENT (gxml_gelement_get_type ())
#define GXML_GELEMENT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GXML_TYPE_GELEMENT, GXmlGElement))
#define GXML_GELEMENT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GXML_TYPE_GELEMENT, GXmlGElementClass))
#define GXML_IS_GELEMENT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GXML_TYPE_GELEMENT))
#define GXML_IS_GELEMENT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GXML_TYPE_GELEMENT))
#define GXML_GELEMENT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GXML_TYPE_GELEMENT, GXmlGElementClass))

typedef struct _GXmlGElement GXmlGElement;
typedef struct _GXmlGElementClass GXmlGElementClass;
typedef struct _GXmlGElementPrivate GXmlGElementPrivate;
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))

#define GXML_TYPE_GATTRIBUTE (gxml_gattribute_get_type ())
#define GXML_GATTRIBUTE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GXML_TYPE_GATTRIBUTE, GXmlGAttribute))
#define GXML_GATTRIBUTE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GXML_TYPE_GATTRIBUTE, GXmlGAttributeClass))
#define GXML_IS_GATTRIBUTE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GXML_TYPE_GATTRIBUTE))
#define GXML_IS_GATTRIBUTE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GXML_TYPE_GATTRIBUTE))
#define GXML_GATTRIBUTE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GXML_TYPE_GATTRIBUTE, GXmlGAttributeClass))

typedef struct _GXmlGAttribute GXmlGAttribute;
typedef struct _GXmlGAttributeClass GXmlGAttributeClass;
#define _xmlBufferFree0(var) ((var == NULL) ? NULL : (var = (xmlBufferFree (var), NULL)))

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

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

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

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

struct _GXmlGNode {
	GObject parent_instance;
	GXmlGNodePrivate * priv;
	GXmlGDocument* _doc;
	xmlNode* _node;
};

struct _GXmlGNodeClass {
	GObjectClass parent_class;
	gboolean (*set_namespace) (GXmlGNode* self, const gchar* uri, const gchar* prefix);
	gchar* (*to_string) (GXmlGNode* self);
	GeeMap* (*get_attrs) (GXmlGNode* self);
	GeeBidirList* (*get_children) (GXmlGNode* self);
	GeeList* (*get_namespaces) (GXmlGNode* self);
	GXmlDocument* (*get_document) (GXmlGNode* self);
	GXmlNode* (*get_parent) (GXmlGNode* self);
	GXmlNodeType (*get_type_node) (GXmlGNode* self);
	gchar* (*get_name) (GXmlGNode* self);
	gchar* (*get_value) (GXmlGNode* self);
	void (*set_value) (GXmlGNode* self, const gchar* value);
};

struct _GXmlElementIface {
	GTypeInterface parent_iface;
	void (*normalize) (GXmlElement* self);
	void (*set_attr) (GXmlElement* self, const gchar* name, const gchar* value);
	GXmlNode* (*get_attr) (GXmlElement* self, const gchar* name);
	void (*remove_attr) (GXmlElement* self, const gchar* name);
	void (*set_ns_attr) (GXmlElement* self, GXmlNamespace* ns, const gchar* name, const gchar* value);
	GXmlNode* (*get_ns_attr) (GXmlElement* self, const gchar* name, const gchar* uri);
	gchar* (*get_tag_name) (GXmlElement* self);
	gchar* (*get_content) (GXmlElement* self);
	void (*set_content) (GXmlElement* self, const gchar* value);
};

struct _GXmlGElement {
	GXmlGNode parent_instance;
	GXmlGElementPrivate * priv;
};

struct _GXmlGElementClass {
	GXmlGNodeClass parent_class;
};


static gpointer gxml_gelement_parent_class = NULL;
static GXmlElementIface* gxml_gelement_gxml_element_parent_iface = NULL;

GType gxml_element_list_get_type (void) G_GNUC_CONST;
GType gxml_namespace_get_type (void) G_GNUC_CONST;
GType gxml_node_type_get_type (void) G_GNUC_CONST;
GType gxml_document_get_type (void) G_GNUC_CONST;
GType gxml_node_get_type (void) G_GNUC_CONST;
GType gxml_gnode_get_type (void) G_GNUC_CONST;
GType gxml_gdocument_get_type (void) G_GNUC_CONST;
GType gxml_element_get_type (void) G_GNUC_CONST;
GType gxml_gelement_get_type (void) G_GNUC_CONST;
enum  {
	GXML_GELEMENT_DUMMY_PROPERTY,
	GXML_GELEMENT_VALUE,
	GXML_GELEMENT_CONTENT,
	GXML_GELEMENT_TAG_NAME
};
GXmlGElement* gxml_gelement_new (GXmlGDocument* doc, xmlNode* node);
GXmlGElement* gxml_gelement_construct (GType object_type, GXmlGDocument* doc, xmlNode* node);
GXmlGNode* gxml_gnode_construct (GType object_type);
static void gxml_gelement_real_set_attr (GXmlElement* base, const gchar* aname, const gchar* avalue);
static GXmlNode* gxml_gelement_real_get_attr (GXmlElement* base, const gchar* name);
GXmlGAttribute* gxml_gattribute_new (GXmlGDocument* doc, xmlAttr* node);
GXmlGAttribute* gxml_gattribute_construct (GType object_type, GXmlGDocument* doc, xmlAttr* node);
GType gxml_gattribute_get_type (void) G_GNUC_CONST;
static void gxml_gelement_real_set_ns_attr (GXmlElement* base, GXmlNamespace* ns, const gchar* name, const gchar* uri);
gchar* gxml_namespace_get_prefix (GXmlNamespace* self);
static GXmlNode* gxml_gelement_real_get_ns_attr (GXmlElement* base, const gchar* name, const gchar* uri);
static void gxml_gelement_real_normalize (GXmlElement* base);
static void gxml_gelement_real_remove_attr (GXmlElement* base, const gchar* name);
static gchar* gxml_gelement_real_to_string (GXmlGNode* base);
gchar* gxml_element_get_content (GXmlElement* self);
void gxml_element_set_content (GXmlElement* self, const gchar* value);
gchar* gxml_gnode_get_value (GXmlGNode* self);
gchar* gxml_element_get_tag_name (GXmlElement* self);
static void _vala_gxml_gelement_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec);
void gxml_gnode_set_value (GXmlGNode* self, const gchar* value);
static void _vala_gxml_gelement_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec);
static void _vala_array_destroy (gpointer array, gint array_length, GDestroyNotify destroy_func);
static void _vala_array_free (gpointer array, gint array_length, GDestroyNotify destroy_func);
static gint _vala_array_length (gpointer array);


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


GXmlGElement* gxml_gelement_construct (GType object_type, GXmlGDocument* doc, xmlNode* node) {
	GXmlGElement * self = NULL;
	xmlNode* _tmp0_ = NULL;
	GXmlGDocument* _tmp1_ = NULL;
	GXmlGDocument* _tmp2_ = NULL;
	g_return_val_if_fail (doc != NULL, NULL);
	self = (GXmlGElement*) gxml_gnode_construct (object_type);
	_tmp0_ = node;
	((GXmlGNode*) self)->_node = _tmp0_;
	_tmp1_ = doc;
	_tmp2_ = _g_object_ref0 (_tmp1_);
	_g_object_unref0 (((GXmlGNode*) self)->_doc);
	((GXmlGNode*) self)->_doc = _tmp2_;
	return self;
}


GXmlGElement* gxml_gelement_new (GXmlGDocument* doc, xmlNode* node) {
	return gxml_gelement_construct (GXML_TYPE_GELEMENT, doc, node);
}


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


static void gxml_gelement_real_set_attr (GXmlElement* base, const gchar* aname, const gchar* avalue) {
	GXmlGElement * self;
	xmlNode* _tmp0_ = NULL;
	const gchar* _tmp1_ = NULL;
	gboolean _tmp2_ = FALSE;
	xmlNode* _tmp3_ = NULL;
	const gchar* _tmp4_ = NULL;
	const gchar* _tmp5_ = NULL;
	self = (GXmlGElement*) base;
	g_return_if_fail (aname != NULL);
	g_return_if_fail (avalue != NULL);
	_tmp0_ = ((GXmlGNode*) self)->_node;
	if (_tmp0_ == NULL) {
		return;
	}
	_tmp1_ = aname;
	_tmp2_ = string_contains (_tmp1_, ":");
	if (_tmp2_) {
		return;
	}
	_tmp3_ = ((GXmlGNode*) self)->_node;
	_tmp4_ = aname;
	_tmp5_ = avalue;
	xmlSetProp (_tmp3_, (xmlChar*) _tmp4_, (xmlChar*) _tmp5_);
}


static GXmlNode* gxml_gelement_real_get_attr (GXmlElement* base, const gchar* name) {
	GXmlGElement * self;
	GXmlNode* result = NULL;
	xmlNode* _tmp0_ = NULL;
	gchar* prefix = NULL;
	gchar* _tmp1_ = NULL;
	gchar* n = NULL;
	const gchar* _tmp2_ = NULL;
	gchar* _tmp3_ = NULL;
	const gchar* _tmp4_ = NULL;
	gboolean _tmp5_ = FALSE;
	xmlAttr* ps = NULL;
	xmlNode* _tmp16_ = NULL;
	xmlAttr* _tmp17_ = NULL;
	self = (GXmlGElement*) base;
	g_return_val_if_fail (name != NULL, NULL);
	_tmp0_ = ((GXmlGNode*) self)->_node;
	if (_tmp0_ == NULL) {
		result = NULL;
		return result;
	}
	_tmp1_ = g_strdup ("");
	prefix = _tmp1_;
	_tmp2_ = name;
	_tmp3_ = g_strdup (_tmp2_);
	n = _tmp3_;
	_tmp4_ = name;
	_tmp5_ = string_contains (_tmp4_, ":");
	if (_tmp5_) {
		gchar** pp = NULL;
		const gchar* _tmp6_ = NULL;
		gchar** _tmp7_ = NULL;
		gchar** _tmp8_ = NULL;
		gint pp_length1 = 0;
		gint _pp_size_ = 0;
		gchar** _tmp9_ = NULL;
		gint _tmp9__length1 = 0;
		gchar** _tmp10_ = NULL;
		gint _tmp10__length1 = 0;
		const gchar* _tmp11_ = NULL;
		gchar* _tmp12_ = NULL;
		gchar** _tmp13_ = NULL;
		gint _tmp13__length1 = 0;
		const gchar* _tmp14_ = NULL;
		gchar* _tmp15_ = NULL;
		_tmp6_ = name;
		_tmp8_ = _tmp7_ = g_strsplit (_tmp6_, ":", 0);
		pp = _tmp8_;
		pp_length1 = _vala_array_length (_tmp7_);
		_pp_size_ = pp_length1;
		_tmp9_ = pp;
		_tmp9__length1 = pp_length1;
		if (_tmp9__length1 != 2) {
			result = NULL;
			pp = (_vala_array_free (pp, pp_length1, (GDestroyNotify) g_free), NULL);
			_g_free0 (n);
			_g_free0 (prefix);
			return result;
		}
		_tmp10_ = pp;
		_tmp10__length1 = pp_length1;
		_tmp11_ = _tmp10_[0];
		_tmp12_ = g_strdup (_tmp11_);
		_g_free0 (prefix);
		prefix = _tmp12_;
		_tmp13_ = pp;
		_tmp13__length1 = pp_length1;
		_tmp14_ = _tmp13_[1];
		_tmp15_ = g_strdup (_tmp14_);
		_g_free0 (n);
		n = _tmp15_;
		pp = (_vala_array_free (pp, pp_length1, (GDestroyNotify) g_free), NULL);
	}
	_tmp16_ = ((GXmlGNode*) self)->_node;
	_tmp17_ = _tmp16_->properties;
	ps = _tmp17_;
	while (TRUE) {
		xmlAttr* _tmp18_ = NULL;
		xmlAttr* _tmp19_ = NULL;
		const gchar* _tmp20_ = NULL;
		const gchar* _tmp21_ = NULL;
		xmlAttr* _tmp38_ = NULL;
		xmlAttr* _tmp39_ = NULL;
		_tmp18_ = ps;
		if (!(_tmp18_ != NULL)) {
			break;
		}
		_tmp19_ = ps;
		_tmp20_ = _tmp19_->name;
		_tmp21_ = n;
		if (g_strcmp0 (_tmp20_, _tmp21_) == 0) {
			gboolean _tmp22_ = FALSE;
			xmlAttr* _tmp23_ = NULL;
			xmlNs* _tmp24_ = NULL;
			xmlAttr* _tmp29_ = NULL;
			xmlNs* _tmp30_ = NULL;
			xmlAttr* _tmp31_ = NULL;
			xmlNs* _tmp32_ = NULL;
			const gchar* _tmp33_ = NULL;
			const gchar* _tmp34_ = NULL;
			_tmp23_ = ps;
			_tmp24_ = _tmp23_->ns;
			if (_tmp24_ == NULL) {
				const gchar* _tmp25_ = NULL;
				_tmp25_ = prefix;
				_tmp22_ = g_strcmp0 (_tmp25_, "") == 0;
			} else {
				_tmp22_ = FALSE;
			}
			if (_tmp22_) {
				GXmlGDocument* _tmp26_ = NULL;
				xmlAttr* _tmp27_ = NULL;
				GXmlGAttribute* _tmp28_ = NULL;
				_tmp26_ = ((GXmlGNode*) self)->_doc;
				_tmp27_ = ps;
				_tmp28_ = gxml_gattribute_new (_tmp26_, _tmp27_);
				result = (GXmlNode*) _tmp28_;
				_g_free0 (n);
				_g_free0 (prefix);
				return result;
			}
			_tmp29_ = ps;
			_tmp30_ = _tmp29_->ns;
			if (_tmp30_ == NULL) {
				continue;
			}
			_tmp31_ = ps;
			_tmp32_ = _tmp31_->ns;
			_tmp33_ = _tmp32_->prefix;
			_tmp34_ = prefix;
			if (g_strcmp0 (_tmp33_, _tmp34_) == 0) {
				GXmlGDocument* _tmp35_ = NULL;
				xmlAttr* _tmp36_ = NULL;
				GXmlGAttribute* _tmp37_ = NULL;
				_tmp35_ = ((GXmlGNode*) self)->_doc;
				_tmp36_ = ps;
				_tmp37_ = gxml_gattribute_new (_tmp35_, _tmp36_);
				result = (GXmlNode*) _tmp37_;
				_g_free0 (n);
				_g_free0 (prefix);
				return result;
			}
		}
		_tmp38_ = ps;
		_tmp39_ = _tmp38_->next;
		ps = _tmp39_;
	}
	result = NULL;
	_g_free0 (n);
	_g_free0 (prefix);
	return result;
}


static void gxml_gelement_real_set_ns_attr (GXmlElement* base, GXmlNamespace* ns, const gchar* name, const gchar* uri) {
	GXmlGElement * self;
	xmlNode* _tmp0_ = NULL;
	xmlNs* ins = NULL;
	xmlNode* _tmp1_ = NULL;
	xmlDoc* _tmp2_ = NULL;
	xmlNode* _tmp3_ = NULL;
	GXmlNamespace* _tmp4_ = NULL;
	gchar* _tmp5_ = NULL;
	gchar* _tmp6_ = NULL;
	gchar* _tmp7_ = NULL;
	xmlNs* _tmp8_ = NULL;
	xmlNs* _tmp9_ = NULL;
	xmlNs* _tmp10_ = NULL;
	self = (GXmlGElement*) base;
	g_return_if_fail (ns != NULL);
	g_return_if_fail (name != NULL);
	g_return_if_fail (uri != NULL);
	_tmp0_ = ((GXmlGNode*) self)->_node;
	if (_tmp0_ == NULL) {
		return;
	}
	_tmp1_ = ((GXmlGNode*) self)->_node;
	_tmp2_ = _tmp1_->doc;
	_tmp3_ = ((GXmlGNode*) self)->_node;
	_tmp4_ = ns;
	_tmp5_ = gxml_namespace_get_prefix (_tmp4_);
	_tmp6_ = _tmp5_;
	_tmp7_ = _tmp6_;
	_tmp8_ = xmlSearchNs (_tmp2_, _tmp3_, _tmp7_);
	_tmp9_ = _tmp8_;
	_g_free0 (_tmp7_);
	ins = _tmp9_;
	_tmp10_ = ins;
	if (_tmp10_ != NULL) {
		xmlNode* _tmp11_ = NULL;
		xmlNs* _tmp12_ = NULL;
		const gchar* _tmp13_ = NULL;
		const gchar* _tmp14_ = NULL;
		_tmp11_ = ((GXmlGNode*) self)->_node;
		_tmp12_ = ins;
		_tmp13_ = name;
		_tmp14_ = uri;
		xmlSetNsProp (_tmp11_, _tmp12_, (xmlChar*) _tmp13_, (xmlChar*) _tmp14_);
		return;
	}
}


static GXmlNode* gxml_gelement_real_get_ns_attr (GXmlElement* base, const gchar* name, const gchar* uri) {
	GXmlGElement * self;
	GXmlNode* result = NULL;
	xmlNode* _tmp0_ = NULL;
	xmlAttr* a = NULL;
	xmlNode* _tmp1_ = NULL;
	const gchar* _tmp2_ = NULL;
	const gchar* _tmp3_ = NULL;
	xmlAttr* _tmp4_ = NULL;
	xmlAttr* _tmp5_ = NULL;
	GXmlGDocument* _tmp6_ = NULL;
	xmlAttr* _tmp7_ = NULL;
	GXmlGAttribute* _tmp8_ = NULL;
	self = (GXmlGElement*) base;
	g_return_val_if_fail (name != NULL, NULL);
	g_return_val_if_fail (uri != NULL, NULL);
	_tmp0_ = ((GXmlGNode*) self)->_node;
	if (_tmp0_ == NULL) {
		result = NULL;
		return result;
	}
	_tmp1_ = ((GXmlGNode*) self)->_node;
	_tmp2_ = name;
	_tmp3_ = uri;
	_tmp4_ = xmlHasNsProp (_tmp1_, (xmlChar*) _tmp2_, (xmlChar*) _tmp3_);
	a = _tmp4_;
	_tmp5_ = a;
	if (_tmp5_ == NULL) {
		result = NULL;
		return result;
	}
	_tmp6_ = ((GXmlGNode*) self)->_doc;
	_tmp7_ = a;
	_tmp8_ = gxml_gattribute_new (_tmp6_, _tmp7_);
	result = (GXmlNode*) _tmp8_;
	return result;
}


static void gxml_gelement_real_normalize (GXmlElement* base) {
	GXmlGElement * self;
	self = (GXmlGElement*) base;
}


static void gxml_gelement_real_remove_attr (GXmlElement* base, const gchar* name) {
	GXmlGElement * self;
	xmlNode* _tmp0_ = NULL;
	xmlAttr* a = NULL;
	xmlNode* _tmp1_ = NULL;
	const gchar* _tmp2_ = NULL;
	xmlAttr* _tmp3_ = NULL;
	xmlAttr* _tmp4_ = NULL;
	xmlAttr* _tmp5_ = NULL;
	self = (GXmlGElement*) base;
	g_return_if_fail (name != NULL);
	_tmp0_ = ((GXmlGNode*) self)->_node;
	if (_tmp0_ == NULL) {
		return;
	}
	_tmp1_ = ((GXmlGNode*) self)->_node;
	_tmp2_ = name;
	_tmp3_ = xmlHasProp (_tmp1_, (xmlChar*) _tmp2_);
	a = _tmp3_;
	_tmp4_ = a;
	if (_tmp4_ == NULL) {
		return;
	}
	_tmp5_ = a;
	xmlRemoveProp (_tmp5_);
}


static gchar* gxml_gelement_real_to_string (GXmlGNode* base) {
	GXmlGElement * self;
	gchar* result = NULL;
	xmlBuffer* buf = NULL;
	xmlBuffer* _tmp0_ = NULL;
	xmlNode* _tmp1_ = NULL;
	xmlDoc* _tmp2_ = NULL;
	xmlNode* _tmp3_ = NULL;
	const gchar* _tmp4_ = NULL;
	gchar* _tmp5_ = NULL;
	self = (GXmlGElement*) base;
	_tmp0_ = xmlBufferCreate ();
	buf = _tmp0_;
	_tmp1_ = ((GXmlGNode*) self)->_node;
	_tmp2_ = _tmp1_->doc;
	_tmp3_ = ((GXmlGNode*) self)->_node;
	xmlNodeDump (buf, _tmp2_, _tmp3_, 1, 0);
	_tmp4_ = xmlBufferContent (buf);
	_tmp5_ = g_strdup (_tmp4_);
	result = _tmp5_;
	_xmlBufferFree0 (buf);
	return result;
}


static gchar* gxml_gelement_real_get_value (GXmlGNode* base) {
	gchar* result;
	GXmlGElement* self;
	gchar* _tmp0_ = NULL;
	gchar* _tmp1_ = NULL;
	self = (GXmlGElement*) base;
	_tmp0_ = gxml_element_get_content ((GXmlElement*) self);
	_tmp1_ = _tmp0_;
	result = _tmp1_;
	return result;
}


static void gxml_gelement_real_set_value (GXmlGNode* base, const gchar* value) {
	GXmlGElement* self;
	const gchar* _tmp0_ = NULL;
	self = (GXmlGElement*) base;
	_tmp0_ = value;
	gxml_element_set_content ((GXmlElement*) self, _tmp0_);
	g_object_notify ((GObject *) self, "value");
}


static gchar* gxml_gelement_real_get_content (GXmlElement* base) {
	gchar* result;
	GXmlGElement* self;
	xmlNode* _tmp0_ = NULL;
	gchar* _tmp1_ = NULL;
	gchar* _tmp2_ = NULL;
	gchar* _tmp3_ = NULL;
	gchar* _tmp4_ = NULL;
	self = (GXmlGElement*) base;
	_tmp0_ = ((GXmlGNode*) self)->_node;
	_tmp1_ = (gchar*) xmlNodeGetContent (_tmp0_);
	_tmp2_ = _tmp1_;
	_tmp3_ = g_strdup (_tmp2_);
	_tmp4_ = _tmp3_;
	_g_free0 (_tmp2_);
	result = _tmp4_;
	return result;
}


static void gxml_gelement_real_set_content (GXmlElement* base, const gchar* value) {
	GXmlGElement* self;
	xmlNode* _tmp0_ = NULL;
	const gchar* _tmp1_ = NULL;
	self = (GXmlGElement*) base;
	_tmp0_ = ((GXmlGNode*) self)->_node;
	_tmp1_ = value;
	xmlNodeSetContent (_tmp0_, (xmlChar*) _tmp1_);
	g_object_notify ((GObject *) self, "content");
}


static gchar* gxml_gelement_real_get_tag_name (GXmlElement* base) {
	gchar* result;
	GXmlGElement* self;
	xmlNode* _tmp0_ = NULL;
	const gchar* _tmp1_ = NULL;
	gchar* _tmp2_ = NULL;
	self = (GXmlGElement*) base;
	_tmp0_ = ((GXmlGNode*) self)->_node;
	_tmp1_ = _tmp0_->name;
	_tmp2_ = g_strdup (_tmp1_);
	result = _tmp2_;
	return result;
}


static void gxml_gelement_class_init (GXmlGElementClass * klass) {
	gxml_gelement_parent_class = g_type_class_peek_parent (klass);
	((GXmlGNodeClass *) klass)->to_string = gxml_gelement_real_to_string;
	GXML_GNODE_CLASS (klass)->get_value = gxml_gelement_real_get_value;
	GXML_GNODE_CLASS (klass)->set_value = gxml_gelement_real_set_value;
	G_OBJECT_CLASS (klass)->get_property = _vala_gxml_gelement_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_gxml_gelement_set_property;
	g_object_class_install_property (G_OBJECT_CLASS (klass), GXML_GELEMENT_VALUE, g_param_spec_string ("value", "value", "value", NULL, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GXML_GELEMENT_CONTENT, g_param_spec_string ("content", "content", "content", NULL, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GXML_GELEMENT_TAG_NAME, g_param_spec_string ("tag-name", "tag-name", "tag-name", NULL, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE));
}


static void gxml_gelement_gxml_element_interface_init (GXmlElementIface * iface) {
	gxml_gelement_gxml_element_parent_iface = g_type_interface_peek_parent (iface);
	iface->set_attr = (void (*)(GXmlElement*, const gchar*, const gchar*)) gxml_gelement_real_set_attr;
	iface->get_attr = (GXmlNode* (*)(GXmlElement*, const gchar*)) gxml_gelement_real_get_attr;
	iface->set_ns_attr = (void (*)(GXmlElement*, GXmlNamespace*, const gchar*, const gchar*)) gxml_gelement_real_set_ns_attr;
	iface->get_ns_attr = (GXmlNode* (*)(GXmlElement*, const gchar*, const gchar*)) gxml_gelement_real_get_ns_attr;
	iface->normalize = (void (*)(GXmlElement*)) gxml_gelement_real_normalize;
	iface->remove_attr = (void (*)(GXmlElement*, const gchar*)) gxml_gelement_real_remove_attr;
	iface->get_content = gxml_gelement_real_get_content;
	iface->set_content = gxml_gelement_real_set_content;
	iface->get_tag_name = gxml_gelement_real_get_tag_name;
}


static void gxml_gelement_instance_init (GXmlGElement * self) {
}


/**
 * Class implemeting {@link GXml.Element} interface, not tied to libxml-2.0 library.
 */
GType gxml_gelement_get_type (void) {
	static volatile gsize gxml_gelement_type_id__volatile = 0;
	if (g_once_init_enter (&gxml_gelement_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (GXmlGElementClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) gxml_gelement_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GXmlGElement), 0, (GInstanceInitFunc) gxml_gelement_instance_init, NULL };
		static const GInterfaceInfo gxml_element_info = { (GInterfaceInitFunc) gxml_gelement_gxml_element_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
		GType gxml_gelement_type_id;
		gxml_gelement_type_id = g_type_register_static (GXML_TYPE_GNODE, "GXmlGElement", &g_define_type_info, 0);
		g_type_add_interface_static (gxml_gelement_type_id, GXML_TYPE_ELEMENT, &gxml_element_info);
		g_once_init_leave (&gxml_gelement_type_id__volatile, gxml_gelement_type_id);
	}
	return gxml_gelement_type_id__volatile;
}


static void _vala_gxml_gelement_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec) {
	GXmlGElement * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, GXML_TYPE_GELEMENT, GXmlGElement);
	switch (property_id) {
		case GXML_GELEMENT_VALUE:
		g_value_take_string (value, gxml_gnode_get_value ((GXmlGNode*) self));
		break;
		case GXML_GELEMENT_CONTENT:
		g_value_take_string (value, gxml_element_get_content ((GXmlElement*) self));
		break;
		case GXML_GELEMENT_TAG_NAME:
		g_value_take_string (value, gxml_element_get_tag_name ((GXmlElement*) self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}


static void _vala_gxml_gelement_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec) {
	GXmlGElement * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, GXML_TYPE_GELEMENT, GXmlGElement);
	switch (property_id) {
		case GXML_GELEMENT_VALUE:
		gxml_gnode_set_value ((GXmlGNode*) self, g_value_get_string (value));
		break;
		case GXML_GELEMENT_CONTENT:
		gxml_element_set_content ((GXmlElement*) self, g_value_get_string (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}


static void _vala_array_destroy (gpointer array, gint array_length, GDestroyNotify destroy_func) {
	if ((array != NULL) && (destroy_func != NULL)) {
		int 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, gint array_length, GDestroyNotify destroy_func) {
	_vala_array_destroy (array, array_length, destroy_func);
	g_free (array);
}


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



