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

/* TDocument.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-object.h>
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include <gee.h>
#include <gio/gio.h>
#include <libxml/xmlwriter.h>
#include <libxml/xmlreader.h>
#include <libxml/tree.h>
#include <glib/gi18n-lib.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;
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;

#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_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;
typedef struct _GXmlTDocumentPrivate GXmlTDocumentPrivate;

#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;
enum  {
	GXML_TDOCUMENT_0_PROPERTY,
	GXML_TDOCUMENT_NAMESPACES_PROPERTY,
	GXML_TDOCUMENT_CHILDREN_NODES_PROPERTY,
	GXML_TDOCUMENT_DOCUMENT_PROPERTY,
	GXML_TDOCUMENT_INDENT_PROPERTY,
	GXML_TDOCUMENT_NS_TOP_PROPERTY,
	GXML_TDOCUMENT_PREFIX_DEFAULT_NS_PROPERTY,
	GXML_TDOCUMENT_BACKUP_PROPERTY,
	GXML_TDOCUMENT_FILE_PROPERTY,
	GXML_TDOCUMENT_ROOT_PROPERTY,
	GXML_TDOCUMENT_NUM_PROPERTIES
};
static GParamSpec* gxml_tdocument_properties[GXML_TDOCUMENT_NUM_PROPERTIES];
typedef enum  {
	GXML_TDOCUMENT_READ_TYPE_NEXT,
	GXML_TDOCUMENT_READ_TYPE_CONTINUE,
	GXML_TDOCUMENT_READ_TYPE_STOP
} GXmlTDocumentReadType;

#define GXML_TDOCUMENT_TYPE_READ_TYPE (gxml_tdocument_read_type_get_type ())
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
typedef GXmlTDocumentReadType (*GXmlTDocumentReadTypeFunc) (GXmlNode* node, xmlTextReader* tr, gpointer user_data);

#define GXML_TYPE_TNAMESPACE (gxml_tnamespace_get_type ())
#define GXML_TNAMESPACE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GXML_TYPE_TNAMESPACE, GXmlTNamespace))
#define GXML_TNAMESPACE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GXML_TYPE_TNAMESPACE, GXmlTNamespaceClass))
#define GXML_IS_TNAMESPACE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GXML_TYPE_TNAMESPACE))
#define GXML_IS_TNAMESPACE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GXML_TYPE_TNAMESPACE))
#define GXML_TNAMESPACE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GXML_TYPE_TNAMESPACE, GXmlTNamespaceClass))

typedef struct _GXmlTNamespace GXmlTNamespace;
typedef struct _GXmlTNamespaceClass GXmlTNamespaceClass;

#define GXML_TYPE_TCOMMENT (gxml_tcomment_get_type ())
#define GXML_TCOMMENT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GXML_TYPE_TCOMMENT, GXmlTComment))
#define GXML_TCOMMENT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GXML_TYPE_TCOMMENT, GXmlTCommentClass))
#define GXML_IS_TCOMMENT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GXML_TYPE_TCOMMENT))
#define GXML_IS_TCOMMENT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GXML_TYPE_TCOMMENT))
#define GXML_TCOMMENT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GXML_TYPE_TCOMMENT, GXmlTCommentClass))

typedef struct _GXmlTComment GXmlTComment;
typedef struct _GXmlTCommentClass GXmlTCommentClass;

#define GXML_TYPE_TPROCESSING_INSTRUCTION (gxml_tprocessing_instruction_get_type ())
#define GXML_TPROCESSING_INSTRUCTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GXML_TYPE_TPROCESSING_INSTRUCTION, GXmlTProcessingInstruction))
#define GXML_TPROCESSING_INSTRUCTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GXML_TYPE_TPROCESSING_INSTRUCTION, GXmlTProcessingInstructionClass))
#define GXML_IS_TPROCESSING_INSTRUCTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GXML_TYPE_TPROCESSING_INSTRUCTION))
#define GXML_IS_TPROCESSING_INSTRUCTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GXML_TYPE_TPROCESSING_INSTRUCTION))
#define GXML_TPROCESSING_INSTRUCTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GXML_TYPE_TPROCESSING_INSTRUCTION, GXmlTProcessingInstructionClass))

typedef struct _GXmlTProcessingInstruction GXmlTProcessingInstruction;
typedef struct _GXmlTProcessingInstructionClass GXmlTProcessingInstructionClass;

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

#define GXML_TYPE_TTEXT (gxml_ttext_get_type ())
#define GXML_TTEXT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GXML_TYPE_TTEXT, GXmlTText))
#define GXML_TTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GXML_TYPE_TTEXT, GXmlTTextClass))
#define GXML_IS_TTEXT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GXML_TYPE_TTEXT))
#define GXML_IS_TTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GXML_TYPE_TTEXT))
#define GXML_TTEXT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GXML_TYPE_TTEXT, GXmlTTextClass))

typedef struct _GXmlTText GXmlTText;
typedef struct _GXmlTTextClass GXmlTTextClass;

#define GXML_TYPE_TCDATA (gxml_tcdata_get_type ())
#define GXML_TCDATA(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GXML_TYPE_TCDATA, GXmlTCDATA))
#define GXML_TCDATA_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GXML_TYPE_TCDATA, GXmlTCDATAClass))
#define GXML_IS_TCDATA(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GXML_TYPE_TCDATA))
#define GXML_IS_TCDATA_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GXML_TYPE_TCDATA))
#define GXML_TCDATA_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GXML_TYPE_TCDATA, GXmlTCDATAClass))

typedef struct _GXmlTCDATA GXmlTCDATA;
typedef struct _GXmlTCDATAClass GXmlTCDATAClass;
#define _xmlFreeTextWriter0(var) ((var == NULL) ? NULL : (var = (xmlFreeTextWriter (var), NULL)))
#define _xmlBufferFree0(var) ((var == NULL) ? NULL : (var = (xmlBufferFree (var), NULL)))
#define _g_string_free0(var) ((var == NULL) ? NULL : (var = (g_string_free (var, TRUE), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))

#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 GXML_TYPE_COMMENT (gxml_comment_get_type ())
#define GXML_COMMENT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GXML_TYPE_COMMENT, GXmlComment))
#define GXML_IS_COMMENT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GXML_TYPE_COMMENT))
#define GXML_COMMENT_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), GXML_TYPE_COMMENT, GXmlCommentIface))

typedef struct _GXmlComment GXmlComment;
typedef struct _GXmlCommentIface GXmlCommentIface;

#define GXML_TYPE_CDATA (gxml_cdata_get_type ())
#define GXML_CDATA(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GXML_TYPE_CDATA, GXmlCDATA))
#define GXML_IS_CDATA(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GXML_TYPE_CDATA))
#define GXML_CDATA_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), GXML_TYPE_CDATA, GXmlCDATAIface))

typedef struct _GXmlCDATA GXmlCDATA;
typedef struct _GXmlCDATAIface GXmlCDATAIface;

#define GXML_TYPE_PROCESSING_INSTRUCTION (gxml_processing_instruction_get_type ())
#define GXML_PROCESSING_INSTRUCTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GXML_TYPE_PROCESSING_INSTRUCTION, GXmlProcessingInstruction))
#define GXML_IS_PROCESSING_INSTRUCTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GXML_TYPE_PROCESSING_INSTRUCTION))
#define GXML_PROCESSING_INSTRUCTION_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), GXML_TYPE_PROCESSING_INSTRUCTION, GXmlProcessingInstructionIface))

typedef struct _GXmlProcessingInstruction GXmlProcessingInstruction;
typedef struct _GXmlProcessingInstructionIface GXmlProcessingInstructionIface;
#define _xmlFreeDoc0(var) ((var == NULL) ? NULL : (var = (xmlFreeDoc (var), NULL)))
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
#define _xmlFreeTextReader0(var) ((var == NULL) ? NULL : (var = (xmlFreeTextReader (var), NULL)))
#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);
};

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 _GXmlTDocument {
	GXmlTNode parent_instance;
	GXmlTDocumentPrivate * priv;
	GeeArrayList* _namespaces;
	GeeArrayList* _children;
};

struct _GXmlTDocumentClass {
	GXmlTNodeClass parent_class;
};

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 _GXmlTDocumentPrivate {
	GXmlElement* _root;
	gboolean _indent;
	gboolean _ns_top;
	gboolean _prefix_default_ns;
	gboolean _backup;
	GFile* _file;
};

typedef enum  {
	GXML_ERROR_NOT_SUPPORTED,
	GXML_ERROR_PARSER,
	GXML_ERROR_WRITER
} GXmlError;
#define GXML_ERROR gxml_error_quark ()
struct _GXmlTextIface {
	GTypeInterface parent_iface;
	gchar* (*get_str) (GXmlText* self);
	void (*set_str) (GXmlText* self, const gchar* value);
};

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

struct _GXmlCDATAIface {
	GTypeInterface parent_iface;
	gchar* (*get_str) (GXmlCDATA* self);
};

struct _GXmlProcessingInstructionIface {
	GTypeInterface parent_iface;
	gchar* (*get_target) (GXmlProcessingInstruction* self);
	gchar* (*get_data) (GXmlProcessingInstruction* self);
	void (*set_data) (GXmlProcessingInstruction* self, const gchar* value);
};

typedef enum  {
	GXML_DOCUMENT_ERROR_INVALID_DOCUMENT_ERROR,
	GXML_DOCUMENT_ERROR_INVALID_FILE
} GXmlDocumentError;
#define GXML_DOCUMENT_ERROR gxml_document_error_quark ()

static gint GXmlTDocument_private_offset;
static gpointer gxml_tdocument_parent_class = NULL;
static GXmlDocumentIface * gxml_tdocument_gxml_document_parent_iface = NULL;

GType gxml_element_list_get_type (void) G_GNUC_CONST;
GType gxml_namespace_get_type (void) G_GNUC_CONST;
GType gxml_node_type_get_type (void) G_GNUC_CONST;
GType gxml_document_get_type (void) G_GNUC_CONST;
GType gxml_node_get_type (void) G_GNUC_CONST;
GType gxml_tnode_get_type (void) G_GNUC_CONST;
GType gxml_tdocument_get_type (void) G_GNUC_CONST;
GType gxml_element_get_type (void) G_GNUC_CONST;
GType gxml_tdocument_read_type_get_type (void) G_GNUC_CONST;
GXmlTDocument* gxml_tdocument_new (void);
GXmlTDocument* gxml_tdocument_construct (GType object_type);
GXmlTNode* gxml_tnode_construct (GType object_type);
GXmlTDocument* gxml_tdocument_new_from_path (const gchar* path);
GXmlTDocument* gxml_tdocument_construct_from_path (GType object_type,
                                                   const gchar* path);
void gxml_document_set_file (GXmlDocument* self,
                             GFile* value);
GFile* gxml_document_get_file (GXmlDocument* self);
void gxml_tdocument_read_doc (GXmlDocument* doc,
                              GFile* file,
                              GXmlTDocumentReadTypeFunc rtfunc,
                              gpointer rtfunc_target,
                              GError** error);
GXmlTDocument* gxml_tdocument_new_from_uri (const gchar* uri);
GXmlTDocument* gxml_tdocument_construct_from_uri (GType object_type,
                                                  const gchar* uri);
GXmlTDocument* gxml_tdocument_new_from_file (GFile* file);
GXmlTDocument* gxml_tdocument_construct_from_file (GType object_type,
                                                   GFile* file);
GXmlTDocument* gxml_tdocument_new_from_stream (GInputStream* stream);
GXmlTDocument* gxml_tdocument_construct_from_stream (GType object_type,
                                                     GInputStream* stream);
void gxml_tdocument_read_doc_stream (GXmlDocument* doc,
                                     GInputStream* istream,
                                     GXmlTDocumentReadTypeFunc rtfunc,
                                     gpointer rtfunc_target,
                                     GError** error);
GXmlTDocument* gxml_tdocument_new_from_string (const gchar* str);
GXmlTDocument* gxml_tdocument_construct_from_string (GType object_type,
                                                     const gchar* str);
GXmlTDocument* gxml_tdocument_new_from_path_with_readtype_func (const gchar* path,
                                                                GXmlTDocumentReadTypeFunc func,
                                                                gpointer func_target);
GXmlTDocument* gxml_tdocument_construct_from_path_with_readtype_func (GType object_type,
                                                                      const gchar* path,
                                                                      GXmlTDocumentReadTypeFunc func,
                                                                      gpointer func_target);
GXmlTDocument* gxml_tdocument_new_from_uri_with_readtype_func (const gchar* uri,
                                                               GXmlTDocumentReadTypeFunc func,
                                                               gpointer func_target);
GXmlTDocument* gxml_tdocument_construct_from_uri_with_readtype_func (GType object_type,
                                                                     const gchar* uri,
                                                                     GXmlTDocumentReadTypeFunc func,
                                                                     gpointer func_target);
GXmlTDocument* gxml_tdocument_new_from_file_with_readtype_func (GFile* file,
                                                                GXmlTDocumentReadTypeFunc func,
                                                                gpointer func_target);
GXmlTDocument* gxml_tdocument_construct_from_file_with_readtype_func (GType object_type,
                                                                      GFile* file,
                                                                      GXmlTDocumentReadTypeFunc func,
                                                                      gpointer func_target);
GXmlTDocument* gxml_tdocument_new_from_stream_with_readtype_func (GInputStream* stream,
                                                                  GXmlTDocumentReadTypeFunc func,
                                                                  gpointer func_target);
GXmlTDocument* gxml_tdocument_construct_from_stream_with_readtype_func (GType object_type,
                                                                        GInputStream* stream,
                                                                        GXmlTDocumentReadTypeFunc func,
                                                                        gpointer func_target);
GXmlTDocument* gxml_tdocument_new_from_string_with_readtype_func (const gchar* str,
                                                                  GXmlTDocumentReadTypeFunc func,
                                                                  gpointer func_target);
GXmlTDocument* gxml_tdocument_construct_from_string_with_readtype_func (GType object_type,
                                                                        const gchar* str,
                                                                        GXmlTDocumentReadTypeFunc func,
                                                                        gpointer func_target);
static gboolean gxml_tdocument_real_set_namespace (GXmlTNode* base,
                                            const gchar* uri,
                                            const gchar* prefix);
GXmlTNamespace* gxml_tnamespace_new (GXmlDocument* d,
                                     const gchar* uri,
                                     const gchar* prefix);
GXmlTNamespace* gxml_tnamespace_construct (GType object_type,
                                           GXmlDocument* d,
                                           const gchar* uri,
                                           const gchar* prefix);
GType gxml_tnamespace_get_type (void) G_GNUC_CONST;
static GXmlNode* gxml_tdocument_real_create_comment (GXmlDocument* base,
                                              const gchar* text);
GType gxml_tcomment_get_type (void) G_GNUC_CONST;
GXmlTComment* gxml_tcomment_new (GXmlDocument* doc,
                                 const gchar* text);
GXmlTComment* gxml_tcomment_construct (GType object_type,
                                       GXmlDocument* doc,
                                       const gchar* text);
static GXmlNode* gxml_tdocument_real_create_pi (GXmlDocument* base,
                                         const gchar* target,
                                         const gchar* data);
GType gxml_tprocessing_instruction_get_type (void) G_GNUC_CONST;
GXmlTProcessingInstruction* gxml_tprocessing_instruction_new (GXmlDocument* doc,
                                                              const gchar* target,
                                                              const gchar* data);
GXmlTProcessingInstruction* gxml_tprocessing_instruction_construct (GType object_type,
                                                                    GXmlDocument* doc,
                                                                    const gchar* target,
                                                                    const gchar* data);
static GXmlNode* gxml_tdocument_real_create_element (GXmlDocument* base,
                                              const gchar* name,
                                              GError** error);
GQuark gxml_error_quark (void);
GXmlTElement* gxml_telement_new (GXmlDocument* d,
                                 const gchar* name);
GXmlTElement* gxml_telement_construct (GType object_type,
                                       GXmlDocument* d,
                                       const gchar* name);
GType gxml_telement_get_type (void) G_GNUC_CONST;
static GXmlNode* gxml_tdocument_real_create_text (GXmlDocument* base,
                                           const gchar* text);
GType gxml_ttext_get_type (void) G_GNUC_CONST;
GXmlTText* gxml_ttext_new (GXmlDocument* d,
                           const gchar* text);
GXmlTText* gxml_ttext_construct (GType object_type,
                                 GXmlDocument* d,
                                 const gchar* text);
static GXmlNode* gxml_tdocument_real_create_cdata (GXmlDocument* base,
                                            const gchar* text);
GType gxml_tcdata_get_type (void) G_GNUC_CONST;
GXmlTCDATA* gxml_tcdata_new (GXmlDocument* d,
                             const gchar* text);
GXmlTCDATA* gxml_tcdata_construct (GType object_type,
                                   GXmlDocument* d,
                                   const gchar* text);
static gboolean gxml_tdocument_real_save (GXmlDocument* base,
                                   GCancellable* cancellable,
                                   GError** error);
gboolean gxml_document_save_as (GXmlDocument* self,
                                GFile* f,
                                GCancellable* cancellable,
                                GError** error);
gboolean gxml_tdocument_save_to (GXmlTDocument* self,
                                 GFile* f,
                                 GCancellable* cancellable,
                                 GError** error) G_GNUC_DEPRECATED;
static gboolean gxml_tdocument_real_save_as (GXmlDocument* base,
                                      GFile* f,
                                      GCancellable* cancellable,
                                      GError** error);
gboolean gxml_tdocument_tw_save_as (GXmlDocument* doc,
                                    GFile* f,
                                    GCancellable* cancellable,
                                    GError** error);
void gxml_tdocument_write_document (GXmlDocument* doc,
                                    xmlTextWriter* tw,
                                    GError** error);
static guint8* _vala_array_dup3 (guint8* self,
                          int length);
gboolean gxml_document_get_backup (GXmlDocument* self);
gboolean gxml_document_get_indent (GXmlDocument* self);
GXmlNode* gxml_document_get_root (GXmlDocument* self);
void gxml_tdocument_start_node (GXmlDocument* doc,
                                xmlTextWriter* tw,
                                GXmlNode* node,
                                gboolean root,
                                GeeArrayList* * declared_ns,
                                GError** error);
GXmlDocument* gxml_node_get_document (GXmlNode* self);
GeeList* gxml_node_get_namespaces (GXmlNode* self);
gboolean gxml_document_get_prefix_default_ns (GXmlDocument* self);
gchar* gxml_namespace_get_prefix (GXmlNamespace* self);
gchar* gxml_node_get_name (GXmlNode* self);
gchar* gxml_namespace_get_uri (GXmlNamespace* self);
gboolean gxml_document_get_ns_top (GXmlDocument* self);
gchar* gxml_node_ns_uri (GXmlNode* self);
gchar* gxml_node_ns_prefix (GXmlNode* self);
GeeMap* gxml_node_get_attrs (GXmlNode* self);
gchar* gxml_node_get_value (GXmlNode* self);
GeeBidirList* gxml_node_get_children_nodes (GXmlNode* self);
gboolean gxml_node_set_namespace (GXmlNode* self,
                                  const gchar* uri,
                                  const gchar* prefix);
GType gxml_text_get_type (void) G_GNUC_CONST;
GType gxml_comment_get_type (void) G_GNUC_CONST;
GType gxml_cdata_get_type (void) G_GNUC_CONST;
GType gxml_processing_instruction_get_type (void) G_GNUC_CONST;
gchar* gxml_processing_instruction_get_target (GXmlProcessingInstruction* self);
gchar* gxml_processing_instruction_get_data (GXmlProcessingInstruction* self);
static gchar* gxml_tdocument_real_to_string (GXmlTNode* base);
GQuark gxml_document_error_quark (void);
GXmlTDocumentReadType gxml_tdocument_read_node (GXmlNode* node,
                                                xmlTextReader* tr,
                                                GXmlTDocumentReadTypeFunc rntfunc,
                                                gpointer rntfunc_target,
                                                GError** error);
GXmlNode* gxml_document_create_element (GXmlDocument* self,
                                        const gchar* name,
                                        GError** error);
void gxml_element_set_ns_attr (GXmlElement* self,
                               const gchar* ns,
                               const gchar* name,
                               const gchar* value);
void gxml_element_set_attr (GXmlElement* self,
                            const gchar* name,
                            const gchar* value);
GXmlNode* gxml_document_create_text (GXmlDocument* self,
                                     const gchar* text);
GXmlNode* gxml_document_create_cdata (GXmlDocument* self,
                                      const gchar* text);
GXmlNode* gxml_document_create_pi (GXmlDocument* self,
                                   const gchar* target,
                                   const gchar* data);
GXmlNode* gxml_document_create_comment (GXmlDocument* self,
                                        const gchar* text);
GeeBidirList* gxml_tnode_get_children_nodes (GXmlTNode* self);
static GObject * gxml_tdocument_constructor (GType type,
                                      guint n_construct_properties,
                                      GObjectConstructParam * construct_properties);
static void gxml_tdocument_finalize (GObject * obj);
GeeList* gxml_tnode_get_namespaces (GXmlTNode* self);
GXmlDocument* gxml_tnode_get_document (GXmlTNode* self);
static void _vala_gxml_tdocument_get_property (GObject * object,
                                        guint property_id,
                                        GValue * value,
                                        GParamSpec * pspec);
void gxml_document_set_indent (GXmlDocument* self,
                               gboolean value);
void gxml_document_set_ns_top (GXmlDocument* self,
                               gboolean value);
void gxml_document_set_prefix_default_ns (GXmlDocument* self,
                                          gboolean value);
void gxml_document_set_backup (GXmlDocument* self,
                               gboolean value);
static void _vala_gxml_tdocument_set_property (GObject * object,
                                        guint property_id,
                                        const GValue * value,
                                        GParamSpec * pspec);

static inline gpointer
gxml_tdocument_get_instance_private (GXmlTDocument* self)
{
	return G_STRUCT_MEMBER_P (self, GXmlTDocument_private_offset);
}

/**
   * Enum for {@link Xml.TextReader} flag on parsing.
   */
