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

/* TElement.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 <glib.h>
#include <glib-object.h>
#include <stdlib.h>
#include <string.h>
#include <gee.h>
#include <gio/gio.h>
#include <libxml/xmlwriter.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_TNODE (gxml_tnode_get_type ())
#define GXML_TNODE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GXML_TYPE_TNODE, GXmlTNode))
#define GXML_TNODE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GXML_TYPE_TNODE, GXmlTNodeClass))
#define GXML_IS_TNODE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GXML_TYPE_TNODE))
#define GXML_IS_TNODE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GXML_TYPE_TNODE))
#define GXML_TNODE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GXML_TYPE_TNODE, GXmlTNodeClass))

typedef struct _GXmlTNode GXmlTNode;
typedef struct _GXmlTNodeClass GXmlTNodeClass;
typedef struct _GXmlTNodePrivate GXmlTNodePrivate;

#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_TELEMENT (gxml_telement_get_type ())
#define GXML_TELEMENT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GXML_TYPE_TELEMENT, GXmlTElement))
#define GXML_TELEMENT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GXML_TYPE_TELEMENT, GXmlTElementClass))
#define GXML_IS_TELEMENT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GXML_TYPE_TELEMENT))
#define GXML_IS_TELEMENT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GXML_TYPE_TELEMENT))
#define GXML_TELEMENT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GXML_TYPE_TELEMENT, GXmlTElementClass))

typedef struct _GXmlTElement GXmlTElement;
typedef struct _GXmlTElementClass GXmlTElementClass;
typedef struct _GXmlTElementPrivate GXmlTElementPrivate;

#define GXML_TNODE_TYPE_TCHILDREN_LIST (gxml_tnode_tchildren_list_get_type ())
#define GXML_TNODE_TCHILDREN_LIST(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GXML_TNODE_TYPE_TCHILDREN_LIST, GXmlTNodeTChildrenList))
#define GXML_TNODE_TCHILDREN_LIST_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GXML_TNODE_TYPE_TCHILDREN_LIST, GXmlTNodeTChildrenListClass))
#define GXML_TNODE_IS_TCHILDREN_LIST(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GXML_TNODE_TYPE_TCHILDREN_LIST))
#define GXML_TNODE_IS_TCHILDREN_LIST_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GXML_TNODE_TYPE_TCHILDREN_LIST))
#define GXML_TNODE_TCHILDREN_LIST_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GXML_TNODE_TYPE_TCHILDREN_LIST, GXmlTNodeTChildrenListClass))

typedef struct _GXmlTNodeTChildrenList GXmlTNodeTChildrenList;
typedef struct _GXmlTNodeTChildrenListClass GXmlTNodeTChildrenListClass;
#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_TDOCUMENT (gxml_tdocument_get_type ())
#define GXML_TDOCUMENT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GXML_TYPE_TDOCUMENT, GXmlTDocument))
#define GXML_TDOCUMENT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GXML_TYPE_TDOCUMENT, GXmlTDocumentClass))
#define GXML_IS_TDOCUMENT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GXML_TYPE_TDOCUMENT))
#define GXML_IS_TDOCUMENT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GXML_TYPE_TDOCUMENT))
#define GXML_TDOCUMENT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GXML_TYPE_TDOCUMENT, GXmlTDocumentClass))

typedef struct _GXmlTDocument GXmlTDocument;
typedef struct _GXmlTDocumentClass GXmlTDocumentClass;

#define GXML_TYPE_TATTRIBUTE (gxml_tattribute_get_type ())
#define GXML_TATTRIBUTE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GXML_TYPE_TATTRIBUTE, GXmlTAttribute))
#define GXML_TATTRIBUTE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GXML_TYPE_TATTRIBUTE, GXmlTAttributeClass))
#define GXML_IS_TATTRIBUTE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GXML_TYPE_TATTRIBUTE))
#define GXML_IS_TATTRIBUTE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GXML_TYPE_TATTRIBUTE))
#define GXML_TATTRIBUTE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GXML_TYPE_TATTRIBUTE, GXmlTAttributeClass))

typedef struct _GXmlTAttribute GXmlTAttribute;
typedef struct _GXmlTAttributeClass GXmlTAttributeClass;

#define GXML_TYPE_ATTRIBUTE (gxml_attribute_get_type ())
#define GXML_ATTRIBUTE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GXML_TYPE_ATTRIBUTE, GXmlAttribute))
#define GXML_IS_ATTRIBUTE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GXML_TYPE_ATTRIBUTE))
#define GXML_ATTRIBUTE_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), GXML_TYPE_ATTRIBUTE, GXmlAttributeIface))

typedef struct _GXmlAttribute GXmlAttribute;
typedef struct _GXmlAttributeIface GXmlAttributeIface;

#define GXML_TYPE_TEXT (gxml_text_get_type ())
#define GXML_TEXT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GXML_TYPE_TEXT, GXmlText))
#define GXML_IS_TEXT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GXML_TYPE_TEXT))
#define GXML_TEXT_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), GXML_TYPE_TEXT, GXmlTextIface))

typedef struct _GXmlText GXmlText;
typedef struct _GXmlTextIface GXmlTextIface;
#define _vala_assert(expr, msg) if G_LIKELY (expr) ; else g_assertion_message_expr (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, msg);
#define _vala_return_if_fail(expr, msg) if G_LIKELY (expr) ; else { g_return_if_fail_warning (G_LOG_DOMAIN, G_STRFUNC, msg); return; }
#define _vala_return_val_if_fail(expr, msg, val) if G_LIKELY (expr) ; else { g_return_if_fail_warning (G_LOG_DOMAIN, G_STRFUNC, msg); return val; }
#define _vala_warn_if_fail(expr, msg) if G_LIKELY (expr) ; else g_warn_message (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, msg);

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

typedef enum  {
	GXML_NODE_TYPE_INVALID = 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);
	GXmlElementList* (*get_elements_by_name) (GXmlNode* self, const gchar* name);
	GXmlElementList* (*get_elements_by_name_ns) (GXmlNode* self, const gchar* name, const gchar* ns);
	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_children_nodes) (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 _GXmlTNode {
	GObject parent_instance;
	GXmlTNodePrivate * priv;
	gchar* _name;
	gchar* _value;
	GXmlDocument* _doc;
	GXmlNode* _parent;
	GXmlNodeType _node_type;
	xmlTextWriter* tw;
};

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

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 (*remove_ns_attr) (GXmlElement* self, const gchar* name, const gchar* uri);
	void (*set_ns_attr) (GXmlElement* self, const gchar* 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 _GXmlTElement {
	GXmlTNode parent_instance;
	GXmlTElementPrivate * priv;
	GeeHashMap* _attrs;
	GXmlTNodeTChildrenList* _children;
	GeeArrayList* _namespaces;
};

struct _GXmlTElementClass {
	GXmlTNodeClass parent_class;
};

struct _GXmlTElementPrivate {
	gchar* _content;
};

struct _GXmlAttributeIface {
	GTypeInterface parent_iface;
	GXmlNamespace* (*get_namespace) (GXmlAttribute* self);
	void (*set_namespace) (GXmlAttribute* self, GXmlNamespace* value);
	gchar* (*get_prefix) (GXmlAttribute* self);
};

struct _GXmlTextIface {
	GTypeInterface parent_iface;
	gchar* (*get_str) (GXmlText* self);
	void (*set_str) (GXmlText* self, const gchar* value);
};


static gpointer gxml_telement_parent_class = NULL;
static GXmlElementIface* gxml_telement_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_tnode_get_type (void) G_GNUC_CONST;
GType gxml_element_get_type (void) G_GNUC_CONST;
GType gxml_telement_get_type (void) G_GNUC_CONST;
GType gxml_tnode_tchildren_list_get_type (void) G_GNUC_CONST;
#define GXML_TELEMENT_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GXML_TYPE_TELEMENT, GXmlTElementPrivate))
enum  {
	GXML_TELEMENT_DUMMY_PROPERTY,
	GXML_TELEMENT_VALUE,
	GXML_TELEMENT_ATTRS,
	GXML_TELEMENT_CHILDREN_NODES,
	GXML_TELEMENT_NAMESPACES,
	GXML_TELEMENT_CONTENT,
	GXML_TELEMENT_TAG_NAME
};
GXmlTElement* gxml_telement_new (GXmlDocument* d, const gchar* name);
GXmlTElement* gxml_telement_construct (GType object_type, GXmlDocument* d, const gchar* name);
GType gxml_tdocument_get_type (void) G_GNUC_CONST;
GXmlTNode* gxml_tnode_construct (GType object_type);
static void gxml_telement_real_set_attr (GXmlElement* base, const gchar* name, const gchar* value);
GType gxml_tattribute_get_type (void) G_GNUC_CONST;
GXmlDocument* gxml_tnode_get_document (GXmlTNode* self);
GXmlTAttribute* gxml_tattribute_new (GXmlDocument* d, const gchar* name, const gchar* value);
GXmlTAttribute* gxml_tattribute_construct (GType object_type, GXmlDocument* d, const gchar* name, const gchar* value);
void gxml_tnode_set_parent (GXmlTNode* self, GXmlNode* node);
GeeMap* gxml_tnode_get_attrs (GXmlTNode* self);
static GXmlNode* gxml_telement_real_get_attr (GXmlElement* base, const gchar* name);
static GXmlNode* gxml_telement_real_get_ns_attr (GXmlElement* base, const gchar* name, const gchar* uri);
gchar* gxml_node_get_name (GXmlNode* self);
GType gxml_attribute_get_type (void) G_GNUC_CONST;
GXmlNamespace* gxml_attribute_get_namespace (GXmlAttribute* self);
gchar* gxml_namespace_get_uri (GXmlNamespace* self);
static void gxml_telement_real_set_ns_attr (GXmlElement* base, const gchar* ns, const gchar* name, const gchar* value);
gboolean gxml_tnode_set_namespace (GXmlTNode* self, const gchar* uri, const gchar* prefix);
static void gxml_telement_real_remove_attr (GXmlElement* base, const gchar* name);
static void gxml_telement_real_remove_ns_attr (GXmlElement* base, const gchar* name, const gchar* uri);
static void gxml_telement_real_normalize (GXmlElement* base);
static void gxml_telement_calculate_content (GXmlTElement* self);
GeeBidirList* gxml_tnode_get_children_nodes (GXmlTNode* self);
GType gxml_text_get_type (void) G_GNUC_CONST;
gchar* gxml_node_get_value (GXmlNode* self);
static void gxml_telement_update_content (GXmlTElement* self, const gchar* val);
GXmlNode* gxml_document_create_text (GXmlDocument* self, const gchar* text);
GXmlTNodeTChildrenList* gxml_tnode_tchildren_list_new (GXmlNode* e);
GXmlTNodeTChildrenList* gxml_tnode_tchildren_list_construct (GType object_type, GXmlNode* e);
gchar* gxml_tnode_get_name (GXmlTNode* self);
static GObject * gxml_telement_constructor (GType type, guint n_construct_properties, GObjectConstructParam * construct_properties);
static void gxml_telement_finalize (GObject* obj);
gchar* gxml_tnode_get_value (GXmlTNode* self);
GeeList* gxml_tnode_get_namespaces (GXmlTNode* self);
gchar* gxml_element_get_content (GXmlElement* self);
gchar* gxml_element_get_tag_name (GXmlElement* self);
static void _vala_gxml_telement_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec);
void gxml_tnode_set_value (GXmlTNode* self, const gchar* value);
void gxml_element_set_content (GXmlElement* self, const gchar* value);
static void _vala_gxml_telement_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;
}


GXmlTElement* gxml_telement_construct (GType object_type, GXmlDocument* d, const gchar* name) {
	GXmlTElement * self = NULL;
	GXmlDocument* _tmp0_ = NULL;
	GXmlDocument* _tmp1_ = NULL;
	GXmlDocument* _tmp2_ = NULL;
	const gchar* _tmp3_ = NULL;
	gchar* _tmp4_ = NULL;
	g_return_val_if_fail (d != NULL, NULL);
	g_return_val_if_fail (name != NULL, NULL);
	_tmp0_ = d;
	_vala_return_val_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (_tmp0_, GXML_TYPE_TDOCUMENT), "d is TDocument", NULL);
	self = (GXmlTElement*) gxml_tnode_construct (object_type);
	_tmp1_ = d;
	_tmp2_ = _g_object_ref0 (_tmp1_);
	_g_object_unref0 (((GXmlTNode*) self)->_doc);
	((GXmlTNode*) self)->_doc = _tmp2_;
	_tmp3_ = name;
	_tmp4_ = g_strdup (_tmp3_);
	_g_free0 (((GXmlTNode*) self)->_name);
	((GXmlTNode*) self)->_name = _tmp4_;
	return self;
}


GXmlTElement* gxml_telement_new (GXmlDocument* d, const gchar* name) {
	return gxml_telement_construct (GXML_TYPE_TELEMENT, d, name);
}


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_telement_real_set_attr (GXmlElement* base, const gchar* name, const gchar* value) {
	GXmlTElement * self;
	const gchar* _tmp0_ = NULL;
	gboolean _tmp1_ = FALSE;
	GXmlTAttribute* att = NULL;
	GXmlDocument* _tmp2_ = NULL;
	GXmlDocument* _tmp3_ = NULL;
	const gchar* _tmp4_ = NULL;
	const gchar* _tmp5_ = NULL;
	GXmlTAttribute* _tmp6_ = NULL;
	GXmlTAttribute* _tmp7_ = NULL;
	GeeMap* _tmp8_ = NULL;
	GeeMap* _tmp9_ = NULL;
	GeeMap* _tmp10_ = NULL;
	const gchar* _tmp11_ = NULL;
	GXmlTAttribute* _tmp12_ = NULL;
	self = (GXmlTElement*) base;
	g_return_if_fail (name != NULL);
	g_return_if_fail (value != NULL);
	_tmp0_ = name;
	_tmp1_ = string_contains (_tmp0_, ":");
	if (_tmp1_) {
		return;
	}
	_tmp2_ = gxml_tnode_get_document ((GXmlTNode*) self);
	_tmp3_ = _tmp2_;
	_tmp4_ = name;
	_tmp5_ = value;
	_tmp6_ = gxml_tattribute_new (_tmp3_, _tmp4_, _tmp5_);
	att = _tmp6_;
	_tmp7_ = att;
	gxml_tnode_set_parent ((GXmlTNode*) _tmp7_, (GXmlNode*) self);
	_tmp8_ = gxml_tnode_get_attrs ((GXmlTNode*) self);
	_tmp9_ = _tmp8_;
	_tmp10_ = _tmp9_;
	_tmp11_ = name;
	_tmp12_ = att;
	gee_map_set (_tmp10_, _tmp11_, (GXmlNode*) _tmp12_);
	_g_object_unref0 (_tmp10_);
	_g_object_unref0 (att);
}


static GXmlNode* gxml_telement_real_get_attr (GXmlElement* base, const gchar* name) {
	GXmlTElement * self;
	GXmlNode* result = NULL;
	GeeMap* _tmp0_ = NULL;
	GeeMap* _tmp1_ = NULL;
	GeeMap* _tmp2_ = NULL;
	const gchar* _tmp3_ = NULL;
	gpointer _tmp4_ = NULL;
	GXmlNode* _tmp5_ = NULL;
	self = (GXmlTElement*) base;
	g_return_val_if_fail (name != NULL, NULL);
	_tmp0_ = gxml_tnode_get_attrs ((GXmlTNode*) self);
	_tmp1_ = _tmp0_;
	_tmp2_ = _tmp1_;
	_tmp3_ = name;
	_tmp4_ = gee_map_get (_tmp2_, _tmp3_);
	_tmp5_ = (GXmlNode*) _tmp4_;
	_g_object_unref0 (_tmp2_);
	result = _tmp5_;
	return result;
}


static GXmlNode* gxml_telement_real_get_ns_attr (GXmlElement* base, const gchar* name, const gchar* uri) {
	GXmlTElement * self;
	GXmlNode* result = NULL;
	self = (GXmlTElement*) base;
	g_return_val_if_fail (name != NULL, NULL);
	g_return_val_if_fail (uri != NULL, NULL);
	{
		GeeIterator* _k_it = NULL;
		GeeMap* _tmp0_ = NULL;
		GeeMap* _tmp1_ = NULL;
		GeeMap* _tmp2_ = NULL;
		GeeSet* _tmp3_ = NULL;
		GeeSet* _tmp4_ = NULL;
		GeeSet* _tmp5_ = NULL;
		GeeIterator* _tmp6_ = NULL;
		GeeIterator* _tmp7_ = NULL;
		_tmp0_ = gxml_tnode_get_attrs ((GXmlTNode*) self);
		_tmp1_ = _tmp0_;
		_tmp2_ = _tmp1_;
		_tmp3_ = gee_map_get_keys (_tmp2_);
		_tmp4_ = _tmp3_;
		_tmp5_ = _tmp4_;
		_tmp6_ = gee_iterable_iterator ((GeeIterable*) _tmp5_);
		_tmp7_ = _tmp6_;
		_g_object_unref0 (_tmp5_);
		_g_object_unref0 (_tmp2_);
		_k_it = _tmp7_;
		while (TRUE) {
			GeeIterator* _tmp8_ = NULL;
			gboolean _tmp9_ = FALSE;
			gchar* k = NULL;
			GeeIterator* _tmp10_ = NULL;
			gpointer _tmp11_ = NULL;
			const gchar* _tmp12_ = NULL;
			gboolean _tmp13_ = FALSE;
			GXmlNode* a = NULL;
			GeeMap* _tmp14_ = NULL;
			GeeMap* _tmp15_ = NULL;
			GeeMap* _tmp16_ = NULL;
			const gchar* _tmp17_ = NULL;
			gpointer _tmp18_ = NULL;
			GXmlNode* _tmp19_ = NULL;
			GXmlNode* _tmp20_ = NULL;
			gchar* _tmp21_ = NULL;
			gchar* _tmp22_ = NULL;
			gchar* _tmp23_ = NULL;
			const gchar* _tmp24_ = NULL;
			gboolean _tmp25_ = FALSE;
			GXmlNode* _tmp26_ = NULL;
			GXmlNamespace* _tmp27_ = NULL;
			GXmlNamespace* _tmp28_ = NULL;
			GXmlNamespace* _tmp29_ = NULL;
			gboolean _tmp30_ = FALSE;
			GXmlNode* _tmp31_ = NULL;
			GXmlNamespace* _tmp32_ = NULL;
			GXmlNamespace* _tmp33_ = NULL;
			GXmlNamespace* _tmp34_ = NULL;
			gchar* _tmp35_ = NULL;
			gchar* _tmp36_ = NULL;
			gchar* _tmp37_ = NULL;
			const gchar* _tmp38_ = NULL;
			gboolean _tmp39_ = FALSE;
			_tmp8_ = _k_it;
			_tmp9_ = gee_iterator_next (_tmp8_);
			if (!_tmp9_) {
				break;
			}
			_tmp10_ = _k_it;
			_tmp11_ = gee_iterator_get (_tmp10_);
			k = (gchar*) _tmp11_;
			_tmp12_ = k;
			_tmp13_ = string_contains (_tmp12_, ":");
			if (!_tmp13_) {
				_g_free0 (k);
				continue;
			}
			_tmp14_ = gxml_tnode_get_attrs ((GXmlTNode*) self);
			_tmp15_ = _tmp14_;
			_tmp16_ = _tmp15_;
			_tmp17_ = k;
			_tmp18_ = gee_map_get (_tmp16_, _tmp17_);
			_tmp19_ = (GXmlNode*) _tmp18_;
			_g_object_unref0 (_tmp16_);
			a = _tmp19_;
			_tmp20_ = a;
			_tmp21_ = gxml_node_get_name (_tmp20_);
			_tmp22_ = _tmp21_;
			_tmp23_ = _tmp22_;
			_tmp24_ = name;
			_tmp25_ = g_strcmp0 (_tmp23_, _tmp24_) != 0;
			_g_free0 (_tmp23_);
			if (_tmp25_) {
				_g_object_unref0 (a);
				_g_free0 (k);
				continue;
			}
			_tmp26_ = a;
			_tmp27_ = gxml_attribute_get_namespace (G_TYPE_CHECK_INSTANCE_CAST (_tmp26_, GXML_TYPE_ATTRIBUTE, GXmlAttribute));
			_tmp28_ = _tmp27_;
			_tmp29_ = _tmp28_;
			_tmp30_ = _tmp29_ == NULL;
			_g_object_unref0 (_tmp29_);
			if (_tmp30_) {
				_g_object_unref0 (a);
				_g_free0 (k);
				continue;
			}
			_tmp31_ = a;
			_tmp32_ = gxml_attribute_get_namespace (G_TYPE_CHECK_INSTANCE_CAST (_tmp31_, GXML_TYPE_ATTRIBUTE, GXmlAttribute));
			_tmp33_ = _tmp32_;
			_tmp34_ = _tmp33_;
			_tmp35_ = gxml_namespace_get_uri (_tmp34_);
			_tmp36_ = _tmp35_;
			_tmp37_ = _tmp36_;
			_tmp38_ = uri;
			_tmp39_ = g_strcmp0 (_tmp37_, _tmp38_) == 0;
			_g_free0 (_tmp37_);
			_g_object_unref0 (_tmp34_);
			if (_tmp39_) {
				GXmlNode* _tmp40_ = NULL;
				GXmlNode* _tmp41_ = NULL;
				_tmp40_ = a;
				_tmp41_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp40_, GXML_TYPE_NODE, GXmlNode));
				result = _tmp41_;
				_g_object_unref0 (a);
				_g_free0 (k);
				_g_object_unref0 (_k_it);
				return result;
			}
			_g_object_unref0 (a);
			_g_free0 (k);
		}
		_g_object_unref0 (_k_it);
	}
	result = NULL;
	return result;
}


static void gxml_telement_real_set_ns_attr (GXmlElement* base, const gchar* ns, const gchar* name, const gchar* value) {
	GXmlTElement * self;
	GXmlTAttribute* att = NULL;
	GXmlDocument* _tmp0_ = NULL;
	GXmlDocument* _tmp1_ = NULL;
	const gchar* _tmp2_ = NULL;
	const gchar* _tmp3_ = NULL;
	GXmlTAttribute* _tmp4_ = NULL;
	gchar* prefix = NULL;
	gchar* uri = NULL;
	gchar* _tmp5_ = NULL;
	const gchar* _tmp6_ = NULL;
	gboolean _tmp7_ = FALSE;
	GXmlTAttribute* _tmp24_ = NULL;
	const gchar* _tmp25_ = NULL;
	const gchar* _tmp26_ = NULL;
	GXmlTAttribute* _tmp27_ = NULL;
	gchar* p = NULL;
	gchar* _tmp28_ = NULL;
	const gchar* _tmp29_ = NULL;
	GeeMap* _tmp32_ = NULL;
	GeeMap* _tmp33_ = NULL;
	GeeMap* _tmp34_ = NULL;
	const gchar* _tmp35_ = NULL;
	gchar* _tmp36_ = NULL;
	gchar* _tmp37_ = NULL;
	const gchar* _tmp38_ = NULL;
	gchar* _tmp39_ = NULL;
	gchar* _tmp40_ = NULL;
	GXmlTAttribute* _tmp41_ = NULL;
	self = (GXmlTElement*) base;
	g_return_if_fail (ns != NULL);
	g_return_if_fail (name != NULL);
	g_return_if_fail (value != NULL);
	_tmp0_ = gxml_tnode_get_document ((GXmlTNode*) self);
	_tmp1_ = _tmp0_;
	_tmp2_ = name;
	_tmp3_ = value;
	_tmp4_ = gxml_tattribute_new (_tmp1_, _tmp2_, _tmp3_);
	att = _tmp4_;
	prefix = NULL;
	_tmp5_ = g_strdup ("");
	uri = _tmp5_;
	_tmp6_ = ns;
	_tmp7_ = string_contains (_tmp6_, ":");
	if (_tmp7_) {
		gchar** s = NULL;
		const gchar* _tmp8_ = NULL;
		gchar** _tmp9_ = NULL;
		gchar** _tmp10_ = NULL;
		gint s_length1 = 0;
		gint _s_size_ = 0;
		gchar** _tmp11_ = NULL;
		gint _tmp11__length1 = 0;
		const gchar* _tmp12_ = NULL;
		gchar* _tmp13_ = NULL;
		gchar** _tmp14_ = NULL;
		gint _tmp14__length1 = 0;
		gchar** _tmp15_ = NULL;
		gint _tmp15__length1 = 0;
		const gchar* _tmp16_ = NULL;
		gchar* _tmp17_ = NULL;
		gchar* _tmp18_ = NULL;
		gchar** _tmp19_ = NULL;
		gint _tmp19__length1 = 0;
		const gchar* _tmp20_ = NULL;
		gchar* _tmp21_ = NULL;
		_tmp8_ = ns;
		_tmp10_ = _tmp9_ = g_strsplit (_tmp8_, ":", 0);
		s = _tmp10_;
		s_length1 = _vala_array_length (_tmp9_);
		_s_size_ = s_length1;
		_tmp11_ = s;
		_tmp11__length1 = s_length1;
		_tmp12_ = _tmp11_[0];
		_tmp13_ = g_strdup (_tmp12_);
		_g_free0 (prefix);
		prefix = _tmp13_;
		_tmp14_ = s;
		_tmp14__length1 = s_length1;
		if (_tmp14__length1 != 3) {
			s = (_vala_array_free (s, s_length1, (GDestroyNotify) g_free), NULL);
			_g_free0 (uri);
			_g_free0 (prefix);
			_g_object_unref0 (att);
			return;
		}
		_tmp15_ = s;
		_tmp15__length1 = s_length1;
		_tmp16_ = _tmp15_[1];
		_tmp17_ = g_strconcat (_tmp16_, ":", NULL);
		_tmp18_ = _tmp17_;
		_tmp19_ = s;
		_tmp19__length1 = s_length1;
		_tmp20_ = _tmp19_[2];
		_tmp21_ = g_strconcat (_tmp18_, _tmp20_, NULL);
		_g_free0 (uri);
		uri = _tmp21_;
		_g_free0 (_tmp18_);
		s = (_vala_array_free (s, s_length1, (GDestroyNotify) g_free), NULL);
	} else {
		const gchar* _tmp22_ = NULL;
		gchar* _tmp23_ = NULL;
		_tmp22_ = ns;
		_tmp23_ = g_strdup (_tmp22_);
		_g_free0 (uri);
		uri = _tmp23_;
	}
	_tmp24_ = att;
	_tmp25_ = uri;
	_tmp26_ = prefix;
	gxml_tnode_set_namespace ((GXmlTNode*) _tmp24_, _tmp25_, _tmp26_);
	_tmp27_ = att;
	gxml_tnode_set_parent ((GXmlTNode*) _tmp27_, (GXmlNode*) self);
	_tmp28_ = g_strdup ("");
	p = _tmp28_;
	_tmp29_ = prefix;
	if (_tmp29_ != NULL) {
		const gchar* _tmp30_ = NULL;
		gchar* _tmp31_ = NULL;
		_tmp30_ = prefix;
		_tmp31_ = g_strdup (_tmp30_);
		_g_free0 (p);
		p = _tmp31_;
	}
	_tmp32_ = gxml_tnode_get_attrs ((GXmlTNode*) self);
	_tmp33_ = _tmp32_;
	_tmp34_ = _tmp33_;
	_tmp35_ = p;
	_tmp36_ = g_strconcat (_tmp35_, ":", NULL);
	_tmp37_ = _tmp36_;
	_tmp38_ = name;
	_tmp39_ = g_strconcat (_tmp37_, _tmp38_, NULL);
	_tmp40_ = _tmp39_;
	_tmp41_ = att;
	gee_map_set (_tmp34_, _tmp40_, (GXmlNode*) _tmp41_);
	_g_free0 (_tmp40_);
	_g_free0 (_tmp37_);
	_g_object_unref0 (_tmp34_);
	_g_free0 (p);
	_g_free0 (uri);
	_g_free0 (prefix);
	_g_object_unref0 (att);
}


static void gxml_telement_real_remove_attr (GXmlElement* base, const gchar* name) {
	GXmlTElement * self;
	GeeMap* _tmp0_ = NULL;
	GeeMap* _tmp1_ = NULL;
	GeeMap* _tmp2_ = NULL;
	const gchar* _tmp3_ = NULL;
	gboolean _tmp4_ = FALSE;
	gboolean _tmp5_ = FALSE;
	self = (GXmlTElement*) base;
	g_return_if_fail (name != NULL);
	_tmp0_ = gxml_tnode_get_attrs ((GXmlTNode*) self);
	_tmp1_ = _tmp0_;
	_tmp2_ = _tmp1_;
	_tmp3_ = name;
	_tmp4_ = gee_map_has_key (_tmp2_, _tmp3_);
	_tmp5_ = _tmp4_;
	_g_object_unref0 (_tmp2_);
	if (_tmp5_) {
		GeeMap* _tmp6_ = NULL;
		GeeMap* _tmp7_ = NULL;
		GeeMap* _tmp8_ = NULL;
		const gchar* _tmp9_ = NULL;
		_tmp6_ = gxml_tnode_get_attrs ((GXmlTNode*) self);
		_tmp7_ = _tmp6_;
		_tmp8_ = _tmp7_;
		_tmp9_ = name;
		gee_map_unset (_tmp8_, _tmp9_, NULL);
		_g_object_unref0 (_tmp8_);
	}
}


static void gxml_telement_real_remove_ns_attr (GXmlElement* base, const gchar* name, const gchar* uri) {
	GXmlTElement * self;
	gchar* prefix = NULL;
	gchar* _tmp0_ = NULL;
	gchar* nuri = NULL;
	gchar* _tmp1_ = NULL;
	const gchar* _tmp2_ = NULL;
	gboolean _tmp3_ = FALSE;
	self = (GXmlTElement*) base;
	g_return_if_fail (name != NULL);
	g_return_if_fail (uri != NULL);
	_tmp0_ = g_strdup ("");
	prefix = _tmp0_;
	_tmp1_ = g_strdup ("");
	nuri = _tmp1_;
	_tmp2_ = uri;
	_tmp3_ = string_contains (_tmp2_, ":");
	if (_tmp3_) {
		gchar** s = NULL;
		const gchar* _tmp4_ = NULL;
		gchar** _tmp5_ = NULL;
		gchar** _tmp6_ = NULL;
		gint s_length1 = 0;
		gint _s_size_ = 0;
		gchar** _tmp7_ = NULL;
		gint _tmp7__length1 = 0;
		const gchar* _tmp8_ = NULL;
		gchar* _tmp9_ = NULL;
		const gchar* _tmp10_ = NULL;
		gchar* _tmp11_ = NULL;
		_tmp4_ = uri;
		_tmp6_ = _tmp5_ = g_strsplit (_tmp4_, ":", 0);
		s = _tmp6_;
		s_length1 = _vala_array_length (_tmp5_);
		_s_size_ = s_length1;
		_tmp7_ = s;
		_tmp7__length1 = s_length1;
		_tmp8_ = _tmp7_[0];
		_tmp9_ = g_strdup (_tmp8_);
		_g_free0 (prefix);
		prefix = _tmp9_;
		_tmp10_ = uri;
		_tmp11_ = g_strdup (_tmp10_);
		_g_free0 (nuri);
		nuri = _tmp11_;
		s = (_vala_array_free (s, s_length1, (GDestroyNotify) g_free), NULL);
	} else {
		const gchar* _tmp12_ = NULL;
		gchar* _tmp13_ = NULL;
		_tmp12_ = uri;
		_tmp13_ = g_strdup (_tmp12_);
		_g_free0 (nuri);
		nuri = _tmp13_;
	}
	{
		GeeIterator* _a_it = NULL;
		GeeMap* _tmp14_ = NULL;
		GeeMap* _tmp15_ = NULL;
		GeeMap* _tmp16_ = NULL;
		GeeCollection* _tmp17_ = NULL;
		GeeCollection* _tmp18_ = NULL;
		GeeCollection* _tmp19_ = NULL;
		GeeIterator* _tmp20_ = NULL;
		GeeIterator* _tmp21_ = NULL;
		_tmp14_ = gxml_tnode_get_attrs ((GXmlTNode*) self);
		_tmp15_ = _tmp14_;
		_tmp16_ = _tmp15_;
		_tmp17_ = gee_map_get_values (_tmp16_);
		_tmp18_ = _tmp17_;
		_tmp19_ = _tmp18_;
		_tmp20_ = gee_iterable_iterator ((GeeIterable*) _tmp19_);
		_tmp21_ = _tmp20_;
		_g_object_unref0 (_tmp19_);
		_g_object_unref0 (_tmp16_);
		_a_it = _tmp21_;
		while (TRUE) {
			GeeIterator* _tmp22_ = NULL;
			gboolean _tmp23_ = FALSE;
			GXmlNode* a = NULL;
			GeeIterator* _tmp24_ = NULL;
			gpointer _tmp25_ = NULL;
			GXmlNode* _tmp26_ = NULL;
			gchar* _tmp27_ = NULL;
			gchar* _tmp28_ = NULL;
			gchar* _tmp29_ = NULL;
			const gchar* _tmp30_ = NULL;
			gboolean _tmp31_ = FALSE;
			_tmp22_ = _a_it;
			_tmp23_ = gee_iterator_next (_tmp22_);
			if (!_tmp23_) {
				break;
			}
			_tmp24_ = _a_it;
			_tmp25_ = gee_iterator_get (_tmp24_);
			a = (GXmlNode*) _tmp25_;
			_tmp26_ = a;
			_tmp27_ = gxml_node_get_name (_tmp26_);
			_tmp28_ = _tmp27_;
			_tmp29_ = _tmp28_;
			_tmp30_ = name;
			_tmp31_ = g_strcmp0 (_tmp29_, _tmp30_) == 0;
			_g_free0 (_tmp29_);
			if (_tmp31_) {
				GXmlNode* _tmp32_ = NULL;
				GXmlNamespace* _tmp33_ = NULL;
				GXmlNamespace* _tmp34_ = NULL;
				GXmlNamespace* _tmp35_ = NULL;
				gboolean _tmp36_ = FALSE;
				_tmp32_ = a;
				_tmp33_ = gxml_attribute_get_namespace (G_TYPE_CHECK_INSTANCE_CAST (_tmp32_, GXML_TYPE_ATTRIBUTE, GXmlAttribute));
				_tmp34_ = _tmp33_;
				_tmp35_ = _tmp34_;
				_tmp36_ = _tmp35_ != NULL;
				_g_object_unref0 (_tmp35_);
				if (_tmp36_) {
					GXmlNode* _tmp37_ = NULL;
					GXmlNamespace* _tmp38_ = NULL;
					GXmlNamespace* _tmp39_ = NULL;
					GXmlNamespace* _tmp40_ = NULL;
					gchar* _tmp41_ = NULL;
					gchar* _tmp42_ = NULL;
					gchar* _tmp43_ = NULL;
					const gchar* _tmp44_ = NULL;
					gboolean _tmp45_ = FALSE;
					_tmp37_ = a;
					_tmp38_ = gxml_attribute_get_namespace (G_TYPE_CHECK_INSTANCE_CAST (_tmp37_, GXML_TYPE_ATTRIBUTE, GXmlAttribute));
					_tmp39_ = _tmp38_;
					_tmp40_ = _tmp39_;
					_tmp41_ = gxml_namespace_get_uri (_tmp40_);
					_tmp42_ = _tmp41_;
					_tmp43_ = _tmp42_;
					_tmp44_ = nuri;
					_tmp45_ = g_strcmp0 (_tmp43_, _tmp44_) == 0;
					_g_free0 (_tmp43_);
					_g_object_unref0 (_tmp40_);
					if (_tmp45_) {
						GeeMap* _tmp46_ = NULL;
						GeeMap* _tmp47_ = NULL;
						GeeMap* _tmp48_ = NULL;
						const gchar* _tmp49_ = NULL;
						gchar* _tmp50_ = NULL;
						gchar* _tmp51_ = NULL;
						GXmlNode* _tmp52_ = NULL;
						gchar* _tmp53_ = NULL;
						gchar* _tmp54_ = NULL;
						gchar* _tmp55_ = NULL;
						gchar* _tmp56_ = NULL;
						gchar* _tmp57_ = NULL;
						_tmp46_ = gxml_tnode_get_attrs ((GXmlTNode*) self);
						_tmp47_ = _tmp46_;
						_tmp48_ = _tmp47_;
						_tmp49_ = prefix;
						_tmp50_ = g_strconcat (_tmp49_, ":", NULL);
						_tmp51_ = _tmp50_;
						_tmp52_ = a;
						_tmp53_ = gxml_node_get_name (_tmp52_);
						_tmp54_ = _tmp53_;
						_tmp55_ = _tmp54_;
						_tmp56_ = g_strconcat (_tmp51_, _tmp55_, NULL);
						_tmp57_ = _tmp56_;
						gee_map_unset (_tmp48_, _tmp57_, NULL);
						_g_free0 (_tmp57_);
						_g_free0 (_tmp55_);
						_g_free0 (_tmp51_);
						_g_object_unref0 (_tmp48_);
					}
				}
			}
			_g_object_unref0 (a);
		}
		_g_object_unref0 (_a_it);
	}
	_g_free0 (nuri);
	_g_free0 (prefix);
}


static void gxml_telement_real_normalize (GXmlElement* base) {
	GXmlTElement * self;
	self = (GXmlTElement*) base;
}


static void gxml_telement_calculate_content (GXmlTElement* self) {
	gchar* _tmp0_ = NULL;
	g_return_if_fail (self != NULL);
	_tmp0_ = g_strdup ("");
	_g_free0 (self->priv->_content);
	self->priv->_content = _tmp0_;
	{
		GeeBidirList* _n_list = NULL;
		GeeBidirList* _tmp1_ = NULL;
		GeeBidirList* _tmp2_ = NULL;
		gint _n_size = 0;
		GeeBidirList* _tmp3_ = NULL;
		gint _tmp4_ = 0;
		gint _tmp5_ = 0;
		gint _n_index = 0;
		_tmp1_ = gxml_tnode_get_children_nodes ((GXmlTNode*) self);
		_tmp2_ = _tmp1_;
		_n_list = _tmp2_;
		_tmp3_ = _n_list;
		_tmp4_ = gee_collection_get_size ((GeeCollection*) _tmp3_);
		_tmp5_ = _tmp4_;
		_n_size = _tmp5_;
		_n_index = -1;
		while (TRUE) {
			gint _tmp6_ = 0;
			gint _tmp7_ = 0;
			gint _tmp8_ = 0;
			GXmlNode* n = NULL;
			GeeBidirList* _tmp9_ = NULL;
			gint _tmp10_ = 0;
			gpointer _tmp11_ = NULL;
			GXmlNode* _tmp12_ = NULL;
			_tmp6_ = _n_index;
			_n_index = _tmp6_ + 1;
			_tmp7_ = _n_index;
			_tmp8_ = _n_size;
			if (!(_tmp7_ < _tmp8_)) {
				break;
			}
			_tmp9_ = _n_list;
			_tmp10_ = _n_index;
			_tmp11_ = gee_list_get ((GeeList*) _tmp9_, _tmp10_);
			n = (GXmlNode*) _tmp11_;
			_tmp12_ = n;
			if (G_TYPE_CHECK_INSTANCE_TYPE (_tmp12_, GXML_TYPE_TEXT)) {
				const gchar* _tmp13_ = NULL;
				GXmlNode* _tmp14_ = NULL;
				gchar* _tmp15_ = NULL;
				gchar* _tmp16_ = NULL;
				gchar* _tmp17_ = NULL;
				gchar* _tmp18_ = NULL;
				_tmp13_ = self->priv->_content;
				_tmp14_ = n;
				_tmp15_ = gxml_node_get_value (_tmp14_);
				_tmp16_ = _tmp15_;
				_tmp17_ = _tmp16_;
				_tmp18_ = g_strconcat (_tmp13_, _tmp17_, NULL);
				_g_free0 (self->priv->_content);
				self->priv->_content = _tmp18_;
				_g_free0 (_tmp17_);
			}
			_g_object_unref0 (n);
		}
		_g_object_unref0 (_n_list);
	}
}


static void gxml_telement_update_content (GXmlTElement* self, const gchar* val) {
	const gchar* _tmp22_ = NULL;
	g_return_if_fail (self != NULL);
	{
		gint i = 0;
		i = 0;
		{
			gboolean _tmp0_ = FALSE;
			_tmp0_ = TRUE;
			while (TRUE) {
				gint _tmp2_ = 0;
				GeeBidirList* _tmp3_ = NULL;
				GeeBidirList* _tmp4_ = NULL;
				GeeBidirList* _tmp5_ = NULL;
				gint _tmp6_ = 0;
				gint _tmp7_ = 0;
				gboolean _tmp8_ = FALSE;
				GXmlNode* n = NULL;
				GeeBidirList* _tmp9_ = NULL;
				GeeBidirList* _tmp10_ = NULL;
				GeeBidirList* _tmp11_ = NULL;
				gint _tmp12_ = 0;
				gpointer _tmp13_ = NULL;
				GXmlNode* _tmp14_ = NULL;
				GXmlNode* _tmp15_ = NULL;
				if (!_tmp0_) {
					gint _tmp1_ = 0;
					_tmp1_ = i;
					i = _tmp1_ + 1;
				}
				_tmp0_ = FALSE;
				_tmp2_ = i;
				_tmp3_ = gxml_tnode_get_children_nodes ((GXmlTNode*) self);
				_tmp4_ = _tmp3_;
				_tmp5_ = _tmp4_;
				_tmp6_ = gee_collection_get_size ((GeeCollection*) _tmp5_);
				_tmp7_ = _tmp6_;
				_tmp8_ = !(_tmp2_ < _tmp7_);
				_g_object_unref0 (_tmp5_);
				if (_tmp8_) {
					break;
				}
				_tmp9_ = gxml_tnode_get_children_nodes ((GXmlTNode*) self);
				_tmp10_ = _tmp9_;
				_tmp11_ = _tmp10_;
				_tmp12_ = i;
				_tmp13_ = gee_list_get ((GeeList*) _tmp11_, _tmp12_);
				_tmp14_ = (GXmlNode*) _tmp13_;
				_g_object_unref0 (_tmp11_);
				n = _tmp14_;
				_tmp15_ = n;
				if (G_TYPE_CHECK_INSTANCE_TYPE (_tmp15_, GXML_TYPE_TEXT)) {
					GeeBidirList* _tmp16_ = NULL;
					GeeBidirList* _tmp17_ = NULL;
					GeeBidirList* _tmp18_ = NULL;
					gint _tmp19_ = 0;
					gpointer _tmp20_ = NULL;
					GXmlNode* _tmp21_ = NULL;
					_tmp16_ = gxml_tnode_get_children_nodes ((GXmlTNode*) self);
					_tmp17_ = _tmp16_;
					_tmp18_ = _tmp17_;
					_tmp19_ = i;
					_tmp20_ = gee_list_remove_at ((GeeList*) _tmp18_, _tmp19_);
					_tmp21_ = (GXmlNode*) _tmp20_;
					_g_object_unref0 (_tmp21_);
					_g_object_unref0 (_tmp18_);
				}
				_g_object_unref0 (n);
			}
		}
	}
	_tmp22_ = val;
	if (_tmp22_ != NULL) {
		GXmlNode* t = NULL;
		GXmlDocument* _tmp23_ = NULL;
		GXmlDocument* _tmp24_ = NULL;
		const gchar* _tmp25_ = NULL;
		GXmlNode* _tmp26_ = NULL;
		GeeBidirList* _tmp27_ = NULL;
		GeeBidirList* _tmp28_ = NULL;
		GeeBidirList* _tmp29_ = NULL;
		GXmlNode* _tmp30_ = NULL;
		_tmp23_ = gxml_tnode_get_document ((GXmlTNode*) self);
		_tmp24_ = _tmp23_;
		_tmp25_ = val;
		_tmp26_ = gxml_document_create_text (_tmp24_, _tmp25_);
		t = _tmp26_;
		_tmp27_ = gxml_tnode_get_children_nodes ((GXmlTNode*) self);
		_tmp28_ = _tmp27_;
		_tmp29_ = _tmp28_;
		_tmp30_ = t;
		gee_collection_add ((GeeCollection*) _tmp29_, _tmp30_);
		_g_object_unref0 (_tmp29_);
		_g_object_unref0 (t);
	}
}


static gchar* gxml_telement_real_get_value (GXmlTNode* base) {
	gchar* result;
	GXmlTElement* self;
	const gchar* _tmp0_ = NULL;
	gchar* _tmp1_ = NULL;
	self = (GXmlTElement*) base;
	gxml_telement_calculate_content (self);
	_tmp0_ = self->priv->_content;
	_tmp1_ = g_strdup (_tmp0_);
	result = _tmp1_;
	return result;
}


static void gxml_telement_real_set_value (GXmlTNode* base, const gchar* value) {
	GXmlTElement* self;
	const gchar* _tmp0_ = NULL;
	self = (GXmlTElement*) base;
	_tmp0_ = value;
	gxml_telement_update_content (self, _tmp0_);
	g_object_notify ((GObject *) self, "value");
}


static GeeMap* gxml_telement_real_get_attrs (GXmlTNode* base) {
	GeeMap* result;
	GXmlTElement* self;
	GeeHashMap* _tmp0_ = NULL;
	GeeHashMap* _tmp2_ = NULL;
	GObject* _tmp3_ = NULL;
	GeeMap* _tmp4_ = NULL;
	self = (GXmlTElement*) base;
	_tmp0_ = self->_attrs;
	if (_tmp0_ == NULL) {
		GeeHashMap* _tmp1_ = NULL;
		_tmp1_ = gee_hash_map_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, GXML_TYPE_NODE, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
		_g_object_unref0 (self->_attrs);
		self->_attrs = _tmp1_;
	}
	_tmp2_ = self->_attrs;
	_tmp3_ = g_object_ref ((GObject*) _tmp2_);
	_tmp4_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (_tmp3_, GEE_TYPE_MAP) ? ((GeeMap*) _tmp3_) : NULL);
	result = _tmp4_;
	return result;
}


static GeeBidirList* gxml_telement_real_get_children_nodes (GXmlTNode* base) {
	GeeBidirList* result;
	GXmlTElement* self;
	GXmlTNodeTChildrenList* _tmp0_ = NULL;
	GXmlTNodeTChildrenList* _tmp2_ = NULL;
	GObject* _tmp3_ = NULL;
	GeeBidirList* _tmp4_ = NULL;
	self = (GXmlTElement*) base;
	_tmp0_ = self->_children;
	if (_tmp0_ == NULL) {
		GXmlTNodeTChildrenList* _tmp1_ = NULL;
		_tmp1_ = gxml_tnode_tchildren_list_new ((GXmlNode*) self);
		_g_object_unref0 (self->_children);
		self->_children = _tmp1_;
	}
	_tmp2_ = self->_children;
	_tmp3_ = g_object_ref ((GObject*) _tmp2_);
	_tmp4_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (_tmp3_, GEE_TYPE_BIDIR_LIST) ? ((GeeBidirList*) _tmp3_) : NULL);
	result = _tmp4_;
	return result;
}


static GeeList* gxml_telement_real_get_namespaces (GXmlTNode* base) {
	GeeList* result;
	GXmlTElement* self;
	GeeArrayList* _tmp0_ = NULL;
	GeeArrayList* _tmp2_ = NULL;
	GObject* _tmp3_ = NULL;
	GeeList* _tmp4_ = NULL;
	self = (GXmlTElement*) base;
	_tmp0_ = self->_namespaces;
	if (_tmp0_ == NULL) {
		GeeArrayList* _tmp1_ = NULL;
		_tmp1_ = gee_array_list_new (GXML_TYPE_NODE, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, NULL, NULL, NULL);
		_g_object_unref0 (self->_namespaces);
		self->_namespaces = _tmp1_;
	}
	_tmp2_ = self->_namespaces;
	_tmp3_ = g_object_ref ((GObject*) _tmp2_);
	_tmp4_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (_tmp3_, GEE_TYPE_LIST) ? ((GeeList*) _tmp3_) : NULL);
	result = _tmp4_;
	return result;
}


static gchar* gxml_telement_real_get_content (GXmlElement* base) {
	gchar* result;
	GXmlTElement* self;
	const gchar* _tmp0_ = NULL;
	gchar* _tmp1_ = NULL;
	self = (GXmlTElement*) base;
	gxml_telement_calculate_content (self);
	_tmp0_ = self->priv->_content;
	_tmp1_ = g_strdup (_tmp0_);
	result = _tmp1_;
	return result;
}


static void gxml_telement_real_set_content (GXmlElement* base, const gchar* value) {
	GXmlTElement* self;
	const gchar* _tmp0_ = NULL;
	self = (GXmlTElement*) base;
	_tmp0_ = value;
	gxml_telement_update_content (self, _tmp0_);
	g_object_notify ((GObject *) self, "content");
}


static gchar* gxml_telement_real_get_tag_name (GXmlElement* base) {
	gchar* result;
	GXmlTElement* self;
	gchar* _tmp0_ = NULL;
	gchar* _tmp1_ = NULL;
	self = (GXmlTElement*) base;
	_tmp0_ = gxml_tnode_get_name ((GXmlTNode*) self);
	_tmp1_ = _tmp0_;
	result = _tmp1_;
	return result;
}


static GObject * gxml_telement_constructor (GType type, guint n_construct_properties, GObjectConstructParam * construct_properties) {
	GObject * obj;
	GObjectClass * parent_class;
	GXmlTElement * self;
	parent_class = G_OBJECT_CLASS (gxml_telement_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GXML_TYPE_TELEMENT, GXmlTElement);
	((GXmlTNode*) self)->_node_type = GXML_NODE_TYPE_ELEMENT;
	return obj;
}


static void gxml_telement_class_init (GXmlTElementClass * klass) {
	gxml_telement_parent_class = g_type_class_peek_parent (klass);
	g_type_class_add_private (klass, sizeof (GXmlTElementPrivate));
	GXML_TNODE_CLASS (klass)->get_value = gxml_telement_real_get_value;
	GXML_TNODE_CLASS (klass)->set_value = gxml_telement_real_set_value;
	GXML_TNODE_CLASS (klass)->get_attrs = gxml_telement_real_get_attrs;
	GXML_TNODE_CLASS (klass)->get_children_nodes = gxml_telement_real_get_children_nodes;
	GXML_TNODE_CLASS (klass)->get_namespaces = gxml_telement_real_get_namespaces;
	G_OBJECT_CLASS (klass)->get_property = _vala_gxml_telement_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_gxml_telement_set_property;
	G_OBJECT_CLASS (klass)->constructor = gxml_telement_constructor;
	G_OBJECT_CLASS (klass)->finalize = gxml_telement_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), GXML_TELEMENT_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_TELEMENT_ATTRS, g_param_spec_object ("attrs", "attrs", "attrs", GEE_TYPE_MAP, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GXML_TELEMENT_CHILDREN_NODES, g_param_spec_object ("children-nodes", "children-nodes", "children-nodes", GEE_TYPE_BIDIR_LIST, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GXML_TELEMENT_NAMESPACES, g_param_spec_object ("namespaces", "namespaces", "namespaces", GEE_TYPE_LIST, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GXML_TELEMENT_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_TELEMENT_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_telement_gxml_element_interface_init (GXmlElementIface * iface) {
	gxml_telement_gxml_element_parent_iface = g_type_interface_peek_parent (iface);
	iface->set_attr = (void (*)(GXmlElement*, const gchar*, const gchar*)) gxml_telement_real_set_attr;
	iface->get_attr = (GXmlNode* (*)(GXmlElement*, const gchar*)) gxml_telement_real_get_attr;
	iface->get_ns_attr = (GXmlNode* (*)(GXmlElement*, const gchar*, const gchar*)) gxml_telement_real_get_ns_attr;
	iface->set_ns_attr = (void (*)(GXmlElement*, const gchar*, const gchar*, const gchar*)) gxml_telement_real_set_ns_attr;
	iface->remove_attr = (void (*)(GXmlElement*, const gchar*)) gxml_telement_real_remove_attr;
	iface->remove_ns_attr = (void (*)(GXmlElement*, const gchar*, const gchar*)) gxml_telement_real_remove_ns_attr;
	iface->normalize = (void (*)(GXmlElement*)) gxml_telement_real_normalize;
	iface->get_content = gxml_telement_real_get_content;
	iface->set_content = gxml_telement_real_set_content;
	iface->get_tag_name = gxml_telement_real_get_tag_name;
}


static void gxml_telement_instance_init (GXmlTElement * self) {
	self->priv = GXML_TELEMENT_GET_PRIVATE (self);
	self->priv->_content = NULL;
}


static void gxml_telement_finalize (GObject* obj) {
	GXmlTElement * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GXML_TYPE_TELEMENT, GXmlTElement);
	_g_object_unref0 (self->_attrs);
	_g_object_unref0 (self->_children);
	_g_object_unref0 (self->_namespaces);
	_g_free0 (self->priv->_content);
	G_OBJECT_CLASS (gxml_telement_parent_class)->finalize (obj);
}


/**
 * Class implemeting {@link GXml.Element} interface, not tied to libxml-2.0 library.
 */