GType
gxml_tdocument_read_type_get_type (void)
{
	static volatile gsize gxml_tdocument_read_type_type_id__volatile = 0;
	if (g_once_init_enter (&gxml_tdocument_read_type_type_id__volatile)) {
		static const GEnumValue values[] = {{GXML_TDOCUMENT_READ_TYPE_NEXT, "GXML_TDOCUMENT_READ_TYPE_NEXT", "next"}, {GXML_TDOCUMENT_READ_TYPE_CONTINUE, "GXML_TDOCUMENT_READ_TYPE_CONTINUE", "continue"}, {GXML_TDOCUMENT_READ_TYPE_STOP, "GXML_TDOCUMENT_READ_TYPE_STOP", "stop"}, {0, NULL, NULL}};
		GType gxml_tdocument_read_type_type_id;
		gxml_tdocument_read_type_type_id = g_enum_register_static ("GXmlTDocumentReadType", values);
		g_once_init_leave (&gxml_tdocument_read_type_type_id__volatile, gxml_tdocument_read_type_type_id);
	}
	return gxml_tdocument_read_type_type_id__volatile;
}

GXmlTDocument*
gxml_tdocument_construct (GType object_type)
{
	GXmlTDocument * self = NULL;
	self = (GXmlTDocument*) gxml_tnode_construct (object_type);
	return self;
}

GXmlTDocument*
gxml_tdocument_new (void)
{
	return gxml_tdocument_construct (GXML_TYPE_TDOCUMENT);
}

GXmlTDocument*
gxml_tdocument_construct_from_path (GType object_type,
                                    const gchar* path)
{
	GXmlTDocument * self = NULL;
	GFile* _tmp0_;
	GFile* _tmp1_;
	GFile* _tmp2_;
	GFile* _tmp3_;
	GError* _inner_error0_ = NULL;
	g_return_val_if_fail (path != NULL, NULL);
	self = (GXmlTDocument*) gxml_tnode_construct (object_type);
	_tmp0_ = g_file_new_for_path (path);
	_tmp1_ = _tmp0_;
	gxml_document_set_file ((GXmlDocument*) self, _tmp1_);
	_g_object_unref0 (_tmp1_);
	_tmp2_ = gxml_document_get_file ((GXmlDocument*) self);
	_tmp3_ = _tmp2_;
	if (!g_file_query_exists (_tmp3_, NULL)) {
		return self;
	}
	{
		GFile* _tmp4_;
		GFile* _tmp5_;
		_tmp4_ = gxml_document_get_file ((GXmlDocument*) self);
		_tmp5_ = _tmp4_;
		gxml_tdocument_read_doc ((GXmlDocument*) self, _tmp5_, NULL, NULL, &_inner_error0_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch3_g_error;
		}
	}
	goto __finally3;
	__catch3_g_error:
	{
		g_clear_error (&_inner_error0_);
		_inner_error0_ = NULL;
	}
	__finally3:
	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 NULL;
	}
	return self;
}

GXmlTDocument*
gxml_tdocument_new_from_path (const gchar* path)
{
	return gxml_tdocument_construct_from_path (GXML_TYPE_TDOCUMENT, path);
}

GXmlTDocument*
gxml_tdocument_construct_from_uri (GType object_type,
                                   const gchar* uri)
{
	GXmlTDocument * self = NULL;
	GFile* _tmp0_;
	GFile* _tmp1_;
	g_return_val_if_fail (uri != NULL, NULL);
	_tmp0_ = g_file_new_for_uri (uri);
	_tmp1_ = _tmp0_;
	self = (GXmlTDocument*) gxml_tdocument_construct_from_file (object_type, _tmp1_);
	_g_object_unref0 (_tmp1_);
	return self;
}

GXmlTDocument*
gxml_tdocument_new_from_uri (const gchar* uri)
{
	return gxml_tdocument_construct_from_uri (GXML_TYPE_TDOCUMENT, uri);
}

GXmlTDocument*
gxml_tdocument_construct_from_file (GType object_type,
                                    GFile* file)
{
	GXmlTDocument * self = NULL;
	GError* _inner_error0_ = NULL;
	g_return_val_if_fail (file != NULL, NULL);
	self = (GXmlTDocument*) gxml_tnode_construct (object_type);
	if (!g_file_query_exists (file, NULL)) {
		return self;
	}
	{
		gxml_tdocument_read_doc ((GXmlDocument*) self, file, NULL, NULL, &_inner_error0_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch4_g_error;
		}
	}
	goto __finally4;
	__catch4_g_error:
	{
		g_clear_error (&_inner_error0_);
		_inner_error0_ = NULL;
	}
	__finally4:
	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 NULL;
	}
	gxml_document_set_file ((GXmlDocument*) self, file);
	return self;
}

GXmlTDocument*
gxml_tdocument_new_from_file (GFile* file)
{
	return gxml_tdocument_construct_from_file (GXML_TYPE_TDOCUMENT, file);
}

GXmlTDocument*
gxml_tdocument_construct_from_stream (GType object_type,
                                      GInputStream* stream)
{
	GXmlTDocument * self = NULL;
	GError* _inner_error0_ = NULL;
	g_return_val_if_fail (stream != NULL, NULL);
	self = (GXmlTDocument*) gxml_tnode_construct (object_type);
	{
		gxml_tdocument_read_doc_stream ((GXmlDocument*) self, stream, NULL, NULL, &_inner_error0_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch5_g_error;
		}
	}
	goto __finally5;
	__catch5_g_error:
	{
		g_clear_error (&_inner_error0_);
		_inner_error0_ = NULL;
	}
	__finally5:
	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 NULL;
	}
	return self;
}

GXmlTDocument*
gxml_tdocument_new_from_stream (GInputStream* stream)
{
	return gxml_tdocument_construct_from_stream (GXML_TYPE_TDOCUMENT, stream);
}

GXmlTDocument*
gxml_tdocument_construct_from_string (GType object_type,
                                      const gchar* str)
{
	GXmlTDocument * self = NULL;
	GMemoryInputStream* minput = NULL;
	GMemoryInputStream* _tmp0_;
	gchar* _tmp1_;
	g_return_val_if_fail (str != NULL, NULL);
	_tmp0_ = (GMemoryInputStream*) g_memory_input_stream_new ();
	minput = _tmp0_;
	_tmp1_ = g_strdup (str);
	g_memory_input_stream_add_data (minput, (guint8*) _tmp1_, (gssize) -1, NULL);
	self = (GXmlTDocument*) gxml_tdocument_construct_from_stream (object_type, (GInputStream*) minput);
	_g_object_unref0 (minput);
	return self;
}

GXmlTDocument*
gxml_tdocument_new_from_string (const gchar* str)
{
	return gxml_tdocument_construct_from_string (GXML_TYPE_TDOCUMENT, str);
}

GXmlTDocument*
gxml_tdocument_construct_from_path_with_readtype_func (GType object_type,
                                                       const gchar* path,
                                                       GXmlTDocumentReadTypeFunc func,
                                                       gpointer func_target)
{
	GXmlTDocument * self = NULL;
	GFile* _tmp0_;
	GFile* _tmp1_;
	GFile* _tmp2_;
	GFile* _tmp3_;
	GError* _inner_error0_ = NULL;
	g_return_val_if_fail (path != NULL, NULL);
	self = (GXmlTDocument*) gxml_tnode_construct (object_type);
	_tmp0_ = g_file_new_for_path (path);
	_tmp1_ = _tmp0_;
	gxml_document_set_file ((GXmlDocument*) self, _tmp1_);
	_g_object_unref0 (_tmp1_);
	_tmp2_ = gxml_document_get_file ((GXmlDocument*) self);
	_tmp3_ = _tmp2_;
	if (!g_file_query_exists (_tmp3_, NULL)) {
		return self;
	}
	{
		GFile* _tmp4_;
		GFile* _tmp5_;
		_tmp4_ = gxml_document_get_file ((GXmlDocument*) self);
		_tmp5_ = _tmp4_;
		gxml_tdocument_read_doc ((GXmlDocument*) self, _tmp5_, func, func_target, &_inner_error0_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch6_g_error;
		}
	}
	goto __finally6;
	__catch6_g_error:
	{
		g_clear_error (&_inner_error0_);
		_inner_error0_ = NULL;
	}
	__finally6:
	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 NULL;
	}
	return self;
}

GXmlTDocument*
gxml_tdocument_new_from_path_with_readtype_func (const gchar* path,
                                                 GXmlTDocumentReadTypeFunc func,
                                                 gpointer func_target)
{
	return gxml_tdocument_construct_from_path_with_readtype_func (GXML_TYPE_TDOCUMENT, path, func, func_target);
}

GXmlTDocument*
gxml_tdocument_construct_from_uri_with_readtype_func (GType object_type,
                                                      const gchar* uri,
                                                      GXmlTDocumentReadTypeFunc func,
                                                      gpointer func_target)
{
	GXmlTDocument * self = NULL;
	GFile* _tmp0_;
	GFile* _tmp1_;
	g_return_val_if_fail (uri != NULL, NULL);
	_tmp0_ = g_file_new_for_uri (uri);
	_tmp1_ = _tmp0_;
	self = (GXmlTDocument*) gxml_tdocument_construct_from_file_with_readtype_func (object_type, _tmp1_, func, func_target);
	_g_object_unref0 (_tmp1_);
	return self;
}

GXmlTDocument*
gxml_tdocument_new_from_uri_with_readtype_func (const gchar* uri,
                                                GXmlTDocumentReadTypeFunc func,
                                                gpointer func_target)
{
	return gxml_tdocument_construct_from_uri_with_readtype_func (GXML_TYPE_TDOCUMENT, uri, func, func_target);
}

GXmlTDocument*
gxml_tdocument_construct_from_file_with_readtype_func (GType object_type,
                                                       GFile* file,
                                                       GXmlTDocumentReadTypeFunc func,
                                                       gpointer func_target)
{
	GXmlTDocument * self = NULL;
	GError* _inner_error0_ = NULL;
	g_return_val_if_fail (file != NULL, NULL);
	self = (GXmlTDocument*) gxml_tnode_construct (object_type);
	if (!g_file_query_exists (file, NULL)) {
		return self;
	}
	{
		gxml_tdocument_read_doc ((GXmlDocument*) self, file, func, func_target, &_inner_error0_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch7_g_error;
		}
	}
	goto __finally7;
	__catch7_g_error:
	{
		g_clear_error (&_inner_error0_);
		_inner_error0_ = NULL;
	}
	__finally7:
	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 NULL;
	}
	gxml_document_set_file ((GXmlDocument*) self, file);
	return self;
}

GXmlTDocument*
gxml_tdocument_new_from_file_with_readtype_func (GFile* file,
                                                 GXmlTDocumentReadTypeFunc func,
                                                 gpointer func_target)
{
	return gxml_tdocument_construct_from_file_with_readtype_func (GXML_TYPE_TDOCUMENT, file, func, func_target);
}

GXmlTDocument*
gxml_tdocument_construct_from_stream_with_readtype_func (GType object_type,
                                                         GInputStream* stream,
                                                         GXmlTDocumentReadTypeFunc func,
                                                         gpointer func_target)
{
	GXmlTDocument * self = NULL;
	GError* _inner_error0_ = NULL;
	g_return_val_if_fail (stream != NULL, NULL);
	self = (GXmlTDocument*) gxml_tnode_construct (object_type);
	{
		gxml_tdocument_read_doc_stream ((GXmlDocument*) self, stream, func, func_target, &_inner_error0_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch8_g_error;
		}
	}
	goto __finally8;
	__catch8_g_error:
	{
		g_clear_error (&_inner_error0_);
		_inner_error0_ = NULL;
	}
	__finally8:
	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 NULL;
	}
	return self;
}

GXmlTDocument*
gxml_tdocument_new_from_stream_with_readtype_func (GInputStream* stream,
                                                   GXmlTDocumentReadTypeFunc func,
                                                   gpointer func_target)
{
	return gxml_tdocument_construct_from_stream_with_readtype_func (GXML_TYPE_TDOCUMENT, stream, func, func_target);
}

GXmlTDocument*
gxml_tdocument_construct_from_string_with_readtype_func (GType object_type,
                                                         const gchar* str,
                                                         GXmlTDocumentReadTypeFunc func,
                                                         gpointer func_target)
{
	GXmlTDocument * self = NULL;
	GMemoryInputStream* minput = NULL;
	GMemoryInputStream* _tmp0_;
	gchar* _tmp1_;
	g_return_val_if_fail (str != NULL, NULL);
	_tmp0_ = (GMemoryInputStream*) g_memory_input_stream_new ();
	minput = _tmp0_;
	_tmp1_ = g_strdup (str);
	g_memory_input_stream_add_data (minput, (guint8*) _tmp1_, (gssize) -1, NULL);
	self = (GXmlTDocument*) gxml_tdocument_construct_from_stream_with_readtype_func (object_type, (GInputStream*) minput, func, func_target);
	_g_object_unref0 (minput);
	return self;
}

GXmlTDocument*
gxml_tdocument_new_from_string_with_readtype_func (const gchar* str,
                                                   GXmlTDocumentReadTypeFunc func,
                                                   gpointer func_target)
{
	return gxml_tdocument_construct_from_string_with_readtype_func (GXML_TYPE_TDOCUMENT, str, func, func_target);
}

/**
   * {@inheritDoc}
   *
   * All namespaces are stored at {@link GXml.Node.namespaces} owned by
   * this {@link GXml.TDocument}.
   *
   * First namespace at list, is considered default one for the document. If
   * you haven't declared a namespace for this document or for its root element,
   * and you define one for a child node, this one is added for the first time
   * to document's namespaces, then this becomes the default namespace. To avoid
   * this, you should set a namespace for documento or its root, then children.
   *
   * Default {@link GXml.Namespace} for a document is the first
   */
static gboolean
gxml_tdocument_real_set_namespace (GXmlTNode* base,
                                   const gchar* uri,
                                   const gchar* prefix)
{
	GXmlTDocument * self;
	gboolean result = FALSE;
	GeeArrayList* _tmp0_;
	GeeArrayList* _tmp2_;
	GXmlTNamespace* _tmp3_;
	GXmlTNamespace* _tmp4_;
	self = (GXmlTDocument*) base;
	g_return_val_if_fail (uri != NULL, FALSE);
	_tmp0_ = self->_namespaces;
	if (_tmp0_ == NULL) {
		GeeArrayList* _tmp1_;
		_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_ = gxml_tnamespace_new ((GXmlDocument*) self, uri, prefix);
	_tmp4_ = _tmp3_;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp2_, (GXmlNode*) _tmp4_);
	_g_object_unref0 (_tmp4_);
	result = TRUE;
	return result;
}

static GXmlNode*
gxml_tdocument_real_create_comment (GXmlDocument* base,
                                    const gchar* text)
{
	GXmlTDocument * self;
	GXmlNode* result = NULL;
	GXmlTComment* c = NULL;
	GXmlTComment* _tmp0_;
	self = (GXmlTDocument*) base;
	g_return_val_if_fail (text != NULL, NULL);
	_tmp0_ = gxml_tcomment_new ((GXmlDocument*) self, text);
	c = _tmp0_;
	result = (GXmlNode*) c;
	return result;
}

static GXmlNode*
gxml_tdocument_real_create_pi (GXmlDocument* base,
                               const gchar* target,
                               const gchar* data)
{
	GXmlTDocument * self;
	GXmlNode* result = NULL;
	GXmlTProcessingInstruction* pi = NULL;
	GXmlTProcessingInstruction* _tmp0_;
	self = (GXmlTDocument*) base;
	g_return_val_if_fail (target != NULL, NULL);
	g_return_val_if_fail (data != NULL, NULL);
	_tmp0_ = gxml_tprocessing_instruction_new ((GXmlDocument*) self, target, data);
	pi = _tmp0_;
	result = (GXmlNode*) pi;
	return result;
}

static GXmlNode*
gxml_tdocument_real_create_element (GXmlDocument* base,
                                    const gchar* name,
                                    GError** error)
{
	GXmlTDocument * self;
	GXmlNode* result = NULL;
	GXmlTElement* _tmp1_;
	GError* _inner_error0_ = NULL;
	self = (GXmlTDocument*) base;
	g_return_val_if_fail (name != NULL, NULL);
	if (xmlValidateName ((const xmlChar*) name, FALSE) != 0) {
		GError* _tmp0_;
		_tmp0_ = g_error_new_literal (GXML_ERROR, GXML_ERROR_PARSER, _ ("Invalid element name"));
		_inner_error0_ = _tmp0_;
		g_propagate_error (error, _inner_error0_);
		return NULL;
	}
	_tmp1_ = gxml_telement_new ((GXmlDocument*) self, name);
	result = (GXmlNode*) _tmp1_;
	return result;
}

static GXmlNode*
gxml_tdocument_real_create_text (GXmlDocument* base,
                                 const gchar* text)
{
	GXmlTDocument * self;
	GXmlNode* result = NULL;
	GXmlTText* t = NULL;
	GXmlTText* _tmp0_;
	self = (GXmlTDocument*) base;
	g_return_val_if_fail (text != NULL, NULL);
	_tmp0_ = gxml_ttext_new ((GXmlDocument*) self, text);
	t = _tmp0_;
	result = (GXmlNode*) t;
	return result;
}

static GXmlNode*
gxml_tdocument_real_create_cdata (GXmlDocument* base,
                                  const gchar* text)
{
	GXmlTDocument * self;
	GXmlNode* result = NULL;
	GXmlTCDATA* t = NULL;
	GXmlTCDATA* _tmp0_;
	self = (GXmlTDocument*) base;
	g_return_val_if_fail (text != NULL, NULL);
	_tmp0_ = gxml_tcdata_new ((GXmlDocument*) self, text);
	t = _tmp0_;
	result = (GXmlNode*) t;
	return result;
}

static gboolean
gxml_tdocument_real_save (GXmlDocument* base,
                          GCancellable* cancellable,
                          GError** error)
{
	GXmlTDocument * self;
	gboolean result = FALSE;
	GFile* _tmp0_;
	GFile* _tmp1_;
	gboolean _tmp2_ = FALSE;
	GFile* _tmp3_;
	GFile* _tmp4_;
	GError* _inner_error0_ = NULL;
	self = (GXmlTDocument*) base;
	_tmp0_ = gxml_document_get_file ((GXmlDocument*) self);
	_tmp1_ = _tmp0_;
	_vala_return_val_if_fail (_tmp1_ != NULL, "file != null", FALSE);
	_tmp3_ = gxml_document_get_file ((GXmlDocument*) self);
	_tmp4_ = _tmp3_;
	_tmp2_ = gxml_document_save_as ((GXmlDocument*) self, _tmp4_, cancellable, &_inner_error0_);
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		gboolean _tmp5_ = FALSE;
		g_propagate_error (error, _inner_error0_);
		return _tmp5_;
	}
	result = _tmp2_;
	return result;
}

gboolean
gxml_tdocument_save_to (GXmlTDocument* self,
                        GFile* f,
                        GCancellable* cancellable,
                        GError** error)
{
	gboolean result = FALSE;
	gboolean _tmp0_ = FALSE;
	GError* _inner_error0_ = NULL;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (f != NULL, FALSE);
	_tmp0_ = gxml_document_save_as ((GXmlDocument*) self, f, cancellable, &_inner_error0_);
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		gboolean _tmp1_ = FALSE;
		g_propagate_error (error, _inner_error0_);
		return _tmp1_;
	}
	result = _tmp0_;
	return result;
}

static gboolean
gxml_tdocument_real_save_as (GXmlDocument* base,
                             GFile* f,
                             GCancellable* cancellable,
                             GError** error)
{
	GXmlTDocument * self;
	gboolean result = FALSE;
	gboolean _tmp0_ = FALSE;
	GError* _inner_error0_ = NULL;
	self = (GXmlTDocument*) base;
	g_return_val_if_fail (f != NULL, FALSE);
	_tmp0_ = gxml_tdocument_tw_save_as ((GXmlDocument*) self, f, cancellable, &_inner_error0_);
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		gboolean _tmp1_ = FALSE;
		g_propagate_error (error, _inner_error0_);
		return _tmp1_;
	}
	result = _tmp0_;
	return result;
}

static guint8*
g_string_get_data (GString* self,
                   gint* result_length1)
{
	guint8* result;
	guint8* res = NULL;
	const gchar* _tmp0_;
	gint res_length1;
	gint _res_size_;
	guint8* _tmp1_;
	gint _tmp1__length1;
	guint8* _tmp2_;
	gint _tmp2__length1;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->str;
	res = (guint8*) _tmp0_;
	res_length1 = -1;
	_res_size_ = res_length1;
	res_length1 = (gint) self->len;
	_tmp1_ = res;
	_tmp1__length1 = res_length1;
	_tmp2_ = _tmp1_;
	_tmp2__length1 = _tmp1__length1;
	if (result_length1) {
		*result_length1 = _tmp2__length1;
	}
	result = _tmp2_;
	return result;
}

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

gboolean
gxml_tdocument_tw_save_as (GXmlDocument* doc,
                           GFile* f,
                           GCancellable* cancellable,
                           GError** error)
{
	gboolean result = FALSE;
	xmlBuffer* buf = NULL;
	xmlBuffer* _tmp0_;
	xmlTextWriter* tw = NULL;
	xmlBuffer* _tmp1_;
	xmlTextWriter* _tmp2_;
	xmlTextWriter* _tmp3_;
	GString* s = NULL;
	GString* _tmp5_;
	GString* _tmp6_;
	xmlBuffer* _tmp7_;
	const gchar* _tmp8_;
	GMemoryInputStream* b = NULL;
	GString* _tmp9_;
	guint8* _tmp10_;
	gint _tmp10__length1;
	guint8* _tmp11_;
	gint _tmp11__length1;
	guint8* _tmp12_;
	gint _tmp12__length1;
	GMemoryInputStream* _tmp13_;
	GFileOutputStream* ostream = NULL;
	gboolean _tmp14_;
	gboolean _tmp15_;
	GFileOutputStream* _tmp16_;
	GFileOutputStream* _tmp18_;
	GMemoryInputStream* _tmp19_;
	GFileOutputStream* _tmp21_;
	GError* _inner_error0_ = NULL;
	g_return_val_if_fail (doc != NULL, FALSE);
	g_return_val_if_fail (f != NULL, FALSE);
	_tmp0_ = xmlBufferCreate ();
	buf = _tmp0_;
	_tmp1_ = buf;
	_tmp2_ = xmlNewTextWriterMemory (_tmp1_, FALSE);
	tw = _tmp2_;
	_tmp3_ = tw;
	gxml_tdocument_write_document (doc, _tmp3_, &_inner_error0_);
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		gboolean _tmp4_ = FALSE;
		g_propagate_error (error, _inner_error0_);
		_xmlFreeTextWriter0 (tw);
		_xmlBufferFree0 (buf);
		return _tmp4_;
	}
	_tmp5_ = g_string_new ("");
	s = _tmp5_;
	_tmp6_ = s;
	_tmp7_ = buf;
	_tmp8_ = xmlBufferContent (_tmp7_);
	g_string_append (_tmp6_, _tmp8_);
	_tmp9_ = s;
	_tmp10_ = g_string_get_data (_tmp9_, &_tmp10__length1);
	_tmp11_ = _tmp10_;
	_tmp11__length1 = _tmp10__length1;
	_tmp12_ = (_tmp11_ != NULL) ? _vala_array_dup3 (_tmp11_, _tmp11__length1) : ((gpointer) _tmp11_);
	_tmp12__length1 = _tmp11__length1;
	_tmp13_ = (GMemoryInputStream*) g_memory_input_stream_new_from_data (_tmp12_, _tmp12__length1, NULL);
	b = _tmp13_;
	_tmp14_ = gxml_document_get_backup (doc);
	_tmp15_ = _tmp14_;
	_tmp16_ = g_file_replace (f, NULL, _tmp15_, G_FILE_CREATE_NONE, cancellable, &_inner_error0_);
	ostream = _tmp16_;
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		gboolean _tmp17_ = FALSE;
		g_propagate_error (error, _inner_error0_);
		_g_object_unref0 (b);
		_g_string_free0 (s);
		_xmlFreeTextWriter0 (tw);
		_xmlBufferFree0 (buf);
		return _tmp17_;
	}
	_tmp18_ = ostream;
	_tmp19_ = b;
	g_output_stream_splice ((GOutputStream*) _tmp18_, (GInputStream*) _tmp19_, G_OUTPUT_STREAM_SPLICE_NONE, NULL, &_inner_error0_);
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		gboolean _tmp20_ = FALSE;
		g_propagate_error (error, _inner_error0_);
		_g_object_unref0 (ostream);
		_g_object_unref0 (b);
		_g_string_free0 (s);
		_xmlFreeTextWriter0 (tw);
		_xmlBufferFree0 (buf);
		return _tmp20_;
	}
	_tmp21_ = ostream;
	g_output_stream_close ((GOutputStream*) _tmp21_, NULL, &_inner_error0_);
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		gboolean _tmp22_ = FALSE;
		g_propagate_error (error, _inner_error0_);
		_g_object_unref0 (ostream);
		_g_object_unref0 (b);
		_g_string_free0 (s);
		_xmlFreeTextWriter0 (tw);
		_xmlBufferFree0 (buf);
		return _tmp22_;
	}
	result = TRUE;
	_g_object_unref0 (ostream);
	_g_object_unref0 (b);
	_g_string_free0 (s);
	_xmlFreeTextWriter0 (tw);
	_xmlBufferFree0 (buf);
	return result;
}

void
gxml_tdocument_write_document (GXmlDocument* doc,
                               xmlTextWriter* tw,
                               GError** error)
{
	gboolean _tmp0_;
	gboolean _tmp1_;
	GXmlNode* _tmp2_;
	GXmlNode* _tmp3_;
	GXmlNode* _tmp4_;
	gboolean _tmp5_;
	GeeArrayList* dns = NULL;
	GeeArrayList* _tmp6_;
	GError* _inner_error0_ = NULL;
	g_return_if_fail (doc != NULL);
	g_return_if_fail (tw != NULL);
	xmlTextWriterStartDocument (tw, NULL, NULL, NULL);
	_tmp0_ = gxml_document_get_indent (doc);
	_tmp1_ = _tmp0_;
	xmlTextWriterSetIndent (tw, _tmp1_);
	_tmp2_ = gxml_document_get_root (doc);
	_tmp3_ = _tmp2_;
	_tmp4_ = _tmp3_;
	_tmp5_ = _tmp4_ == NULL;
	_g_object_unref0 (_tmp4_);
	if (_tmp5_) {
		xmlTextWriterEndDocument (tw);
	}
	_tmp6_ = gee_array_list_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, NULL, NULL, NULL);
	dns = _tmp6_;
	gxml_tdocument_start_node (doc, tw, (GXmlNode*) doc, FALSE, &dns, &_inner_error0_);
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		g_propagate_error (error, _inner_error0_);
		_g_object_unref0 (dns);
		return;
	}
	xmlTextWriterEndElement (tw);
	xmlTextWriterEndDocument (tw);
	xmlTextWriterFlush (tw);
	_g_object_unref0 (dns);
}