GType gxml_telement_get_type (void) {
	static volatile gsize gxml_telement_type_id__volatile = 0;
	if (g_once_init_enter (&gxml_telement_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (GXmlTElementClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) gxml_telement_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GXmlTElement), 0, (GInstanceInitFunc) gxml_telement_instance_init, NULL };
		static const GInterfaceInfo gxml_element_info = { (GInterfaceInitFunc) gxml_telement_gxml_element_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
		GType gxml_telement_type_id;
		gxml_telement_type_id = g_type_register_static (GXML_TYPE_TNODE, "GXmlTElement", &g_define_type_info, 0);
		g_type_add_interface_static (gxml_telement_type_id, GXML_TYPE_ELEMENT, &gxml_element_info);
		g_once_init_leave (&gxml_telement_type_id__volatile, gxml_telement_type_id);
	}
	return gxml_telement_type_id__volatile;
}


static void _vala_gxml_telement_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec) {
	GXmlTElement * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, GXML_TYPE_TELEMENT, GXmlTElement);
	switch (property_id) {
		case GXML_TELEMENT_VALUE:
		g_value_take_string (value, gxml_tnode_get_value ((GXmlTNode*) self));
		break;
		case GXML_TELEMENT_ATTRS:
		g_value_take_object (value, gxml_tnode_get_attrs ((GXmlTNode*) self));
		break;
		case GXML_TELEMENT_CHILDREN_NODES:
		g_value_take_object (value, gxml_tnode_get_children_nodes ((GXmlTNode*) self));
		break;
		case GXML_TELEMENT_NAMESPACES:
		g_value_take_object (value, gxml_tnode_get_namespaces ((GXmlTNode*) self));
		break;
		case GXML_TELEMENT_CONTENT:
		g_value_take_string (value, gxml_element_get_content ((GXmlElement*) self));
		break;
		case GXML_TELEMENT_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_telement_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec) {
	GXmlTElement * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, GXML_TYPE_TELEMENT, GXmlTElement);
	switch (property_id) {
		case GXML_TELEMENT_VALUE:
		gxml_tnode_set_value ((GXmlTNode*) self, g_value_get_string (value));
		break;
		case GXML_TELEMENT_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;
}