void
gxml_tdocument_start_node (GXmlDocument* doc,
                           xmlTextWriter* tw,
                           GXmlNode* node,
                           gboolean root,
                           GeeArrayList* * declared_ns,
                           GError** error)
{
	gint size = 0;
	GError* _inner_error0_ = NULL;
	g_return_if_fail (doc != NULL);
	g_return_if_fail (tw != NULL);
	g_return_if_fail (node != NULL);
	g_return_if_fail (*declared_ns != NULL);
	size = 0;
	if (G_TYPE_CHECK_INSTANCE_TYPE (node, GXML_TYPE_ELEMENT)) {
		if (root) {
			GXmlDocument* _tmp0_;
			GXmlDocument* _tmp1_;
			GeeList* _tmp2_;
			GeeList* _tmp3_;
			GeeList* _tmp4_;
			gint _tmp5_;
			gint _tmp6_;
			gboolean _tmp7_;
			_tmp0_ = gxml_node_get_document (node);
			_tmp1_ = _tmp0_;
			_tmp2_ = gxml_node_get_namespaces ((GXmlNode*) _tmp1_);
			_tmp3_ = _tmp2_;
			_tmp4_ = _tmp3_;
			_tmp5_ = gee_collection_get_size ((GeeCollection*) _tmp4_);
			_tmp6_ = _tmp5_;
			_tmp7_ = _tmp6_ > 0;
			_g_object_unref0 (_tmp4_);
			if (_tmp7_) {
				GXmlNamespace* dns = NULL;
				GXmlDocument* _tmp8_;
				GXmlDocument* _tmp9_;
				GeeList* _tmp10_;
				GeeList* _tmp11_;
				GeeList* _tmp12_;
				gpointer _tmp13_;
				GXmlNamespace* _tmp14_;
				GXmlNamespace* _tmp15_;
				gboolean _tmp16_;
				gboolean _tmp17_;
				gboolean _tmp59_ = FALSE;
				GXmlDocument* _tmp60_;
				GXmlDocument* _tmp61_;
				GeeList* _tmp62_;
				GeeList* _tmp63_;
				GeeList* _tmp64_;
				gint _tmp65_;
				gint _tmp66_;
				gboolean _tmp67_;
				_tmp8_ = gxml_node_get_document (node);
				_tmp9_ = _tmp8_;
				_tmp10_ = gxml_node_get_namespaces ((GXmlNode*) _tmp9_);
				_tmp11_ = _tmp10_;
				_tmp12_ = _tmp11_;
				_tmp13_ = gee_list_get (_tmp12_, 0);
				_tmp14_ = (GXmlNamespace*) _tmp13_;
				_g_object_unref0 (_tmp12_);
				dns = _tmp14_;
				_tmp15_ = dns;
				_vala_assert (_tmp15_ != NULL, "dns != null");
				_tmp16_ = gxml_document_get_prefix_default_ns (doc);
				_tmp17_ = _tmp16_;
				if (_tmp17_) {
					GXmlNamespace* _tmp18_;
					gchar* _tmp19_;
					gchar* _tmp20_;
					gchar* _tmp21_;
					gchar* _tmp22_;
					gchar* _tmp23_;
					gchar* _tmp24_;
					GXmlNamespace* _tmp25_;
					gchar* _tmp26_;
					gchar* _tmp27_;
					gchar* _tmp28_;
					GXmlNamespace* _tmp29_;
					gchar* _tmp30_;
					gchar* _tmp31_;
					gchar* _tmp32_;
					_tmp18_ = dns;
					_tmp19_ = gxml_namespace_get_prefix (_tmp18_);
					_tmp20_ = _tmp19_;
					_tmp21_ = _tmp20_;
					_tmp22_ = gxml_node_get_name (node);
					_tmp23_ = _tmp22_;
					_tmp24_ = _tmp23_;
					_tmp25_ = dns;
					_tmp26_ = gxml_namespace_get_uri (_tmp25_);
					_tmp27_ = _tmp26_;
					_tmp28_ = _tmp27_;
					xmlTextWriterStartElementNS (tw, (xmlChar*) _tmp21_, (xmlChar*) _tmp24_, (xmlChar*) _tmp28_);
					_g_free0 (_tmp28_);
					_g_free0 (_tmp24_);
					_g_free0 (_tmp21_);
					_tmp29_ = dns;
					_tmp30_ = gxml_namespace_get_uri (_tmp29_);
					_tmp31_ = _tmp30_;
					_tmp32_ = _tmp31_;
					gee_abstract_collection_add ((GeeAbstractCollection*) (*declared_ns), _tmp32_);
					_g_free0 (_tmp32_);
				} else {
					gchar* _tmp33_;
					gchar* _tmp34_;
					gchar* _tmp35_;
					GXmlNamespace* _tmp36_;
					gchar* _tmp37_;
					gchar* _tmp38_;
					gchar* _tmp39_;
					gboolean _tmp40_;
					GXmlNamespace* _tmp55_;
					gchar* _tmp56_;
					gchar* _tmp57_;
					gchar* _tmp58_;
					_tmp33_ = gxml_node_get_name (node);
					_tmp34_ = _tmp33_;
					_tmp35_ = _tmp34_;
					xmlTextWriterStartElement (tw, (xmlChar*) _tmp35_);
					_g_free0 (_tmp35_);
					_tmp36_ = dns;
					_tmp37_ = gxml_namespace_get_prefix (_tmp36_);
					_tmp38_ = _tmp37_;
					_tmp39_ = _tmp38_;
					_tmp40_ = _tmp39_ == NULL;
					_g_free0 (_tmp39_);
					if (_tmp40_) {
						GXmlNamespace* _tmp41_;
						gchar* _tmp42_;
						gchar* _tmp43_;
						gchar* _tmp44_;
						_tmp41_ = dns;
						_tmp42_ = gxml_namespace_get_uri (_tmp41_);
						_tmp43_ = _tmp42_;
						_tmp44_ = _tmp43_;
						xmlTextWriterWriteAttribute (tw, (xmlChar*) "xmlns", (xmlChar*) _tmp44_);
						_g_free0 (_tmp44_);
					} else {
						GXmlNamespace* _tmp45_;
						gchar* _tmp46_;
						gchar* _tmp47_;
						gchar* _tmp48_;
						gchar* _tmp49_;
						gchar* _tmp50_;
						GXmlNamespace* _tmp51_;
						gchar* _tmp52_;
						gchar* _tmp53_;
						gchar* _tmp54_;
						_tmp45_ = dns;
						_tmp46_ = gxml_namespace_get_prefix (_tmp45_);
						_tmp47_ = _tmp46_;
						_tmp48_ = _tmp47_;
						_tmp49_ = g_strconcat ("xmlns:", _tmp48_, NULL);
						_tmp50_ = _tmp49_;
						_tmp51_ = dns;
						_tmp52_ = gxml_namespace_get_uri (_tmp51_);
						_tmp53_ = _tmp52_;
						_tmp54_ = _tmp53_;
						xmlTextWriterWriteAttribute (tw, (xmlChar*) _tmp50_, (xmlChar*) _tmp54_);
						_g_free0 (_tmp54_);
						_g_free0 (_tmp50_);
						_g_free0 (_tmp48_);
					}
					_tmp55_ = dns;
					_tmp56_ = gxml_namespace_get_uri (_tmp55_);
					_tmp57_ = _tmp56_;
					_tmp58_ = _tmp57_;
					gee_abstract_collection_add ((GeeAbstractCollection*) (*declared_ns), _tmp58_);
					_g_free0 (_tmp58_);
				}
				_tmp60_ = gxml_node_get_document (node);
				_tmp61_ = _tmp60_;
				_tmp62_ = gxml_node_get_namespaces ((GXmlNode*) _tmp61_);
				_tmp63_ = _tmp62_;
				_tmp64_ = _tmp63_;
				_tmp65_ = gee_collection_get_size ((GeeCollection*) _tmp64_);
				_tmp66_ = _tmp65_;
				_tmp67_ = _tmp66_ > 1;
				_g_object_unref0 (_tmp64_);
				if (_tmp67_) {
					GXmlDocument* _tmp68_;
					GXmlDocument* _tmp69_;
					gboolean _tmp70_;
					gboolean _tmp71_;
					_tmp68_ = gxml_node_get_document (node);
					_tmp69_ = _tmp68_;
					_tmp70_ = gxml_document_get_ns_top (_tmp69_);
					_tmp71_ = _tmp70_;
					_tmp59_ = _tmp71_;
				} else {
					_tmp59_ = FALSE;
				}
				if (_tmp59_) {
					{
						gint i = 0;
						i = 1;
						{
							gboolean _tmp72_ = FALSE;
							_tmp72_ = TRUE;
							while (TRUE) {
								GXmlDocument* _tmp74_;
								GXmlDocument* _tmp75_;
								GeeList* _tmp76_;
								GeeList* _tmp77_;
								GeeList* _tmp78_;
								gint _tmp79_;
								gint _tmp80_;
								gboolean _tmp81_;
								GXmlNamespace* ns = NULL;
								GXmlDocument* _tmp82_;
								GXmlDocument* _tmp83_;
								GeeList* _tmp84_;
								GeeList* _tmp85_;
								GeeList* _tmp86_;
								gpointer _tmp87_;
								GXmlNamespace* _tmp88_;
								GXmlNamespace* _tmp89_;
								gchar* _tmp90_;
								gchar* _tmp91_;
								gchar* _tmp92_;
								gboolean _tmp93_;
								GXmlNamespace* _tmp94_;
								gchar* _tmp95_;
								gchar* _tmp96_;
								gchar* _tmp97_;
								gchar* _tmp98_;
								gchar* _tmp99_;
								GXmlNamespace* _tmp100_;
								gchar* _tmp101_;
								gchar* _tmp102_;
								gchar* _tmp103_;
								GXmlNamespace* _tmp104_;
								gchar* _tmp105_;
								gchar* _tmp106_;
								gchar* _tmp107_;
								if (!_tmp72_) {
									gint _tmp73_;
									_tmp73_ = i;
									i = _tmp73_ + 1;
								}
								_tmp72_ = FALSE;
								_tmp74_ = gxml_node_get_document (node);
								_tmp75_ = _tmp74_;
								_tmp76_ = gxml_node_get_namespaces ((GXmlNode*) _tmp75_);
								_tmp77_ = _tmp76_;
								_tmp78_ = _tmp77_;
								_tmp79_ = gee_collection_get_size ((GeeCollection*) _tmp78_);
								_tmp80_ = _tmp79_;
								_tmp81_ = !(i < _tmp80_);
								_g_object_unref0 (_tmp78_);
								if (_tmp81_) {
									break;
								}
								_tmp82_ = gxml_node_get_document (node);
								_tmp83_ = _tmp82_;
								_tmp84_ = gxml_node_get_namespaces ((GXmlNode*) _tmp83_);
								_tmp85_ = _tmp84_;
								_tmp86_ = _tmp85_;
								_tmp87_ = gee_list_get (_tmp86_, i);
								_tmp88_ = (GXmlNamespace*) _tmp87_;
								_g_object_unref0 (_tmp86_);
								ns = _tmp88_;
								_tmp89_ = ns;
								_tmp90_ = gxml_namespace_get_prefix (_tmp89_);
								_tmp91_ = _tmp90_;
								_tmp92_ = _tmp91_;
								_tmp93_ = _tmp92_ == NULL;
								_g_free0 (_tmp92_);
								if (_tmp93_) {
									_g_object_unref0 (ns);
									continue;
								}
								_tmp94_ = ns;
								_tmp95_ = gxml_namespace_get_prefix (_tmp94_);
								_tmp96_ = _tmp95_;
								_tmp97_ = _tmp96_;
								_tmp98_ = g_strconcat ("xmlns:", _tmp97_, NULL);
								_tmp99_ = _tmp98_;
								_tmp100_ = ns;
								_tmp101_ = gxml_namespace_get_uri (_tmp100_);
								_tmp102_ = _tmp101_;
								_tmp103_ = _tmp102_;
								xmlTextWriterWriteAttribute (tw, (xmlChar*) _tmp99_, (xmlChar*) _tmp103_);
								_g_free0 (_tmp103_);
								_g_free0 (_tmp99_);
								_g_free0 (_tmp97_);
								_tmp104_ = ns;
								_tmp105_ = gxml_namespace_get_uri (_tmp104_);
								_tmp106_ = _tmp105_;
								_tmp107_ = _tmp106_;
								gee_abstract_collection_add ((GeeAbstractCollection*) (*declared_ns), _tmp107_);
								_g_free0 (_tmp107_);
								_g_object_unref0 (ns);
							}
						}
					}
				}
				_g_object_unref0 (dns);
			} else {
				gchar* _tmp108_;
				gchar* _tmp109_;
				gchar* _tmp110_;
				_tmp108_ = gxml_node_get_name (node);
				_tmp109_ = _tmp108_;
				_tmp110_ = _tmp109_;
				xmlTextWriterStartElement (tw, (xmlChar*) _tmp110_);
				_g_free0 (_tmp110_);
			}
		} else {
			GeeList* _tmp111_;
			GeeList* _tmp112_;
			GeeList* _tmp113_;
			gint _tmp114_;
			gint _tmp115_;
			gboolean _tmp116_;
			_tmp111_ = gxml_node_get_namespaces (node);
			_tmp112_ = _tmp111_;
			_tmp113_ = _tmp112_;
			_tmp114_ = gee_collection_get_size ((GeeCollection*) _tmp113_);
			_tmp115_ = _tmp114_;
			_tmp116_ = _tmp115_ > 0;
			_g_object_unref0 (_tmp113_);
			if (_tmp116_) {
				GXmlDocument* _tmp117_;
				GXmlDocument* _tmp118_;
				gchar* _tmp119_;
				gchar* _tmp120_;
				gchar* _tmp121_;
				gchar* _tmp122_;
				gboolean _tmp123_;
				_tmp117_ = gxml_node_get_document (node);
				_tmp118_ = _tmp117_;
				_tmp119_ = gxml_node_ns_uri ((GXmlNode*) _tmp118_);
				_tmp120_ = _tmp119_;
				_tmp121_ = gxml_node_ns_uri (node);
				_tmp122_ = _tmp121_;
				_tmp123_ = g_strcmp0 (_tmp120_, _tmp122_) == 0;
				_g_free0 (_tmp122_);
				_g_free0 (_tmp120_);
				if (_tmp123_) {
					GXmlDocument* _tmp124_;
					GXmlDocument* _tmp125_;
					gboolean _tmp126_;
					gboolean _tmp127_;
					_tmp124_ = gxml_node_get_document (node);
					_tmp125_ = _tmp124_;
					_tmp126_ = gxml_document_get_prefix_default_ns (_tmp125_);
					_tmp127_ = _tmp126_;
					if (_tmp127_) {
						gchar* _tmp128_;
						gchar* _tmp129_;
						gchar* _tmp130_;
						gchar* _tmp131_;
						gchar* _tmp132_;
						_tmp128_ = gxml_node_ns_prefix (node);
						_tmp129_ = _tmp128_;
						_tmp130_ = gxml_node_get_name (node);
						_tmp131_ = _tmp130_;
						_tmp132_ = _tmp131_;
						xmlTextWriterStartElementNS (tw, (xmlChar*) _tmp129_, (xmlChar*) _tmp132_, (xmlChar*) NULL);
						_g_free0 (_tmp132_);
						_g_free0 (_tmp129_);
					} else {
						gchar* _tmp133_;
						gchar* _tmp134_;
						gchar* _tmp135_;
						_tmp133_ = gxml_node_get_name (node);
						_tmp134_ = _tmp133_;
						_tmp135_ = _tmp134_;
						xmlTextWriterStartElement (tw, (xmlChar*) _tmp135_);
						_g_free0 (_tmp135_);
					}
				} else {
					gboolean _tmp136_ = FALSE;
					gchar* _tmp137_;
					gchar* _tmp138_;
					gboolean _tmp139_;
					_tmp137_ = gxml_node_ns_prefix (node);
					_tmp138_ = _tmp137_;
					_tmp139_ = _tmp138_ == NULL;
					_g_free0 (_tmp138_);
					if (_tmp139_) {
						gchar* _tmp140_;
						gchar* _tmp141_;
						_tmp140_ = gxml_node_ns_uri (node);
						_tmp141_ = _tmp140_;
						_tmp136_ = !gee_abstract_collection_contains ((GeeAbstractCollection*) (*declared_ns), _tmp141_);
						_g_free0 (_tmp141_);
					} else {
						_tmp136_ = FALSE;
					}
					if (_tmp136_) {
						gchar* _tmp142_;
						gchar* _tmp143_;
						gchar* _tmp144_;
						gchar* _tmp145_;
						gchar* _tmp146_;
						gchar* _tmp147_;
						gchar* _tmp148_;
						gchar* _tmp149_;
						gchar* _tmp150_;
						_tmp142_ = gxml_node_ns_prefix (node);
						_tmp143_ = _tmp142_;
						_tmp144_ = gxml_node_get_name (node);
						_tmp145_ = _tmp144_;
						_tmp146_ = _tmp145_;
						_tmp147_ = gxml_node_ns_uri (node);
						_tmp148_ = _tmp147_;
						xmlTextWriterStartElementNS (tw, (xmlChar*) _tmp143_, (xmlChar*) _tmp146_, (xmlChar*) _tmp148_);
						_g_free0 (_tmp148_);
						_g_free0 (_tmp146_);
						_g_free0 (_tmp143_);
						_tmp149_ = gxml_node_ns_uri (node);
						_tmp150_ = _tmp149_;
						gee_abstract_collection_add ((GeeAbstractCollection*) (*declared_ns), _tmp150_);
						_g_free0 (_tmp150_);
					} else {
						gboolean _tmp151_ = FALSE;
						GXmlDocument* _tmp152_;
						GXmlDocument* _tmp153_;
						gboolean _tmp154_;
						gboolean _tmp155_;
						_tmp152_ = gxml_node_get_document (node);
						_tmp153_ = _tmp152_;
						_tmp154_ = gxml_document_get_ns_top (_tmp153_);
						_tmp155_ = _tmp154_;
						if (_tmp155_) {
							_tmp151_ = TRUE;
						} else {
							gchar* _tmp156_;
							gchar* _tmp157_;
							_tmp156_ = gxml_node_ns_uri (node);
							_tmp157_ = _tmp156_;
							_tmp151_ = gee_abstract_collection_contains ((GeeAbstractCollection*) (*declared_ns), _tmp157_);
							_g_free0 (_tmp157_);
						}
						if (_tmp151_) {
							gchar* _tmp158_;
							gchar* _tmp159_;
							gchar* _tmp160_;
							gchar* _tmp161_;
							gchar* _tmp162_;
							_tmp158_ = gxml_node_ns_prefix (node);
							_tmp159_ = _tmp158_;
							_tmp160_ = gxml_node_get_name (node);
							_tmp161_ = _tmp160_;
							_tmp162_ = _tmp161_;
							xmlTextWriterStartElementNS (tw, (xmlChar*) _tmp159_, (xmlChar*) _tmp162_, (xmlChar*) NULL);
							_g_free0 (_tmp162_);
							_g_free0 (_tmp159_);
						} else {
							gchar* _tmp163_;
							gchar* _tmp164_;
							gchar* _tmp165_;
							gchar* _tmp166_;
							gchar* _tmp167_;
							gchar* _tmp168_;
							gchar* _tmp169_;
							gchar* _tmp170_;
							gchar* _tmp171_;
							_tmp163_ = gxml_node_ns_prefix (node);
							_tmp164_ = _tmp163_;
							_tmp165_ = gxml_node_get_name (node);
							_tmp166_ = _tmp165_;
							_tmp167_ = _tmp166_;
							_tmp168_ = gxml_node_ns_uri (node);
							_tmp169_ = _tmp168_;
							xmlTextWriterStartElementNS (tw, (xmlChar*) _tmp164_, (xmlChar*) _tmp167_, (xmlChar*) _tmp169_);
							_g_free0 (_tmp169_);
							_g_free0 (_tmp167_);
							_g_free0 (_tmp164_);
							_tmp170_ = gxml_node_ns_uri (node);
							_tmp171_ = _tmp170_;
							gee_abstract_collection_add ((GeeAbstractCollection*) (*declared_ns), _tmp171_);
							_g_free0 (_tmp171_);
						}
					}
				}
			} else {
				GXmlDocument* _tmp172_;
				GXmlDocument* _tmp173_;
				gboolean _tmp174_;
				gboolean _tmp175_;
				_tmp172_ = gxml_node_get_document (node);
				_tmp173_ = _tmp172_;
				_tmp174_ = gxml_document_get_prefix_default_ns (_tmp173_);
				_tmp175_ = _tmp174_;
				if (_tmp175_) {
					GXmlDocument* _tmp176_;
					GXmlDocument* _tmp177_;
					gchar* _tmp178_;
					gchar* _tmp179_;
					gchar* _tmp180_;
					gchar* _tmp181_;
					gchar* _tmp182_;
					_tmp176_ = gxml_node_get_document (node);
					_tmp177_ = _tmp176_;
					_tmp178_ = gxml_node_ns_prefix ((GXmlNode*) _tmp177_);
					_tmp179_ = _tmp178_;
					_tmp180_ = gxml_node_get_name (node);
					_tmp181_ = _tmp180_;
					_tmp182_ = _tmp181_;
					xmlTextWriterStartElementNS (tw, (xmlChar*) _tmp179_, (xmlChar*) _tmp182_, (xmlChar*) NULL);
					_g_free0 (_tmp182_);
					_g_free0 (_tmp179_);
				} else {
					gchar* _tmp183_;
					gchar* _tmp184_;
					gchar* _tmp185_;
					_tmp183_ = gxml_node_get_name (node);
					_tmp184_ = _tmp183_;
					_tmp185_ = _tmp184_;
					xmlTextWriterStartElement (tw, (xmlChar*) _tmp185_);
					_g_free0 (_tmp185_);
				}
			}
		}
		{
			GeeList* _ns_list = NULL;
			GeeList* _tmp186_;
			GeeList* _tmp187_;
			gint _ns_size = 0;
			GeeList* _tmp188_;
			gint _tmp189_;
			gint _tmp190_;
			gint _ns_index = 0;
			_tmp186_ = gxml_node_get_namespaces (node);
			_tmp187_ = _tmp186_;
			_ns_list = _tmp187_;
			_tmp188_ = _ns_list;
			_tmp189_ = gee_collection_get_size ((GeeCollection*) _tmp188_);
			_tmp190_ = _tmp189_;
			_ns_size = _tmp190_;
			_ns_index = -1;
			while (TRUE) {
				GXmlNamespace* ns = NULL;
				GeeList* _tmp191_;
				gpointer _tmp192_;
				GXmlNamespace* _tmp193_;
				gchar* _tmp194_;
				gchar* _tmp195_;
				gchar* _tmp196_;
				gboolean _tmp197_;
				GXmlNamespace* _tmp198_;
				gchar* _tmp199_;
				gchar* _tmp200_;
				gchar* _tmp201_;
				gchar* _tmp202_;
				gchar* _tmp203_;
				GXmlNamespace* _tmp204_;
				gchar* _tmp205_;
				gchar* _tmp206_;
				gchar* _tmp207_;
				GXmlNamespace* _tmp208_;
				gchar* _tmp209_;
				gchar* _tmp210_;
				gchar* _tmp211_;
				_ns_index = _ns_index + 1;
				if (!(_ns_index < _ns_size)) {
					break;
				}
				_tmp191_ = _ns_list;
				_tmp192_ = gee_list_get (_tmp191_, _ns_index);
				ns = (GXmlNamespace*) _tmp192_;
				_tmp193_ = ns;
				_tmp194_ = gxml_namespace_get_uri (_tmp193_);
				_tmp195_ = _tmp194_;
				_tmp196_ = _tmp195_;
				_tmp197_ = gee_abstract_collection_contains ((GeeAbstractCollection*) (*declared_ns), _tmp196_);
				_g_free0 (_tmp196_);
				if (_tmp197_) {
					_g_object_unref0 (ns);
					continue;
				}
				_tmp198_ = ns;
				_tmp199_ = gxml_namespace_get_prefix (_tmp198_);
				_tmp200_ = _tmp199_;
				_tmp201_ = _tmp200_;
				_tmp202_ = g_strconcat ("xmlns:", _tmp201_, NULL);
				_tmp203_ = _tmp202_;
				_tmp204_ = ns;
				_tmp205_ = gxml_namespace_get_uri (_tmp204_);
				_tmp206_ = _tmp205_;
				_tmp207_ = _tmp206_;
				xmlTextWriterWriteAttribute (tw, (xmlChar*) _tmp203_, (xmlChar*) _tmp207_);
				_g_free0 (_tmp207_);
				_g_free0 (_tmp203_);
				_g_free0 (_tmp201_);
				_tmp208_ = ns;
				_tmp209_ = gxml_namespace_get_uri (_tmp208_);
				_tmp210_ = _tmp209_;
				_tmp211_ = _tmp210_;
				gee_abstract_collection_add ((GeeAbstractCollection*) (*declared_ns), _tmp211_);
				_g_free0 (_tmp211_);
				_g_object_unref0 (ns);
			}
			_g_object_unref0 (_ns_list);
		}
		{
			GeeIterator* _attr_it = NULL;
			GeeMap* _tmp212_;
			GeeMap* _tmp213_;
			GeeMap* _tmp214_;
			GeeCollection* _tmp215_;
			GeeCollection* _tmp216_;
			GeeCollection* _tmp217_;
			GeeIterator* _tmp218_;
			GeeIterator* _tmp219_;
			_tmp212_ = gxml_node_get_attrs (node);
			_tmp213_ = _tmp212_;
			_tmp214_ = _tmp213_;
			_tmp215_ = gee_map_get_values (_tmp214_);
			_tmp216_ = _tmp215_;
			_tmp217_ = _tmp216_;
			_tmp218_ = gee_iterable_iterator ((GeeIterable*) _tmp217_);
			_tmp219_ = _tmp218_;
			_g_object_unref0 (_tmp217_);
			_g_object_unref0 (_tmp214_);
			_attr_it = _tmp219_;
			while (TRUE) {
				GeeIterator* _tmp220_;
				GXmlNode* attr = NULL;
				GeeIterator* _tmp221_;
				gpointer _tmp222_;
				GXmlNode* _tmp223_;
				GeeList* _tmp224_;
				GeeList* _tmp225_;
				GeeList* _tmp226_;
				gint _tmp227_;
				gint _tmp228_;
				gboolean _tmp229_;
				_tmp220_ = _attr_it;
				if (!gee_iterator_next (_tmp220_)) {
					break;
				}
				_tmp221_ = _attr_it;
				_tmp222_ = gee_iterator_get (_tmp221_);
				attr = (GXmlNode*) _tmp222_;
				_tmp223_ = attr;
				_tmp224_ = gxml_node_get_namespaces (_tmp223_);
				_tmp225_ = _tmp224_;
				_tmp226_ = _tmp225_;
				_tmp227_ = gee_collection_get_size ((GeeCollection*) _tmp226_);
				_tmp228_ = _tmp227_;
				_tmp229_ = _tmp228_ > 0;
				_g_object_unref0 (_tmp226_);
				if (_tmp229_) {
					GXmlNode* _tmp230_;
					gchar* _tmp231_;
					gchar* _tmp232_;
					gboolean _tmp233_;
					_tmp230_ = attr;
					_tmp231_ = gxml_node_ns_uri (_tmp230_);
					_tmp232_ = _tmp231_;
					_tmp233_ = !gee_abstract_collection_contains ((GeeAbstractCollection*) (*declared_ns), _tmp232_);
					_g_free0 (_tmp232_);
					if (_tmp233_) {
						GXmlNode* _tmp234_;
						gchar* _tmp235_;
						gchar* _tmp236_;
						GXmlNode* _tmp237_;
						gchar* _tmp238_;
						gchar* _tmp239_;
						gchar* _tmp240_;
						GXmlNode* _tmp241_;
						gchar* _tmp242_;
						gchar* _tmp243_;
						GXmlNode* _tmp244_;
						gchar* _tmp245_;
						gchar* _tmp246_;
						gchar* _tmp247_;
						GXmlNode* _tmp248_;
						gchar* _tmp249_;
						gchar* _tmp250_;
						_tmp234_ = attr;
						_tmp235_ = gxml_node_ns_prefix (_tmp234_);
						_tmp236_ = _tmp235_;
						_tmp237_ = attr;
						_tmp238_ = gxml_node_get_name (_tmp237_);
						_tmp239_ = _tmp238_;
						_tmp240_ = _tmp239_;
						_tmp241_ = attr;
						_tmp242_ = gxml_node_ns_uri (_tmp241_);
						_tmp243_ = _tmp242_;
						_tmp244_ = attr;
						_tmp245_ = gxml_node_get_value (_tmp244_);
						_tmp246_ = _tmp245_;
						_tmp247_ = _tmp246_;
						size = size + xmlTextWriterWriteAttributeNS (tw, (xmlChar*) _tmp236_, (xmlChar*) _tmp240_, (xmlChar*) _tmp243_, (xmlChar*) _tmp247_);
						_g_free0 (_tmp247_);
						_g_free0 (_tmp243_);
						_g_free0 (_tmp240_);
						_g_free0 (_tmp236_);
						_tmp248_ = attr;
						_tmp249_ = gxml_node_ns_uri (_tmp248_);
						_tmp250_ = _tmp249_;
						gee_abstract_collection_add ((GeeAbstractCollection*) (*declared_ns), _tmp250_);
						_g_free0 (_tmp250_);
					} else {
						GXmlNode* _tmp251_;
						gchar* _tmp252_;
						gchar* _tmp253_;
						GXmlNode* _tmp254_;
						gchar* _tmp255_;
						gchar* _tmp256_;
						gchar* _tmp257_;
						GXmlNode* _tmp258_;
						gchar* _tmp259_;
						gchar* _tmp260_;
						gchar* _tmp261_;
						_tmp251_ = attr;
						_tmp252_ = gxml_node_ns_prefix (_tmp251_);
						_tmp253_ = _tmp252_;
						_tmp254_ = attr;
						_tmp255_ = gxml_node_get_name (_tmp254_);
						_tmp256_ = _tmp255_;
						_tmp257_ = _tmp256_;
						_tmp258_ = attr;
						_tmp259_ = gxml_node_get_value (_tmp258_);
						_tmp260_ = _tmp259_;
						_tmp261_ = _tmp260_;
						size = size + xmlTextWriterWriteAttributeNS (tw, (xmlChar*) _tmp253_, (xmlChar*) _tmp257_, (xmlChar*) NULL, (xmlChar*) _tmp261_);
						_g_free0 (_tmp261_);
						_g_free0 (_tmp257_);
						_g_free0 (_tmp253_);
					}
				} else {
					GXmlNode* _tmp262_;
					gchar* _tmp263_;
					gchar* _tmp264_;
					gchar* _tmp265_;
					GXmlNode* _tmp266_;
					gchar* _tmp267_;
					gchar* _tmp268_;
					gchar* _tmp269_;
					_tmp262_ = attr;
					_tmp263_ = gxml_node_get_name (_tmp262_);
					_tmp264_ = _tmp263_;
					_tmp265_ = _tmp264_;
					_tmp266_ = attr;
					_tmp267_ = gxml_node_get_value (_tmp266_);
					_tmp268_ = _tmp267_;
					_tmp269_ = _tmp268_;
					size = size + xmlTextWriterWriteAttribute (tw, (xmlChar*) _tmp265_, (xmlChar*) _tmp269_);
					_g_free0 (_tmp269_);
					_g_free0 (_tmp265_);
				}
				if (size > 1500) {
					xmlTextWriterFlush (tw);
				}
				_g_object_unref0 (attr);
			}
			_g_object_unref0 (_attr_it);
		}
	}
	{
		GeeBidirList* _n_list = NULL;
		GeeBidirList* _tmp270_;
		GeeBidirList* _tmp271_;
		gint _n_size = 0;
		GeeBidirList* _tmp272_;
		gint _tmp273_;
		gint _tmp274_;
		gint _n_index = 0;
		_tmp270_ = gxml_node_get_children_nodes (node);
		_tmp271_ = _tmp270_;
		_n_list = _tmp271_;
		_tmp272_ = _n_list;
		_tmp273_ = gee_collection_get_size ((GeeCollection*) _tmp272_);
		_tmp274_ = _tmp273_;
		_n_size = _tmp274_;
		_n_index = -1;
		while (TRUE) {
			GXmlNode* n = NULL;
			GeeBidirList* _tmp275_;
			gpointer _tmp276_;
			GXmlNode* _tmp277_;
			GXmlNode* _tmp314_;
			GXmlNode* _tmp319_;
			GXmlNode* _tmp324_;
			GXmlNode* _tmp329_;
			_n_index = _n_index + 1;
			if (!(_n_index < _n_size)) {
				break;
			}
			_tmp275_ = _n_list;
			_tmp276_ = gee_list_get ((GeeList*) _tmp275_, _n_index);
			n = (GXmlNode*) _tmp276_;
			_tmp277_ = n;
			if (G_TYPE_CHECK_INSTANCE_TYPE (_tmp277_, GXML_TYPE_ELEMENT)) {
				GeeList* _tmp278_;
				GeeList* _tmp279_;
				GeeList* _tmp280_;
				gint _tmp281_;
				gint _tmp282_;
				gboolean _tmp283_;
				_tmp278_ = gxml_node_get_namespaces (node);
				_tmp279_ = _tmp278_;
				_tmp280_ = _tmp279_;
				_tmp281_ = gee_collection_get_size ((GeeCollection*) _tmp280_);
				_tmp282_ = _tmp281_;
				_tmp283_ = _tmp282_ > 0;
				_g_object_unref0 (_tmp280_);
				if (_tmp283_) {
					GXmlDocument* _tmp284_;
					GXmlDocument* _tmp285_;
					GeeList* _tmp286_;
					GeeList* _tmp287_;
					GeeList* _tmp288_;
					gint _tmp289_;
					gint _tmp290_;
					gboolean _tmp291_;
					_tmp284_ = gxml_node_get_document (node);
					_tmp285_ = _tmp284_;
					_tmp286_ = gxml_node_get_namespaces ((GXmlNode*) _tmp285_);
					_tmp287_ = _tmp286_;
					_tmp288_ = _tmp287_;
					_tmp289_ = gee_collection_get_size ((GeeCollection*) _tmp288_);
					_tmp290_ = _tmp289_;
					_tmp291_ = _tmp290_ > 0;
					_g_object_unref0 (_tmp288_);
					if (_tmp291_) {
						gchar* _tmp292_;
						gchar* _tmp293_;
						GXmlDocument* _tmp294_;
						GXmlDocument* _tmp295_;
						gchar* _tmp296_;
						gchar* _tmp297_;
						gboolean _tmp298_;
						_tmp292_ = gxml_node_ns_uri (node);
						_tmp293_ = _tmp292_;
						_tmp294_ = gxml_node_get_document (node);
						_tmp295_ = _tmp294_;
						_tmp296_ = gxml_node_ns_uri ((GXmlNode*) _tmp295_);
						_tmp297_ = _tmp296_;
						_tmp298_ = g_strcmp0 (_tmp293_, _tmp297_) != 0;
						_g_free0 (_tmp297_);
						_g_free0 (_tmp293_);
						if (_tmp298_) {
							gboolean _tmp299_ = FALSE;
							GXmlNode* _tmp300_;
							GeeList* _tmp301_;
							GeeList* _tmp302_;
							GeeList* _tmp303_;
							gint _tmp304_;
							gint _tmp305_;
							gboolean _tmp306_;
							_tmp300_ = n;
							_tmp301_ = gxml_node_get_namespaces (_tmp300_);
							_tmp302_ = _tmp301_;
							_tmp303_ = _tmp302_;
							_tmp304_ = gee_collection_get_size ((GeeCollection*) _tmp303_);
							_tmp305_ = _tmp304_;
							_tmp306_ = _tmp305_ == 0;
							_g_object_unref0 (_tmp303_);
							if (_tmp306_) {
								_tmp299_ = gxml_node_ns_prefix == NULL;
							} else {
								_tmp299_ = FALSE;
							}
							if (_tmp299_) {
								GXmlNode* _tmp307_;
								gchar* _tmp308_;
								gchar* _tmp309_;
								gchar* _tmp310_;
								gchar* _tmp311_;
								_tmp307_ = n;
								_tmp308_ = gxml_node_ns_uri (node);
								_tmp309_ = _tmp308_;
								_tmp310_ = gxml_node_ns_prefix (node);
								_tmp311_ = _tmp310_;
								gxml_node_set_namespace (_tmp307_, _tmp309_, _tmp311_);
								_g_free0 (_tmp311_);
								_g_free0 (_tmp309_);
							}
						}
					}
				}
				if (G_TYPE_CHECK_INSTANCE_TYPE (node, GXML_TYPE_DOCUMENT)) {
					GXmlNode* _tmp312_;
					_tmp312_ = n;
					gxml_tdocument_start_node (doc, tw, _tmp312_, TRUE, declared_ns, &_inner_error0_);
					if (G_UNLIKELY (_inner_error0_ != NULL)) {
						g_propagate_error (error, _inner_error0_);
						_g_object_unref0 (n);
						_g_object_unref0 (_n_list);
						return;
					}
				} else {
					GXmlNode* _tmp313_;
					_tmp313_ = n;
					gxml_tdocument_start_node (doc, tw, _tmp313_, FALSE, declared_ns, &_inner_error0_);
					if (G_UNLIKELY (_inner_error0_ != NULL)) {
						g_propagate_error (error, _inner_error0_);
						_g_object_unref0 (n);
						_g_object_unref0 (_n_list);
						return;
					}
				}
				size = size + xmlTextWriterEndElement (tw);
				if (size > 1500) {
					xmlTextWriterFlush (tw);
				}
			}
			_tmp314_ = n;
			if (G_TYPE_CHECK_INSTANCE_TYPE (_tmp314_, GXML_TYPE_TEXT)) {
				GXmlNode* _tmp315_;
				gchar* _tmp316_;
				gchar* _tmp317_;
				gchar* _tmp318_;
				_tmp315_ = n;
				_tmp316_ = gxml_node_get_value (_tmp315_);
				_tmp317_ = _tmp316_;
				_tmp318_ = _tmp317_;
				size = size + xmlTextWriterWriteString (tw, (xmlChar*) _tmp318_);
				_g_free0 (_tmp318_);
				if (size > 1500) {
					xmlTextWriterFlush (tw);
				}
			}
			_tmp319_ = n;
			if (G_TYPE_CHECK_INSTANCE_TYPE (_tmp319_, GXML_TYPE_COMMENT)) {
				GXmlNode* _tmp320_;
				gchar* _tmp321_;
				gchar* _tmp322_;
				gchar* _tmp323_;
				_tmp320_ = n;
				_tmp321_ = gxml_node_get_value (_tmp320_);
				_tmp322_ = _tmp321_;
				_tmp323_ = _tmp322_;
				size = size + xmlTextWriterWriteComment (tw, (xmlChar*) _tmp323_);
				_g_free0 (_tmp323_);
				if (size > 1500) {
					xmlTextWriterFlush (tw);
				}
			}
			_tmp324_ = n;
			if (G_TYPE_CHECK_INSTANCE_TYPE (_tmp324_, GXML_TYPE_CDATA)) {
				GXmlNode* _tmp325_;
				gchar* _tmp326_;
				gchar* _tmp327_;
				gchar* _tmp328_;
				_tmp325_ = n;
				_tmp326_ = gxml_node_get_value (_tmp325_);
				_tmp327_ = _tmp326_;
				_tmp328_ = _tmp327_;
				size = size + xmlTextWriterWriteCDATA (tw, (xmlChar*) _tmp328_);
				_g_free0 (_tmp328_);
				if (size > 1500) {
					xmlTextWriterFlush (tw);
				}
			}
			_tmp329_ = n;
			if (G_TYPE_CHECK_INSTANCE_TYPE (_tmp329_, GXML_TYPE_PROCESSING_INSTRUCTION)) {
				GXmlNode* _tmp330_;
				gchar* _tmp331_;
				gchar* _tmp332_;
				gchar* _tmp333_;
				GXmlNode* _tmp334_;
				gchar* _tmp335_;
				gchar* _tmp336_;
				gchar* _tmp337_;
				_tmp330_ = n;
				_tmp331_ = gxml_processing_instruction_get_target (G_TYPE_CHECK_INSTANCE_CAST (_tmp330_, GXML_TYPE_PROCESSING_INSTRUCTION, GXmlProcessingInstruction));
				_tmp332_ = _tmp331_;
				_tmp333_ = _tmp332_;
				_tmp334_ = n;
				_tmp335_ = gxml_processing_instruction_get_data (G_TYPE_CHECK_INSTANCE_CAST (_tmp334_, GXML_TYPE_PROCESSING_INSTRUCTION, GXmlProcessingInstruction));
				_tmp336_ = _tmp335_;
				_tmp337_ = _tmp336_;
				size = size + xmlTextWriterWritePI (tw, (xmlChar*) _tmp333_, (xmlChar*) _tmp337_);
				_g_free0 (_tmp337_);
				_g_free0 (_tmp333_);
				if (size > 1500) {
					xmlTextWriterFlush (tw);
				}
			}
			_g_object_unref0 (n);
		}
		_g_object_unref0 (_n_list);
	}
}

static gchar*
gxml_tdocument_real_to_string (GXmlTNode* base)
{
	GXmlTDocument * self;
	gchar* result = NULL;
	GError* _inner_error0_ = NULL;
	self = (GXmlTDocument*) base;
	{
		xmlDoc* doc = NULL;
		xmlTextWriter* tw = NULL;
		xmlTextWriter* _tmp0_;
		gchar* str = NULL;
		gint size = 0;
		xmlDoc* _tmp1_;
		gchar* _tmp2_ = NULL;
		gint _tmp3_ = 0;
		doc = NULL;
		_tmp0_ = xmlNewTextWriterDoc (&doc, FALSE);
		tw = _tmp0_;
		gxml_tdocument_write_document ((GXmlDocument*) self, tw, &_inner_error0_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			_xmlFreeTextWriter0 (tw);
			_xmlFreeDoc0 (doc);
			goto __catch9_g_error;
		}
		_tmp1_ = doc;
		xmlDocDumpMemory (_tmp1_, (xmlChar**) (&_tmp2_), &_tmp3_);
		_g_free0 (str);
		str = _tmp2_;
		size = _tmp3_;
		result = str;
		_xmlFreeTextWriter0 (tw);
		_xmlFreeDoc0 (doc);
		return result;
	}
	goto __finally9;
	__catch9_g_error:
	{
		GError* e = NULL;
		GError* _tmp4_;
		const gchar* _tmp5_;
		gchar* _tmp6_;
		e = _inner_error0_;
		_inner_error0_ = NULL;
		_tmp4_ = e;
		_tmp5_ = _tmp4_->message;
		_tmp6_ = g_strconcat ("ERROR: ", _tmp5_, NULL);
		result = _tmp6_;
		_g_error_free0 (e);
		return result;
	}
	__finally9:
	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;
}

/**
   * Read a {@link GXml.Document} from a {@link GLib.File}, parsing is controller
   * using {@link ReadTypeFunc}, if null it parse all nodes.
   */
void
gxml_tdocument_read_doc (GXmlDocument* doc,
                         GFile* file,
                         GXmlTDocumentReadTypeFunc rtfunc,
                         gpointer rtfunc_target,
                         GError** error)
{
	GFileInputStream* istream = NULL;
	GFileInputStream* _tmp1_;
	GFileInputStream* _tmp2_;
	GFileInputStream* _tmp3_;
	GError* _inner_error0_ = NULL;
	g_return_if_fail (doc != NULL);
	g_return_if_fail (file != NULL);
	if (!g_file_query_exists (file, NULL)) {
		GError* _tmp0_;
		_tmp0_ = g_error_new_literal (GXML_DOCUMENT_ERROR, GXML_DOCUMENT_ERROR_INVALID_FILE, _ ("File doesn't exist"));
		_inner_error0_ = _tmp0_;
		g_propagate_error (error, _inner_error0_);
		return;
	}
	_tmp1_ = g_file_read (file, NULL, &_inner_error0_);
	istream = _tmp1_;
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		g_propagate_error (error, _inner_error0_);
		return;
	}
	_tmp2_ = istream;
	gxml_tdocument_read_doc_stream (doc, (GInputStream*) _tmp2_, rtfunc, rtfunc_target, &_inner_error0_);
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		g_propagate_error (error, _inner_error0_);
		_g_object_unref0 (istream);
		return;
	}
	_tmp3_ = istream;
	g_input_stream_close ((GInputStream*) _tmp3_, NULL, &_inner_error0_);
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		g_propagate_error (error, _inner_error0_);
		_g_object_unref0 (istream);
		return;
	}
	_g_object_unref0 (istream);
}

/**
   * Reads document from {@link GLib.InputStream} objects.
   */
void
gxml_tdocument_read_doc_stream (GXmlDocument* doc,
                                GInputStream* istream,
                                GXmlTDocumentReadTypeFunc rtfunc,
                                gpointer rtfunc_target,
                                GError** error)
{
	GMemoryOutputStream* b = NULL;
	GMemoryOutputStream* _tmp0_;
	GMemoryOutputStream* _tmp1_;
	xmlTextReader* tr = NULL;
	GMemoryOutputStream* _tmp2_;
	void* _tmp3_;
	void* _tmp4_;
	GMemoryOutputStream* _tmp5_;
	xmlTextReader* _tmp6_;
	GError* _inner_error0_ = NULL;
	g_return_if_fail (doc != NULL);
	g_return_if_fail (istream != NULL);
	_tmp0_ = (GMemoryOutputStream*) g_memory_output_stream_new_resizable ();
	b = _tmp0_;
	_tmp1_ = b;
	g_output_stream_splice ((GOutputStream*) _tmp1_, istream, 0, NULL, &_inner_error0_);
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		g_propagate_error (error, _inner_error0_);
		_g_object_unref0 (b);
		return;
	}
	_tmp2_ = b;
	_tmp3_ = g_memory_output_stream_get_data (_tmp2_);
	_tmp4_ = _tmp3_;
	_tmp5_ = b;
	_tmp6_ = xmlReaderForMemory ((gchar*) _tmp4_, (gint) g_memory_output_stream_get_data_size (_tmp5_), "/gxml_memory", NULL, 0);
	tr = _tmp6_;
	while (TRUE) {
		GXmlTDocumentReadType _tmp7_ = 0;
		xmlTextReader* _tmp8_;
		_tmp8_ = tr;
		_tmp7_ = gxml_tdocument_read_node ((GXmlNode*) doc, _tmp8_, rtfunc, rtfunc_target, &_inner_error0_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			g_propagate_error (error, _inner_error0_);
			_xmlFreeTextReader0 (tr);
			_g_object_unref0 (b);
			return;
		}
		if (!(_tmp7_ == GXML_TDOCUMENT_READ_TYPE_CONTINUE)) {
			break;
		}
	}
	_xmlFreeTextReader0 (tr);
	tr = NULL;
	_xmlFreeTextReader0 (tr);
	_g_object_unref0 (b);
}

/**
   * Parse current node in {@link Xml.TextReader}.
   *
   * Returns: a {@link GXml.Node} respresenting current parsed one.
   */
GXmlTDocumentReadType
gxml_tdocument_read_node (GXmlNode* node,
                          xmlTextReader* tr,
                          GXmlTDocumentReadTypeFunc rntfunc,
                          gpointer rntfunc_target,
                          GError** error)
{
	GXmlTDocumentReadType result = 0;
	GXmlNode* n = NULL;
	gchar* prefix = NULL;
	gchar* nsuri = NULL;
	GXmlTDocumentReadType rt = 0;
	GXmlTDocumentReadType _tmp0_;
	GXmlTDocumentReadType _tmp1_;
	gint t = 0;
	GError* _inner_error0_ = NULL;
	g_return_val_if_fail (node != NULL, 0);
	g_return_val_if_fail (tr != NULL, 0);
	n = NULL;
	rt = GXML_TDOCUMENT_READ_TYPE_CONTINUE;
	if (rntfunc != NULL) {
		rt = rntfunc (node, tr, rntfunc_target);
	}
	_tmp0_ = rt;
	if (_tmp0_ == GXML_TDOCUMENT_READ_TYPE_CONTINUE) {
		if (xmlTextReaderRead (tr) != 1) {
			result = GXML_TDOCUMENT_READ_TYPE_STOP;
			_g_free0 (nsuri);
			_g_free0 (prefix);
			_g_object_unref0 (n);
			return result;
		}
	}
	_tmp1_ = rt;
	if (_tmp1_ == GXML_TDOCUMENT_READ_TYPE_NEXT) {
		if (xmlTextReaderNext (tr) != 1) {
			result = GXML_TDOCUMENT_READ_TYPE_STOP;
			_g_free0 (nsuri);
			_g_free0 (prefix);
			_g_object_unref0 (n);
			return result;
		}
	}
	t = xmlTextReaderNodeType (tr);
	switch (t) {
		case XML_READER_TYPE_NONE:
		{
			if (xmlTextReaderRead (tr) != 1) {
				result = GXML_TDOCUMENT_READ_TYPE_STOP;
				_g_free0 (nsuri);
				_g_free0 (prefix);
				_g_object_unref0 (n);
				return result;
			}
			break;
		}
		case XML_READER_TYPE_ELEMENT:
		{
			gboolean isempty = FALSE;
			GXmlNode* _tmp2_ = NULL;
			GXmlDocument* _tmp3_;
			GXmlDocument* _tmp4_;
			const gchar* _tmp5_;
			GXmlNode* _tmp6_;
			GXmlNode* _tmp7_;
			GXmlTDocumentReadType nrt = 0;
			GXmlTDocumentReadType _tmp9_;
			GXmlTDocumentReadType _tmp16_;
			GeeBidirList* _tmp17_;
			GeeBidirList* _tmp18_;
			GeeBidirList* _tmp19_;
			GXmlNode* _tmp20_;
			gchar* _tmp21_;
			const gchar* _tmp22_;
			gint nattr = 0;
			isempty = xmlTextReaderIsEmptyElement (tr) == 1;
			_tmp3_ = gxml_node_get_document (node);
			_tmp4_ = _tmp3_;
			_tmp5_ = (const gchar*) xmlTextReaderConstLocalName (tr);
			_tmp6_ = gxml_document_create_element (_tmp4_, _tmp5_, &_inner_error0_);
			_tmp2_ = _tmp6_;
			if (G_UNLIKELY (_inner_error0_ != NULL)) {
				g_propagate_error (error, _inner_error0_);
				_g_free0 (nsuri);
				_g_free0 (prefix);
				_g_object_unref0 (n);
				return 0;
			}
			_tmp7_ = _tmp2_;
			_tmp2_ = NULL;
			_g_object_unref0 (n);
			n = _tmp7_;
			nrt = GXML_TDOCUMENT_READ_TYPE_CONTINUE;
			if (rntfunc != NULL) {
				GXmlNode* _tmp8_;
				_tmp8_ = n;
				nrt = rntfunc (_tmp8_, tr, rntfunc_target);
			}
			_tmp9_ = nrt;
			if (_tmp9_ == GXML_TDOCUMENT_READ_TYPE_NEXT) {
				gboolean cont = FALSE;
				if (isempty) {
					result = GXML_TDOCUMENT_READ_TYPE_CONTINUE;
					_g_object_unref0 (_tmp2_);
					_g_free0 (nsuri);
					_g_free0 (prefix);
					_g_object_unref0 (n);
					return result;
				}
				cont = TRUE;
				while (TRUE) {
					if (!cont) {
						break;
					}
					if (xmlTextReaderRead (tr) != 1) {
						result = GXML_TDOCUMENT_READ_TYPE_STOP;
						_g_object_unref0 (_tmp2_);
						_g_free0 (nsuri);
						_g_free0 (prefix);
						_g_object_unref0 (n);
						return result;
					}
					t = xmlTextReaderNodeType (tr);
					if (t == ((gint) XML_READER_TYPE_END_ELEMENT)) {
						const gchar* _tmp10_;
						GXmlNode* _tmp11_;
						gchar* _tmp12_;
						gchar* _tmp13_;
						gchar* _tmp14_;
						gboolean _tmp15_;
						_tmp10_ = (const gchar*) xmlTextReaderConstLocalName (tr);
						_tmp11_ = n;
						_tmp12_ = gxml_node_get_name (_tmp11_);
						_tmp13_ = _tmp12_;
						_tmp14_ = _tmp13_;
						_tmp15_ = g_strcmp0 (_tmp10_, _tmp14_) == 0;
						_g_free0 (_tmp14_);
						if (_tmp15_) {
							cont = FALSE;
						}
					}
				}
				result = GXML_TDOCUMENT_READ_TYPE_CONTINUE;
				_g_object_unref0 (_tmp2_);
				_g_free0 (nsuri);
				_g_free0 (prefix);
				_g_object_unref0 (n);
				return result;
			}
			_tmp16_ = nrt;
			if (_tmp16_ == GXML_TDOCUMENT_READ_TYPE_STOP) {
				result = GXML_TDOCUMENT_READ_TYPE_STOP;
				_g_object_unref0 (_tmp2_);
				_g_free0 (nsuri);
				_g_free0 (prefix);
				_g_object_unref0 (n);
				return result;
			}
			_tmp17_ = gxml_node_get_children_nodes (node);
			_tmp18_ = _tmp17_;
			_tmp19_ = _tmp18_;
			_tmp20_ = n;
			gee_collection_add ((GeeCollection*) _tmp19_, _tmp20_);
			_g_object_unref0 (_tmp19_);
			_tmp21_ = (gchar*) xmlTextReaderPrefix (tr);
			_g_free0 (prefix);
			prefix = _tmp21_;
			_tmp22_ = prefix;
			if (_tmp22_ != NULL) {
				const gchar* _tmp23_;
				gchar* _tmp24_;
				const gchar* _tmp25_;
				_tmp23_ = prefix;
				_tmp24_ = (gchar*) xmlTextReaderLookupNamespace (tr, (xmlChar*) _tmp23_);
				_g_free0 (nsuri);
				nsuri = _tmp24_;
				_tmp25_ = nsuri;
				if (_tmp25_ != NULL) {
					GXmlNode* _tmp26_;
					const gchar* _tmp27_;
					const gchar* _tmp28_;
					_tmp26_ = n;
					_tmp27_ = nsuri;
					_tmp28_ = prefix;
					gxml_node_set_namespace (_tmp26_, _tmp27_, _tmp28_);
				}
			}
			nattr = xmlTextReaderAttributeCount (tr);
			{
				gint i = 0;
				i = 0;
				{
					gboolean _tmp29_ = FALSE;
					_tmp29_ = TRUE;
					while (TRUE) {
						gint c = 0;
						if (!_tmp29_) {
							gint _tmp30_;
							_tmp30_ = i;
							i = _tmp30_ + 1;
						}
						_tmp29_ = FALSE;
						if (!(i < nattr)) {
							break;
						}
						c = xmlTextReaderMoveToAttributeNo (tr, i);
						if (c != 1) {
							gchar* _tmp31_;
							gchar* _tmp32_;
							GError* _tmp33_;
							GError* _tmp34_;
							_tmp31_ = g_strdup_printf (_ ("Parsing ERROR: Fail to move to attribute number: %i"), i);
							_tmp32_ = _tmp31_;
							_tmp33_ = g_error_new_literal (GXML_DOCUMENT_ERROR, GXML_DOCUMENT_ERROR_INVALID_DOCUMENT_ERROR, _tmp32_);
							_tmp34_ = _tmp33_;
							_g_free0 (_tmp32_);
							_inner_error0_ = _tmp34_;
							g_propagate_error (error, _inner_error0_);
							_g_object_unref0 (_tmp2_);
							_g_free0 (nsuri);
							_g_free0 (prefix);
							_g_object_unref0 (n);
							return 0;
						}
						if (xmlTextReaderIsNamespaceDecl (tr) == 1) {
							gchar* nsp = NULL;
							const gchar* _tmp35_;
							gchar* _tmp36_;
							_tmp35_ = (const gchar*) xmlTextReaderConstLocalName (tr);
							_tmp36_ = g_strdup (_tmp35_);
							nsp = _tmp36_;
							xmlTextReaderReadAttributeValue (tr);
							if (xmlTextReaderNodeType (tr) == ((gint) XML_READER_TYPE_TEXT)) {
								gchar* _tmp37_;
								GXmlNode* _tmp38_;
								const gchar* _tmp39_;
								const gchar* _tmp40_;
								_tmp37_ = (gchar*) xmlTextReaderReadString (tr);
								_g_free0 (nsuri);
								nsuri = _tmp37_;
								_tmp38_ = n;
								_tmp39_ = nsuri;
								_tmp40_ = nsp;
								gxml_node_set_namespace (_tmp38_, _tmp39_, _tmp40_);
							}
							_g_free0 (nsp);
						} else {
							gchar* attrname = NULL;
							const gchar* _tmp41_;
							gchar* _tmp42_;
							gchar* _tmp43_;
							_tmp41_ = (const gchar*) xmlTextReaderConstLocalName (tr);
							_tmp42_ = g_strdup (_tmp41_);
							attrname = _tmp42_;
							_tmp43_ = (gchar*) xmlTextReaderPrefix (tr);
							_g_free0 (prefix);
							prefix = _tmp43_;
							xmlTextReaderReadAttributeValue (tr);
							if (xmlTextReaderNodeType (tr) == ((gint) XML_READER_TYPE_TEXT)) {
								gchar* attrval = NULL;
								gchar* _tmp44_;
								const gchar* _tmp45_;
								_tmp44_ = (gchar*) xmlTextReaderReadString (tr);
								attrval = _tmp44_;
								_tmp45_ = prefix;
								if (_tmp45_ != NULL) {
									const gchar* _tmp46_;
									gchar* _tmp47_;
									const gchar* _tmp48_;
									_tmp46_ = prefix;
									_tmp47_ = (gchar*) xmlTextReaderLookupNamespace (tr, (xmlChar*) _tmp46_);
									_g_free0 (nsuri);
									nsuri = _tmp47_;
									_tmp48_ = nsuri;
									if (_tmp48_ != NULL) {
										GXmlNode* _tmp49_;
										const gchar* _tmp50_;
										gchar* _tmp51_;
										gchar* _tmp52_;
										const gchar* _tmp53_;
										gchar* _tmp54_;
										gchar* _tmp55_;
										const gchar* _tmp56_;
										const gchar* _tmp57_;
										_tmp49_ = n;
										_tmp50_ = prefix;
										_tmp51_ = g_strconcat (_tmp50_, ":", NULL);
										_tmp52_ = _tmp51_;
										_tmp53_ = nsuri;
										_tmp54_ = g_strconcat (_tmp52_, _tmp53_, NULL);
										_tmp55_ = _tmp54_;
										_tmp56_ = attrname;
										_tmp57_ = attrval;
										gxml_element_set_ns_attr (G_TYPE_CHECK_INSTANCE_TYPE (_tmp49_, GXML_TYPE_ELEMENT) ? ((GXmlElement*) _tmp49_) : NULL, _tmp55_, _tmp56_, _tmp57_);
										_g_free0 (_tmp55_);
										_g_free0 (_tmp52_);
									}
								} else {
									GXmlNode* _tmp58_;
									const gchar* _tmp59_;
									const gchar* _tmp60_;
									_tmp58_ = n;
									_tmp59_ = attrname;
									_tmp60_ = attrval;
									gxml_element_set_attr (G_TYPE_CHECK_INSTANCE_TYPE (_tmp58_, GXML_TYPE_ELEMENT) ? ((GXmlElement*) _tmp58_) : NULL, _tmp59_, _tmp60_);
								}
								_g_free0 (attrval);
							}
							_g_free0 (attrname);
						}
					}
				}
			}
			if (isempty) {
				result = GXML_TDOCUMENT_READ_TYPE_CONTINUE;
				_g_object_unref0 (_tmp2_);
				_g_free0 (nsuri);
				_g_free0 (prefix);
				_g_object_unref0 (n);
				return result;
			}
			while (TRUE) {
				GXmlTDocumentReadType _tmp61_ = 0;
				GXmlNode* _tmp62_;
				_tmp62_ = n;
				_tmp61_ = gxml_tdocument_read_node (_tmp62_, tr, rntfunc, rntfunc_target, &_inner_error0_);
				if (G_UNLIKELY (_inner_error0_ != NULL)) {
					g_propagate_error (error, _inner_error0_);
					_g_object_unref0 (_tmp2_);
					_g_free0 (nsuri);
					_g_free0 (prefix);
					_g_object_unref0 (n);
					return 0;
				}
				if (!(_tmp61_ == GXML_TDOCUMENT_READ_TYPE_CONTINUE)) {
					break;
				}
			}
			_g_object_unref0 (_tmp2_);
			break;
		}
		case XML_READER_TYPE_ATTRIBUTE:
		{
			break;
		}
		case XML_READER_TYPE_TEXT:
		{
			gchar* txtval = NULL;
			gchar* _tmp63_;
			GXmlDocument* _tmp64_;
			GXmlDocument* _tmp65_;
			const gchar* _tmp66_;
			GXmlNode* _tmp67_;
			GeeBidirList* _tmp68_;
			GeeBidirList* _tmp69_;
			GeeBidirList* _tmp70_;
			GXmlNode* _tmp71_;
			_tmp63_ = (gchar*) xmlTextReaderReadString (tr);
			txtval = _tmp63_;
			_tmp64_ = gxml_node_get_document (node);
			_tmp65_ = _tmp64_;
			_tmp66_ = txtval;
			_tmp67_ = gxml_document_create_text (_tmp65_, _tmp66_);
			_g_object_unref0 (n);
			n = _tmp67_;
			_tmp68_ = gxml_node_get_children_nodes (node);
			_tmp69_ = _tmp68_;
			_tmp70_ = _tmp69_;
			_tmp71_ = n;
			gee_collection_add ((GeeCollection*) _tmp70_, _tmp71_);
			_g_object_unref0 (_tmp70_);
			_g_free0 (txtval);
			break;
		}
		case XML_READER_TYPE_CDATA:
		{
			gchar* cdval = NULL;
			gchar* _tmp72_;
			GXmlDocument* _tmp73_;
			GXmlDocument* _tmp74_;
			const gchar* _tmp75_;
			GXmlNode* _tmp76_;
			GeeBidirList* _tmp77_;
			GeeBidirList* _tmp78_;
			GeeBidirList* _tmp79_;
			GXmlNode* _tmp80_;
			_tmp72_ = (gchar*) xmlTextReaderValue (tr);
			cdval = _tmp72_;
			_tmp73_ = gxml_node_get_document (node);
			_tmp74_ = _tmp73_;
			_tmp75_ = cdval;
			_tmp76_ = gxml_document_create_cdata (_tmp74_, _tmp75_);
			_g_object_unref0 (n);
			n = _tmp76_;
			_tmp77_ = gxml_node_get_children_nodes (node);
			_tmp78_ = _tmp77_;
			_tmp79_ = _tmp78_;
			_tmp80_ = n;
			gee_collection_add ((GeeCollection*) _tmp79_, _tmp80_);
			_g_object_unref0 (_tmp79_);
			_g_free0 (cdval);
			break;
		}
		case XML_READER_TYPE_ENTITY_REFERENCE:
		{
			break;
		}
		case XML_READER_TYPE_ENTITY:
		{
			break;
		}
		case XML_READER_TYPE_PROCESSING_INSTRUCTION:
		{
			gchar* pit = NULL;
			const gchar* _tmp81_;
			gchar* _tmp82_;
			gchar* pival = NULL;
			gchar* _tmp83_;
			GXmlDocument* _tmp84_;
			GXmlDocument* _tmp85_;
			const gchar* _tmp86_;
			const gchar* _tmp87_;
			GXmlNode* _tmp88_;
			GeeBidirList* _tmp89_;
			GeeBidirList* _tmp90_;
			GeeBidirList* _tmp91_;
			GXmlNode* _tmp92_;
			_tmp81_ = (const gchar*) xmlTextReaderConstLocalName (tr);
			_tmp82_ = g_strdup (_tmp81_);
			pit = _tmp82_;
			_tmp83_ = (gchar*) xmlTextReaderValue (tr);
			pival = _tmp83_;
			_tmp84_ = gxml_node_get_document (node);
			_tmp85_ = _tmp84_;
			_tmp86_ = pit;
			_tmp87_ = pival;
			_tmp88_ = gxml_document_create_pi (_tmp85_, _tmp86_, _tmp87_);
			_g_object_unref0 (n);
			n = _tmp88_;
			_tmp89_ = gxml_node_get_children_nodes (node);
			_tmp90_ = _tmp89_;
			_tmp91_ = _tmp90_;
			_tmp92_ = n;
			gee_collection_add ((GeeCollection*) _tmp91_, _tmp92_);
			_g_object_unref0 (_tmp91_);
			_g_free0 (pival);
			_g_free0 (pit);
			break;
		}
		case XML_READER_TYPE_COMMENT:
		{
			gchar* commval = NULL;
			gchar* _tmp93_;
			GXmlDocument* _tmp94_;
			GXmlDocument* _tmp95_;
			const gchar* _tmp96_;
			GXmlNode* _tmp97_;
			GeeBidirList* _tmp98_;
			GeeBidirList* _tmp99_;
			GeeBidirList* _tmp100_;
			GXmlNode* _tmp101_;
			_tmp93_ = (gchar*) xmlTextReaderValue (tr);
			commval = _tmp93_;
			_tmp94_ = gxml_node_get_document (node);
			_tmp95_ = _tmp94_;
			_tmp96_ = commval;
			_tmp97_ = gxml_document_create_comment (_tmp95_, _tmp96_);
			_g_object_unref0 (n);
			n = _tmp97_;
			_tmp98_ = gxml_node_get_children_nodes (node);
			_tmp99_ = _tmp98_;
			_tmp100_ = _tmp99_;
			_tmp101_ = n;
			gee_collection_add ((GeeCollection*) _tmp100_, _tmp101_);
			_g_object_unref0 (_tmp100_);
			_g_free0 (commval);
			break;
		}
		case XML_READER_TYPE_DOCUMENT:
		{
			break;
		}
		case XML_READER_TYPE_DOCUMENT_TYPE:
		{
			break;
		}
		case XML_READER_TYPE_DOCUMENT_FRAGMENT:
		{
			break;
		}
		case XML_READER_TYPE_NOTATION:
		{
			break;
		}
		case XML_READER_TYPE_WHITESPACE:
		{
			break;
		}
		case XML_READER_TYPE_SIGNIFICANT_WHITESPACE:
		{
			break;
		}
		case XML_READER_TYPE_END_ELEMENT:
		{
			result = GXML_TDOCUMENT_READ_TYPE_STOP;
			_g_free0 (nsuri);
			_g_free0 (prefix);
			_g_object_unref0 (n);
			return result;
		}
		case XML_READER_TYPE_END_ENTITY:
		{
			result = GXML_TDOCUMENT_READ_TYPE_STOP;
			_g_free0 (nsuri);
			_g_free0 (prefix);
			_g_object_unref0 (n);
			return result;
		}
		case XML_READER_TYPE_XML_DECLARATION:
		{
			break;
		}
		default:
		break;
	}
	result = GXML_TDOCUMENT_READ_TYPE_CONTINUE;
	_g_free0 (nsuri);
	_g_free0 (prefix);
	_g_object_unref0 (n);
	return result;
}

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

static GeeList*
gxml_tdocument_real_get_namespaces (GXmlTNode* base)
{
	GeeList* result;
	GXmlTDocument* self;
	GeeArrayList* _tmp0_;
	GeeArrayList* _tmp2_;
	GObject* _tmp3_;
	GeeList* _tmp4_;
	self = (GXmlTDocument*) base;
	_tmp0_ = self->_namespaces;
	if (_tmp0_ == NULL) {
		GeeArrayList* _tmp1_;
		_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 GeeBidirList*
gxml_tdocument_real_get_children_nodes (GXmlTNode* base)
{
	GeeBidirList* result;
	GXmlTDocument* self;
	GeeArrayList* _tmp0_;
	GeeArrayList* _tmp2_;
	GObject* _tmp3_;
	GeeBidirList* _tmp4_;
	self = (GXmlTDocument*) base;
	_tmp0_ = self->_children;
	if (_tmp0_ == NULL) {
		GeeArrayList* _tmp1_;
		_tmp1_ = gee_array_list_new (GXML_TYPE_NODE, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, NULL, NULL, NULL);
		_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 GXmlDocument*
gxml_tdocument_real_get_document (GXmlTNode* base)
{
	GXmlDocument* result;
	GXmlTDocument* self;
	self = (GXmlTDocument*) base;
	result = (GXmlDocument*) self;
	return result;
}

static gboolean
gxml_tdocument_real_get_indent (GXmlDocument* base)
{
	gboolean result;
	GXmlTDocument* self;
	self = (GXmlTDocument*) base;
	result = self->priv->_indent;
	return result;
}

static void
gxml_tdocument_real_set_indent (GXmlDocument* base,
                                gboolean value)
{
	GXmlTDocument* self;
	self = (GXmlTDocument*) base;
	if (gxml_tdocument_real_get_indent (base) != value) {
		self->priv->_indent = value;
		g_object_notify_by_pspec ((GObject *) self, gxml_tdocument_properties[GXML_TDOCUMENT_INDENT_PROPERTY]);
	}
}

static gboolean
gxml_tdocument_real_get_ns_top (GXmlDocument* base)
{
	gboolean result;
	GXmlTDocument* self;
	self = (GXmlTDocument*) base;
	result = self->priv->_ns_top;
	return result;
}

static void
gxml_tdocument_real_set_ns_top (GXmlDocument* base,
                                gboolean value)
{
	GXmlTDocument* self;
	self = (GXmlTDocument*) base;
	if (gxml_tdocument_real_get_ns_top (base) != value) {
		self->priv->_ns_top = value;
		g_object_notify_by_pspec ((GObject *) self, gxml_tdocument_properties[GXML_TDOCUMENT_NS_TOP_PROPERTY]);
	}
}

static gboolean
gxml_tdocument_real_get_prefix_default_ns (GXmlDocument* base)
{
	gboolean result;
	GXmlTDocument* self;
	self = (GXmlTDocument*) base;
	result = self->priv->_prefix_default_ns;
	return result;
}

static void
gxml_tdocument_real_set_prefix_default_ns (GXmlDocument* base,
                                           gboolean value)
{
	GXmlTDocument* self;
	self = (GXmlTDocument*) base;
	if (gxml_tdocument_real_get_prefix_default_ns (base) != value) {
		self->priv->_prefix_default_ns = value;
		g_object_notify_by_pspec ((GObject *) self, gxml_tdocument_properties[GXML_TDOCUMENT_PREFIX_DEFAULT_NS_PROPERTY]);
	}
}

static gboolean
gxml_tdocument_real_get_backup (GXmlDocument* base)
{
	gboolean result;
	GXmlTDocument* self;
	self = (GXmlTDocument*) base;
	result = self->priv->_backup;
	return result;
}

static void
gxml_tdocument_real_set_backup (GXmlDocument* base,
                                gboolean value)
{
	GXmlTDocument* self;
	self = (GXmlTDocument*) base;
	if (gxml_tdocument_real_get_backup (base) != value) {
		self->priv->_backup = value;
		g_object_notify_by_pspec ((GObject *) self, gxml_tdocument_properties[GXML_TDOCUMENT_BACKUP_PROPERTY]);
	}
}

static GFile*
gxml_tdocument_real_get_file (GXmlDocument* base)
{
	GFile* result;
	GXmlTDocument* self;
	GFile* _tmp0_;
	self = (GXmlTDocument*) base;
	_tmp0_ = self->priv->_file;
	result = _tmp0_;
	return result;
}

static void
gxml_tdocument_real_set_file (GXmlDocument* base,
                              GFile* value)
{
	GXmlTDocument* self;
	self = (GXmlTDocument*) base;
	if (gxml_tdocument_real_get_file (base) != value) {
		GFile* _tmp0_;
		_tmp0_ = _g_object_ref0 (value);
		_g_object_unref0 (self->priv->_file);
		self->priv->_file = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, gxml_tdocument_properties[GXML_TDOCUMENT_FILE_PROPERTY]);
	}
}

static GXmlNode*
gxml_tdocument_real_get_root (GXmlDocument* base)
{
	GXmlNode* result;
	GXmlTDocument* self;
	GeeArrayList* _tmp0_;
	GXmlElement* _tmp2_;
	GXmlElement* _tmp20_;
	GXmlNode* _tmp21_;
	self = (GXmlTDocument*) base;
	_tmp0_ = self->_children;
	if (_tmp0_ == NULL) {
		GeeArrayList* _tmp1_;
		_tmp1_ = gee_array_list_new (GXML_TYPE_NODE, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, NULL, NULL, NULL);
		_g_object_unref0 (self->_children);
		self->_children = _tmp1_;
	}
	_tmp2_ = self->priv->_root;
	if (_tmp2_ == NULL) {
		gint found = 0;
		found = 0;
		{
			gint i = 0;
			i = 0;
			{
				gboolean _tmp3_ = FALSE;
				_tmp3_ = TRUE;
				while (TRUE) {
					GeeBidirList* _tmp5_;
					GeeBidirList* _tmp6_;
					GeeBidirList* _tmp7_;
					gint _tmp8_;
					gint _tmp9_;
					gboolean _tmp10_;
					GXmlNode* n = NULL;
					GeeBidirList* _tmp11_;
					GeeBidirList* _tmp12_;
					GeeBidirList* _tmp13_;
					gpointer _tmp14_;
					GXmlNode* _tmp15_;
					GXmlNode* _tmp16_;
					if (!_tmp3_) {
						gint _tmp4_;
						_tmp4_ = i;
						i = _tmp4_ + 1;
					}
					_tmp3_ = FALSE;
					_tmp5_ = gxml_tnode_get_children_nodes ((GXmlTNode*) self);
					_tmp6_ = _tmp5_;
					_tmp7_ = _tmp6_;
					_tmp8_ = gee_collection_get_size ((GeeCollection*) _tmp7_);
					_tmp9_ = _tmp8_;
					_tmp10_ = !(i < _tmp9_);
					_g_object_unref0 (_tmp7_);
					if (_tmp10_) {
						break;
					}
					_tmp11_ = gxml_tnode_get_children_nodes ((GXmlTNode*) self);
					_tmp12_ = _tmp11_;
					_tmp13_ = _tmp12_;
					_tmp14_ = gee_list_get ((GeeList*) _tmp13_, i);
					_tmp15_ = (GXmlNode*) _tmp14_;
					_g_object_unref0 (_tmp13_);
					n = _tmp15_;
					_tmp16_ = n;
					if (G_TYPE_CHECK_INSTANCE_TYPE (_tmp16_, GXML_TYPE_ELEMENT)) {
						gint _tmp17_;
						_tmp17_ = found;
						found = _tmp17_ + 1;
						if (found == 1) {
							GXmlNode* _tmp18_;
							GXmlElement* _tmp19_;
							_tmp18_ = n;
							_tmp19_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp18_, GXML_TYPE_ELEMENT, GXmlElement));
							_g_object_unref0 (self->priv->_root);
							self->priv->_root = _tmp19_;
						}
					}
					_g_object_unref0 (n);
				}
			}
		}
	}
	_tmp20_ = self->priv->_root;
	_tmp21_ = _g_object_ref0 ((GXmlNode*) _tmp20_);
	result = _tmp21_;
	return result;
}

static GObject *
gxml_tdocument_constructor (GType type,
                            guint n_construct_properties,
                            GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	GXmlTDocument * self;
	gchar* _tmp0_;
	parent_class = G_OBJECT_CLASS (gxml_tdocument_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GXML_TYPE_TDOCUMENT, GXmlTDocument);
	_tmp0_ = g_strdup ("#document");
	_g_free0 (((GXmlTNode*) self)->_name);
	((GXmlTNode*) self)->_name = _tmp0_;
	((GXmlTNode*) self)->_node_type = GXML_NODE_TYPE_DOCUMENT;
	return obj;
}

static void
gxml_tdocument_class_init (GXmlTDocumentClass * klass,
                           gpointer klass_data)
{
	gxml_tdocument_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &GXmlTDocument_private_offset);
	((GXmlTNodeClass *) klass)->set_namespace = (gboolean (*) (GXmlTNode*, const gchar*, const gchar*)) gxml_tdocument_real_set_namespace;
	((GXmlTNodeClass *) klass)->to_string = (gchar* (*) (GXmlTNode*)) gxml_tdocument_real_to_string;
	GXML_TNODE_CLASS (klass)->get_namespaces = gxml_tdocument_real_get_namespaces;
	GXML_TNODE_CLASS (klass)->get_children_nodes = gxml_tdocument_real_get_children_nodes;
	GXML_TNODE_CLASS (klass)->get_document = gxml_tdocument_real_get_document;
	G_OBJECT_CLASS (klass)->get_property = _vala_gxml_tdocument_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_gxml_tdocument_set_property;
	G_OBJECT_CLASS (klass)->constructor = gxml_tdocument_constructor;
	G_OBJECT_CLASS (klass)->finalize = gxml_tdocument_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), GXML_TDOCUMENT_NAMESPACES_PROPERTY, gxml_tdocument_properties[GXML_TDOCUMENT_NAMESPACES_PROPERTY] = g_param_spec_object ("namespaces", "namespaces", "namespaces", GEE_TYPE_LIST, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GXML_TDOCUMENT_CHILDREN_NODES_PROPERTY, gxml_tdocument_properties[GXML_TDOCUMENT_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_TDOCUMENT_DOCUMENT_PROPERTY, gxml_tdocument_properties[GXML_TDOCUMENT_DOCUMENT_PROPERTY] = g_param_spec_object ("document", "document", "document", GXML_TYPE_DOCUMENT, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GXML_TDOCUMENT_INDENT_PROPERTY, gxml_tdocument_properties[GXML_TDOCUMENT_INDENT_PROPERTY] = g_param_spec_boolean ("indent", "indent", "indent", FALSE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GXML_TDOCUMENT_NS_TOP_PROPERTY, gxml_tdocument_properties[GXML_TDOCUMENT_NS_TOP_PROPERTY] = g_param_spec_boolean ("ns-top", "ns-top", "ns-top", FALSE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GXML_TDOCUMENT_PREFIX_DEFAULT_NS_PROPERTY, gxml_tdocument_properties[GXML_TDOCUMENT_PREFIX_DEFAULT_NS_PROPERTY] = g_param_spec_boolean ("prefix-default-ns", "prefix-default-ns", "prefix-default-ns", FALSE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GXML_TDOCUMENT_BACKUP_PROPERTY, gxml_tdocument_properties[GXML_TDOCUMENT_BACKUP_PROPERTY] = g_param_spec_boolean ("backup", "backup", "backup", TRUE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GXML_TDOCUMENT_FILE_PROPERTY, gxml_tdocument_properties[GXML_TDOCUMENT_FILE_PROPERTY] = g_param_spec_object ("file", "file", "file", g_file_get_type (), G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GXML_TDOCUMENT_ROOT_PROPERTY, gxml_tdocument_properties[GXML_TDOCUMENT_ROOT_PROPERTY] = g_param_spec_object ("root", "root", "root", GXML_TYPE_NODE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
}

static void
gxml_tdocument_gxml_document_interface_init (GXmlDocumentIface * iface,
                                             gpointer iface_data)
{
	gxml_tdocument_gxml_document_parent_iface = g_type_interface_peek_parent (iface);
	iface->create_comment = (GXmlNode* (*) (GXmlDocument*, const gchar*)) gxml_tdocument_real_create_comment;
	iface->create_pi = (GXmlNode* (*) (GXmlDocument*, const gchar*, const gchar*)) gxml_tdocument_real_create_pi;
	iface->create_element = (GXmlNode* (*) (GXmlDocument*, const gchar*, GError**)) gxml_tdocument_real_create_element;
	iface->create_text = (GXmlNode* (*) (GXmlDocument*, const gchar*)) gxml_tdocument_real_create_text;
	iface->create_cdata = (GXmlNode* (*) (GXmlDocument*, const gchar*)) gxml_tdocument_real_create_cdata;
	iface->save = (gboolean (*) (GXmlDocument*, GCancellable*, GError**)) gxml_tdocument_real_save;
	iface->save_as = (gboolean (*) (GXmlDocument*, GFile*, GCancellable*, GError**)) gxml_tdocument_real_save_as;
	iface->get_indent = gxml_tdocument_real_get_indent;
	iface->set_indent = gxml_tdocument_real_set_indent;
	iface->get_ns_top = gxml_tdocument_real_get_ns_top;
	iface->set_ns_top = gxml_tdocument_real_set_ns_top;
	iface->get_prefix_default_ns = gxml_tdocument_real_get_prefix_default_ns;
	iface->set_prefix_default_ns = gxml_tdocument_real_set_prefix_default_ns;
	iface->get_backup = gxml_tdocument_real_get_backup;
	iface->set_backup = gxml_tdocument_real_set_backup;
	iface->get_file = gxml_tdocument_real_get_file;
	iface->set_file = gxml_tdocument_real_set_file;
	iface->get_root = gxml_tdocument_real_get_root;
}

static void
gxml_tdocument_instance_init (GXmlTDocument * self,
                              gpointer klass)
{
	self->priv = gxml_tdocument_get_instance_private (self);
	self->priv->_root = NULL;
	self->priv->_indent = FALSE;
	self->priv->_ns_top = FALSE;
	self->priv->_prefix_default_ns = FALSE;
	self->priv->_backup = TRUE;
}

static void
gxml_tdocument_finalize (GObject * obj)
{
	GXmlTDocument * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GXML_TYPE_TDOCUMENT, GXmlTDocument);
	_g_object_unref0 (self->_namespaces);
	_g_object_unref0 (self->_children);
	_g_object_unref0 (self->priv->_root);
	_g_object_unref0 (self->priv->_file);
	G_OBJECT_CLASS (gxml_tdocument_parent_class)->finalize (obj);
}

/**
 * DOM1 Class implemeting {@link GXml.Document} interface, not tied to libxml-2.0 library.
 *
 * This class use {@link Xml.TextWriter} to write down XML documents using
 * its contained {@link GXml.Node} children or other XML structures.
 */
GType
gxml_tdocument_get_type (void)
{
	static volatile gsize gxml_tdocument_type_id__volatile = 0;
	if (g_once_init_enter (&gxml_tdocument_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (GXmlTDocumentClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) gxml_tdocument_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GXmlTDocument), 0, (GInstanceInitFunc) gxml_tdocument_instance_init, NULL };
		static const GInterfaceInfo gxml_document_info = { (GInterfaceInitFunc) gxml_tdocument_gxml_document_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
		GType gxml_tdocument_type_id;
		gxml_tdocument_type_id = g_type_register_static (GXML_TYPE_TNODE, "GXmlTDocument", &g_define_type_info, 0);
		g_type_add_interface_static (gxml_tdocument_type_id, GXML_TYPE_DOCUMENT, &gxml_document_info);
		GXmlTDocument_private_offset = g_type_add_instance_private (gxml_tdocument_type_id, sizeof (GXmlTDocumentPrivate));
		g_once_init_leave (&gxml_tdocument_type_id__volatile, gxml_tdocument_type_id);
	}
	return gxml_tdocument_type_id__volatile;
}

static void
_vala_gxml_tdocument_get_property (GObject * object,
                                   guint property_id,
                                   GValue * value,
                                   GParamSpec * pspec)
{
	GXmlTDocument * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, GXML_TYPE_TDOCUMENT, GXmlTDocument);
	switch (property_id) {
		case GXML_TDOCUMENT_NAMESPACES_PROPERTY:
		g_value_take_object (value, gxml_tnode_get_namespaces ((GXmlTNode*) self));
		break;
		case GXML_TDOCUMENT_CHILDREN_NODES_PROPERTY:
		g_value_take_object (value, gxml_tnode_get_children_nodes ((GXmlTNode*) self));
		break;
		case GXML_TDOCUMENT_DOCUMENT_PROPERTY:
		g_value_set_object (value, gxml_tnode_get_document ((GXmlTNode*) self));
		break;
		case GXML_TDOCUMENT_INDENT_PROPERTY:
		g_value_set_boolean (value, gxml_document_get_indent ((GXmlDocument*) self));
		break;
		case GXML_TDOCUMENT_NS_TOP_PROPERTY:
		g_value_set_boolean (value, gxml_document_get_ns_top ((GXmlDocument*) self));
		break;
		case GXML_TDOCUMENT_PREFIX_DEFAULT_NS_PROPERTY:
		g_value_set_boolean (value, gxml_document_get_prefix_default_ns ((GXmlDocument*) self));
		break;
		case GXML_TDOCUMENT_BACKUP_PROPERTY:
		g_value_set_boolean (value, gxml_document_get_backup ((GXmlDocument*) self));
		break;
		case GXML_TDOCUMENT_FILE_PROPERTY:
		g_value_set_object (value, gxml_document_get_file ((GXmlDocument*) self));
		break;
		case GXML_TDOCUMENT_ROOT_PROPERTY:
		g_value_take_object (value, gxml_document_get_root ((GXmlDocument*) self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_gxml_tdocument_set_property (GObject * object,
                                   guint property_id,
                                   const GValue * value,
                                   GParamSpec * pspec)
{
	GXmlTDocument * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, GXML_TYPE_TDOCUMENT, GXmlTDocument);
	switch (property_id) {
		case GXML_TDOCUMENT_INDENT_PROPERTY:
		gxml_document_set_indent ((GXmlDocument*) self, g_value_get_boolean (value));
		break;
		case GXML_TDOCUMENT_NS_TOP_PROPERTY:
		gxml_document_set_ns_top ((GXmlDocument*) self, g_value_get_boolean (value));
		break;
		case GXML_TDOCUMENT_PREFIX_DEFAULT_NS_PROPERTY:
		gxml_document_set_prefix_default_ns ((GXmlDocument*) self, g_value_get_boolean (value));
		break;
		case GXML_TDOCUMENT_BACKUP_PROPERTY:
		gxml_document_set_backup ((GXmlDocument*) self, g_value_get_boolean (value));
		break;
		case GXML_TDOCUMENT_FILE_PROPERTY:
		gxml_document_set_file ((GXmlDocument*) self, g_value_get_object (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

