/* TDocument.c generated by valac 0.34.7, 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.h>
#include <glib-object.h>
#include <stdlib.h>
#include <string.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;

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

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

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

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

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

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

struct _GXmlTNode {
	GObject parent_instance;
	GXmlTNodePrivate * priv;
	gchar* _name;
	gchar* _value;
	GXmlDocument* _doc;
	GXmlNode* _parent;
	GXmlNodeType _node_type;
	xmlTextWriter* tw;
};

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

struct _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_TDOCUMENT_READ_TYPE_NEXT,
	GXML_TDOCUMENT_READ_TYPE_CONTINUE,
	GXML_TDOCUMENT_READ_TYPE_STOP
} GXmlTDocumentReadType;

typedef GXmlTDocumentReadType (*GXmlTDocumentReadTypeFunc) (GXmlNode* node, xmlTextReader* tr, void* user_data);
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 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;
#define GXML_TDOCUMENT_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GXML_TYPE_TDOCUMENT, GXmlTDocumentPrivate))
enum  {
	GXML_TDOCUMENT_DUMMY_PROPERTY,
	GXML_TDOCUMENT_NAMESPACES,
	GXML_TDOCUMENT_CHILDREN_NODES,
	GXML_TDOCUMENT_DOCUMENT,
	GXML_TDOCUMENT_INDENT,
	GXML_TDOCUMENT_NS_TOP,
	GXML_TDOCUMENT_PREFIX_DEFAULT_NS,
	GXML_TDOCUMENT_BACKUP,
	GXML_TDOCUMENT_FILE,
	GXML_TDOCUMENT_ROOT
};
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, void* 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, void* 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, void* func_target);
GXmlTDocument* gxml_tdocument_construct_from_path_with_readtype_func (GType object_type, const gchar* path, GXmlTDocumentReadTypeFunc func, void* func_target);
GXmlTDocument* gxml_tdocument_new_from_uri_with_readtype_func (const gchar* uri, GXmlTDocumentReadTypeFunc func, void* func_target);
GXmlTDocument* gxml_tdocument_construct_from_uri_with_readtype_func (GType object_type, const gchar* uri, GXmlTDocumentReadTypeFunc func, void* func_target);
GXmlTDocument* gxml_tdocument_new_from_file_with_readtype_func (GFile* file, GXmlTDocumentReadTypeFunc func, void* func_target);
GXmlTDocument* gxml_tdocument_construct_from_file_with_readtype_func (GType object_type, GFile* file, GXmlTDocumentReadTypeFunc func, void* func_target);
GXmlTDocument* gxml_tdocument_new_from_stream_with_readtype_func (GInputStream* stream, GXmlTDocumentReadTypeFunc func, void* func_target);
GXmlTDocument* gxml_tdocument_construct_from_stream_with_readtype_func (GType object_type, GInputStream* stream, GXmlTDocumentReadTypeFunc func, void* func_target);
GXmlTDocument* gxml_tdocument_new_from_string_with_readtype_func (const gchar* str, GXmlTDocumentReadTypeFunc func, void* func_target);
GXmlTDocument* gxml_tdocument_construct_from_string_with_readtype_func (GType object_type, const gchar* str, GXmlTDocumentReadTypeFunc func, void* 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_dup8 (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, void* 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);


/**
   * 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;
	const gchar* _tmp0_ = NULL;
	GFile* _tmp1_ = NULL;
	GFile* _tmp2_ = NULL;
	GFile* _tmp3_ = NULL;
	GFile* _tmp4_ = NULL;
	gboolean _tmp5_ = FALSE;
	GError * _inner_error_ = NULL;
	g_return_val_if_fail (path != NULL, NULL);
	self = (GXmlTDocument*) gxml_tnode_construct (object_type);
	_tmp0_ = path;
	_tmp1_ = g_file_new_for_path (_tmp0_);
	_tmp2_ = _tmp1_;
	gxml_document_set_file ((GXmlDocument*) self, _tmp2_);
	_g_object_unref0 (_tmp2_);
	_tmp3_ = gxml_document_get_file ((GXmlDocument*) self);
	_tmp4_ = _tmp3_;
	_tmp5_ = g_file_query_exists (_tmp4_, NULL);
	if (!_tmp5_) {
		return self;
	}
	{
		GFile* _tmp6_ = NULL;
		GFile* _tmp7_ = NULL;
		_tmp6_ = gxml_document_get_file ((GXmlDocument*) self);
		_tmp7_ = _tmp6_;
		gxml_tdocument_read_doc ((GXmlDocument*) self, _tmp7_, NULL, NULL, &_inner_error_);
		if (G_UNLIKELY (_inner_error_ != NULL)) {
			goto __catch3_g_error;
		}
	}
	goto __finally3;
	__catch3_g_error:
	{
		g_clear_error (&_inner_error_);
		_inner_error_ = NULL;
	}
	__finally3:
	if (G_UNLIKELY (_inner_error_ != NULL)) {
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
		g_clear_error (&_inner_error_);
		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;
	const gchar* _tmp0_ = NULL;
	GFile* _tmp1_ = NULL;
	GFile* _tmp2_ = NULL;
	g_return_val_if_fail (uri != NULL, NULL);
	_tmp0_ = uri;
	_tmp1_ = g_file_new_for_uri (_tmp0_);
	_tmp2_ = _tmp1_;
	self = (GXmlTDocument*) gxml_tdocument_construct_from_file (object_type, _tmp2_);
	_g_object_unref0 (_tmp2_);
	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;
	GFile* _tmp0_ = NULL;
	gboolean _tmp1_ = FALSE;
	GFile* _tmp3_ = NULL;
	GError * _inner_error_ = NULL;
	g_return_val_if_fail (file != NULL, NULL);
	self = (GXmlTDocument*) gxml_tnode_construct (object_type);
	_tmp0_ = file;
	_tmp1_ = g_file_query_exists (_tmp0_, NULL);
	if (!_tmp1_) {
		return self;
	}
	{
		GFile* _tmp2_ = NULL;
		_tmp2_ = file;
		gxml_tdocument_read_doc ((GXmlDocument*) self, _tmp2_, NULL, NULL, &_inner_error_);
		if (G_UNLIKELY (_inner_error_ != NULL)) {
			goto __catch4_g_error;
		}
	}
	goto __finally4;
	__catch4_g_error:
	{
		g_clear_error (&_inner_error_);
		_inner_error_ = NULL;
	}
	__finally4:
	if (G_UNLIKELY (_inner_error_ != NULL)) {
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
		g_clear_error (&_inner_error_);
		return NULL;
	}
	_tmp3_ = file;
	gxml_document_set_file ((GXmlDocument*) self, _tmp3_);
	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_error_ = NULL;
	g_return_val_if_fail (stream != NULL, NULL);
	self = (GXmlTDocument*) gxml_tnode_construct (object_type);
	{
		GInputStream* _tmp0_ = NULL;
		_tmp0_ = stream;
		gxml_tdocument_read_doc_stream ((GXmlDocument*) self, _tmp0_, NULL, NULL, &_inner_error_);
		if (G_UNLIKELY (_inner_error_ != NULL)) {
			goto __catch5_g_error;
		}
	}
	goto __finally5;
	__catch5_g_error:
	{
		g_clear_error (&_inner_error_);
		_inner_error_ = NULL;
	}
	__finally5:
	if (G_UNLIKELY (_inner_error_ != NULL)) {
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
		g_clear_error (&_inner_error_);
		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_ = NULL;
	const gchar* _tmp1_ = NULL;
	gchar* _tmp2_ = NULL;
	g_return_val_if_fail (str != NULL, NULL);
	_tmp0_ = (GMemoryInputStream*) g_memory_input_stream_new ();
	minput = _tmp0_;
	_tmp1_ = str;
	_tmp2_ = g_strdup (_tmp1_);
	g_memory_input_stream_add_data (minput, (guint8*) _tmp2_, (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, void* func_target) {
	GXmlTDocument * self = NULL;
	const gchar* _tmp0_ = NULL;
	GFile* _tmp1_ = NULL;
	GFile* _tmp2_ = NULL;
	GFile* _tmp3_ = NULL;
	GFile* _tmp4_ = NULL;
	gboolean _tmp5_ = FALSE;
	GError * _inner_error_ = NULL;
	g_return_val_if_fail (path != NULL, NULL);
	self = (GXmlTDocument*) gxml_tnode_construct (object_type);
	_tmp0_ = path;
	_tmp1_ = g_file_new_for_path (_tmp0_);
	_tmp2_ = _tmp1_;
	gxml_document_set_file ((GXmlDocument*) self, _tmp2_);
	_g_object_unref0 (_tmp2_);
	_tmp3_ = gxml_document_get_file ((GXmlDocument*) self);
	_tmp4_ = _tmp3_;
	_tmp5_ = g_file_query_exists (_tmp4_, NULL);
	if (!_tmp5_) {
		return self;
	}
	{
		GFile* _tmp6_ = NULL;
		GFile* _tmp7_ = NULL;
		GXmlTDocumentReadTypeFunc _tmp8_ = NULL;
		void* _tmp8__target = NULL;
		_tmp6_ = gxml_document_get_file ((GXmlDocument*) self);
		_tmp7_ = _tmp6_;
		_tmp8_ = func;
		_tmp8__target = func_target;
		gxml_tdocument_read_doc ((GXmlDocument*) self, _tmp7_, _tmp8_, _tmp8__target, &_inner_error_);
		if (G_UNLIKELY (_inner_error_ != NULL)) {
			goto __catch6_g_error;
		}
	}
	goto __finally6;
	__catch6_g_error:
	{
		g_clear_error (&_inner_error_);
		_inner_error_ = NULL;
	}
	__finally6:
	if (G_UNLIKELY (_inner_error_ != NULL)) {
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
		g_clear_error (&_inner_error_);
		return NULL;
	}
	return self;
}


GXmlTDocument* gxml_tdocument_new_from_path_with_readtype_func (const gchar* path, GXmlTDocumentReadTypeFunc func, void* 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, void* func_target) {
	GXmlTDocument * self = NULL;
	const gchar* _tmp0_ = NULL;
	GFile* _tmp1_ = NULL;
	GFile* _tmp2_ = NULL;
	GXmlTDocumentReadTypeFunc _tmp3_ = NULL;
	void* _tmp3__target = NULL;
	g_return_val_if_fail (uri != NULL, NULL);
	_tmp0_ = uri;
	_tmp1_ = g_file_new_for_uri (_tmp0_);
	_tmp2_ = _tmp1_;
	_tmp3_ = func;
	_tmp3__target = func_target;
	self = (GXmlTDocument*) gxml_tdocument_construct_from_file_with_readtype_func (object_type, _tmp2_, _tmp3_, _tmp3__target);
	_g_object_unref0 (_tmp2_);
	return self;
}


GXmlTDocument* gxml_tdocument_new_from_uri_with_readtype_func (const gchar* uri, GXmlTDocumentReadTypeFunc func, void* 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, void* func_target) {
	GXmlTDocument * self = NULL;
	GFile* _tmp0_ = NULL;
	gboolean _tmp1_ = FALSE;
	GFile* _tmp4_ = NULL;
	GError * _inner_error_ = NULL;
	g_return_val_if_fail (file != NULL, NULL);
	self = (GXmlTDocument*) gxml_tnode_construct (object_type);
	_tmp0_ = file;
	_tmp1_ = g_file_query_exists (_tmp0_, NULL);
	if (!_tmp1_) {
		return self;
	}
	{
		GFile* _tmp2_ = NULL;
		GXmlTDocumentReadTypeFunc _tmp3_ = NULL;
		void* _tmp3__target = NULL;
		_tmp2_ = file;
		_tmp3_ = func;
		_tmp3__target = func_target;
		gxml_tdocument_read_doc ((GXmlDocument*) self, _tmp2_, _tmp3_, _tmp3__target, &_inner_error_);
		if (G_UNLIKELY (_inner_error_ != NULL)) {
			goto __catch7_g_error;
		}
	}
	goto __finally7;
	__catch7_g_error:
	{
		g_clear_error (&_inner_error_);
		_inner_error_ = NULL;
	}
	__finally7:
	if (G_UNLIKELY (_inner_error_ != NULL)) {
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
		g_clear_error (&_inner_error_);
		return NULL;
	}
	_tmp4_ = file;
	gxml_document_set_file ((GXmlDocument*) self, _tmp4_);
	return self;
}


GXmlTDocument* gxml_tdocument_new_from_file_with_readtype_func (GFile* file, GXmlTDocumentReadTypeFunc func, void* 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, void* func_target) {
	GXmlTDocument * self = NULL;
	GError * _inner_error_ = NULL;
	g_return_val_if_fail (stream != NULL, NULL);
	self = (GXmlTDocument*) gxml_tnode_construct (object_type);
	{
		GInputStream* _tmp0_ = NULL;
		GXmlTDocumentReadTypeFunc _tmp1_ = NULL;
		void* _tmp1__target = NULL;
		_tmp0_ = stream;
		_tmp1_ = func;
		_tmp1__target = func_target;
		gxml_tdocument_read_doc_stream ((GXmlDocument*) self, _tmp0_, _tmp1_, _tmp1__target, &_inner_error_);
		if (G_UNLIKELY (_inner_error_ != NULL)) {
			goto __catch8_g_error;
		}
	}
	goto __finally8;
	__catch8_g_error:
	{
		g_clear_error (&_inner_error_);
		_inner_error_ = NULL;
	}
	__finally8:
	if (G_UNLIKELY (_inner_error_ != NULL)) {
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
		g_clear_error (&_inner_error_);
		return NULL;
	}
	return self;
}


GXmlTDocument* gxml_tdocument_new_from_stream_with_readtype_func (GInputStream* stream, GXmlTDocumentReadTypeFunc func, void* 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, void* func_target) {
	GXmlTDocument * self = NULL;
	GMemoryInputStream* minput = NULL;
	GMemoryInputStream* _tmp0_ = NULL;
	const gchar* _tmp1_ = NULL;
	gchar* _tmp2_ = NULL;
	GXmlTDocumentReadTypeFunc _tmp3_ = NULL;
	void* _tmp3__target = NULL;
	g_return_val_if_fail (str != NULL, NULL);
	_tmp0_ = (GMemoryInputStream*) g_memory_input_stream_new ();
	minput = _tmp0_;
	_tmp1_ = str;
	_tmp2_ = g_strdup (_tmp1_);
	g_memory_input_stream_add_data (minput, (guint8*) _tmp2_, (gssize) -1, NULL);
	_tmp3_ = func;
	_tmp3__target = func_target;
	self = (GXmlTDocument*) gxml_tdocument_construct_from_stream_with_readtype_func (object_type, (GInputStream*) minput, _tmp3_, _tmp3__target);
	_g_object_unref0 (minput);
	return self;
}


GXmlTDocument* gxml_tdocument_new_from_string_with_readtype_func (const gchar* str, GXmlTDocumentReadTypeFunc func, void* 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_ = NULL;
	GeeArrayList* _tmp2_ = NULL;
	const gchar* _tmp3_ = NULL;
	const gchar* _tmp4_ = NULL;
	GXmlTNamespace* _tmp5_ = NULL;
	GXmlTNamespace* _tmp6_ = NULL;
	self = (GXmlTDocument*) base;
	g_return_val_if_fail (uri != NULL, FALSE);
	_tmp0_ = self->_namespaces;
	if (_tmp0_ == NULL) {
		GeeArrayList* _tmp1_ = NULL;
		_tmp1_ = gee_array_list_new (GXML_TYPE_NODE, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, NULL, NULL, NULL);
		_g_object_unref0 (self->_namespaces);
		self->_namespaces = _tmp1_;
	}
	_tmp2_ = self->_namespaces;
	_tmp3_ = uri;
	_tmp4_ = prefix;
	_tmp5_ = gxml_tnamespace_new ((GXmlDocument*) self, _tmp3_, _tmp4_);
	_tmp6_ = _tmp5_;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp2_, (GXmlNode*) _tmp6_);
	_g_object_unref0 (_tmp6_);
	result = TRUE;
	return result;
}


static GXmlNode* gxml_tdocument_real_create_comment (GXmlDocument* base, const gchar* text) {
	GXmlTDocument * self;
	GXmlNode* result = NULL;
	GXmlTComment* c = NULL;
	const gchar* _tmp0_ = NULL;
	GXmlTComment* _tmp1_ = NULL;
	self = (GXmlTDocument*) base;
	g_return_val_if_fail (text != NULL, NULL);
	_tmp0_ = text;
	_tmp1_ = gxml_tcomment_new ((GXmlDocument*) self, _tmp0_);
	c = _tmp1_;
	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;
	const gchar* _tmp0_ = NULL;
	const gchar* _tmp1_ = NULL;
	GXmlTProcessingInstruction* _tmp2_ = NULL;
	self = (GXmlTDocument*) base;
	g_return_val_if_fail (target != NULL, NULL);
	g_return_val_if_fail (data != NULL, NULL);
	_tmp0_ = target;
	_tmp1_ = data;
	_tmp2_ = gxml_tprocessing_instruction_new ((GXmlDocument*) self, _tmp0_, _tmp1_);
	pi = _tmp2_;
	result = (GXmlNode*) pi;
	return result;
}


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


static GXmlNode* gxml_tdocument_real_create_text (GXmlDocument* base, const gchar* text) {
	GXmlTDocument * self;
	GXmlNode* result = NULL;
	GXmlTText* t = NULL;
	const gchar* _tmp0_ = NULL;
	GXmlTText* _tmp1_ = NULL;
	self = (GXmlTDocument*) base;
	g_return_val_if_fail (text != NULL, NULL);
	_tmp0_ = text;
	_tmp1_ = gxml_ttext_new ((GXmlDocument*) self, _tmp0_);
	t = _tmp1_;
	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;
	const gchar* _tmp0_ = NULL;
	GXmlTCDATA* _tmp1_ = NULL;
	self = (GXmlTDocument*) base;
	g_return_val_if_fail (text != NULL, NULL);
	_tmp0_ = text;
	_tmp1_ = gxml_tcdata_new ((GXmlDocument*) self, _tmp0_);
	t = _tmp1_;
	result = (GXmlNode*) t;
	return result;
}


static gboolean gxml_tdocument_real_save (GXmlDocument* base, GCancellable* cancellable, GError** error) {
	GXmlTDocument * self;
	gboolean result = FALSE;
	GFile* _tmp0_ = NULL;
	GFile* _tmp1_ = NULL;
	gboolean _tmp2_ = FALSE;
	GFile* _tmp3_ = NULL;
	GFile* _tmp4_ = NULL;
	GCancellable* _tmp5_ = NULL;
	gboolean _tmp6_ = FALSE;
	GError * _inner_error_ = 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_;
	_tmp5_ = cancellable;
	_tmp6_ = gxml_document_save_as ((GXmlDocument*) self, _tmp4_, _tmp5_, &_inner_error_);
	_tmp2_ = _tmp6_;
	if (G_UNLIKELY (_inner_error_ != NULL)) {
		gboolean _tmp7_ = FALSE;
		g_propagate_error (error, _inner_error_);
		return _tmp7_;
	}
	result = _tmp2_;
	return result;
}


gboolean gxml_tdocument_save_to (GXmlTDocument* self, GFile* f, GCancellable* cancellable, GError** error) {
	gboolean result = FALSE;
	gboolean _tmp0_ = FALSE;
	GFile* _tmp1_ = NULL;
	GCancellable* _tmp2_ = NULL;
	gboolean _tmp3_ = FALSE;
	GError * _inner_error_ = NULL;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (f != NULL, FALSE);
	_tmp1_ = f;
	_tmp2_ = cancellable;
	_tmp3_ = gxml_document_save_as ((GXmlDocument*) self, _tmp1_, _tmp2_, &_inner_error_);
	_tmp0_ = _tmp3_;
	if (G_UNLIKELY (_inner_error_ != NULL)) {
		gboolean _tmp4_ = FALSE;
		g_propagate_error (error, _inner_error_);
		return _tmp4_;
	}
	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;
	GFile* _tmp1_ = NULL;
	GCancellable* _tmp2_ = NULL;
	gboolean _tmp3_ = FALSE;
	GError * _inner_error_ = NULL;
	self = (GXmlTDocument*) base;
	g_return_val_if_fail (f != NULL, FALSE);
	_tmp1_ = f;
	_tmp2_ = cancellable;
	_tmp3_ = gxml_tdocument_tw_save_as ((GXmlDocument*) self, _tmp1_, _tmp2_, &_inner_error_);
	_tmp0_ = _tmp3_;
	if (G_UNLIKELY (_inner_error_ != NULL)) {
		gboolean _tmp4_ = FALSE;
		g_propagate_error (error, _inner_error_);
		return _tmp4_;
	}
	result = _tmp0_;
	return result;
}


static guint8* g_string_get_data (GString* self, int* result_length1) {
	guint8* result;
	guint8* res = NULL;
	const gchar* _tmp0_ = NULL;
	gint res_length1 = 0;
	gint _res_size_ = 0;
	gssize _tmp1_ = 0L;
	gint _tmp2_ = 0;
	guint8* _tmp3_ = NULL;
	gint _tmp3__length1 = 0;
	guint8* _tmp4_ = NULL;
	gint _tmp4__length1 = 0;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->str;
	res = (guint8*) _tmp0_;
	res_length1 = -1;
	_res_size_ = res_length1;
	_tmp1_ = self->len;
	res_length1 = (gint) _tmp1_;
	_tmp2_ = res_length1;
	_tmp3_ = res;
	_tmp3__length1 = res_length1;
	_tmp4_ = _tmp3_;
	_tmp4__length1 = _tmp3__length1;
	if (result_length1) {
		*result_length1 = _tmp4__length1;
	}
	result = _tmp4_;
	return result;
}


static guint8* _vala_array_dup8 (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_ = NULL;
	xmlTextWriter* tw = NULL;
	xmlBuffer* _tmp1_ = NULL;
	xmlTextWriter* _tmp2_ = NULL;
	GXmlDocument* _tmp3_ = NULL;
	xmlTextWriter* _tmp4_ = NULL;
	GString* s = NULL;
	GString* _tmp6_ = NULL;
	GString* _tmp7_ = NULL;
	xmlBuffer* _tmp8_ = NULL;
	const gchar* _tmp9_ = NULL;
	GMemoryInputStream* b = NULL;
	GString* _tmp10_ = NULL;
	guint8* _tmp11_ = NULL;
	gint _tmp11__length1 = 0;
	guint8* _tmp12_ = NULL;
	gint _tmp12__length1 = 0;
	guint8* _tmp13_ = NULL;
	gint _tmp13__length1 = 0;
	GMemoryInputStream* _tmp14_ = NULL;
	GFileOutputStream* ostream = NULL;
	GFile* _tmp15_ = NULL;
	GXmlDocument* _tmp16_ = NULL;
	gboolean _tmp17_ = FALSE;
	gboolean _tmp18_ = FALSE;
	GCancellable* _tmp19_ = NULL;
	GFileOutputStream* _tmp20_ = NULL;
	GFileOutputStream* _tmp22_ = NULL;
	GMemoryInputStream* _tmp23_ = NULL;
	GFileOutputStream* _tmp25_ = NULL;
	GError * _inner_error_ = 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_ = doc;
	_tmp4_ = tw;
	gxml_tdocument_write_document (_tmp3_, _tmp4_, &_inner_error_);
	if (G_UNLIKELY (_inner_error_ != NULL)) {
		gboolean _tmp5_ = FALSE;
		g_propagate_error (error, _inner_error_);
		_xmlFreeTextWriter0 (tw);
		_xmlBufferFree0 (buf);
		return _tmp5_;
	}
	_tmp6_ = g_string_new ("");
	s = _tmp6_;
	_tmp7_ = s;
	_tmp8_ = buf;
	_tmp9_ = xmlBufferContent (_tmp8_);
	g_string_append (_tmp7_, _tmp9_);
	_tmp10_ = s;
	_tmp11_ = g_string_get_data (_tmp10_, &_tmp11__length1);
	_tmp12_ = _tmp11_;
	_tmp12__length1 = _tmp11__length1;
	_tmp13_ = (_tmp12_ != NULL) ? _vala_array_dup8 (_tmp12_, _tmp12__length1) : ((gpointer) _tmp12_);
	_tmp13__length1 = _tmp12__length1;
	_tmp14_ = (GMemoryInputStream*) g_memory_input_stream_new_from_data (_tmp13_, _tmp13__length1, NULL);
	b = _tmp14_;
	_tmp15_ = f;
	_tmp16_ = doc;
	_tmp17_ = gxml_document_get_backup (_tmp16_);
	_tmp18_ = _tmp17_;
	_tmp19_ = cancellable;
	_tmp20_ = g_file_replace (_tmp15_, NULL, _tmp18_, G_FILE_CREATE_NONE, _tmp19_, &_inner_error_);
	ostream = _tmp20_;
	if (G_UNLIKELY (_inner_error_ != NULL)) {
		gboolean _tmp21_ = FALSE;
		g_propagate_error (error, _inner_error_);
		_g_object_unref0 (b);
		_g_string_free0 (s);
		_xmlFreeTextWriter0 (tw);
		_xmlBufferFree0 (buf);
		return _tmp21_;
	}
	_tmp22_ = ostream;
	_tmp23_ = b;
	g_output_stream_splice ((GOutputStream*) _tmp22_, (GInputStream*) _tmp23_, G_OUTPUT_STREAM_SPLICE_NONE, NULL, &_inner_error_);
	if (G_UNLIKELY (_inner_error_ != NULL)) {
		gboolean _tmp24_ = FALSE;
		g_propagate_error (error, _inner_error_);
		_g_object_unref0 (ostream);
		_g_object_unref0 (b);
		_g_string_free0 (s);
		_xmlFreeTextWriter0 (tw);
		_xmlBufferFree0 (buf);
		return _tmp24_;
	}
	_tmp25_ = ostream;
	g_output_stream_close ((GOutputStream*) _tmp25_, NULL, &_inner_error_);
	if (G_UNLIKELY (_inner_error_ != NULL)) {
		gboolean _tmp26_ = FALSE;
		g_propagate_error (error, _inner_error_);
		_g_object_unref0 (ostream);
		_g_object_unref0 (b);
		_g_string_free0 (s);
		_xmlFreeTextWriter0 (tw);
		_xmlBufferFree0 (buf);
		return _tmp26_;
	}
	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) {
	xmlTextWriter* _tmp0_ = NULL;
	xmlTextWriter* _tmp1_ = NULL;
	GXmlDocument* _tmp2_ = NULL;
	gboolean _tmp3_ = FALSE;
	gboolean _tmp4_ = FALSE;
	GXmlDocument* _tmp5_ = NULL;
	GXmlNode* _tmp6_ = NULL;
	GXmlNode* _tmp7_ = NULL;
	GXmlNode* _tmp8_ = NULL;
	gboolean _tmp9_ = FALSE;
	GeeArrayList* dns = NULL;
	GeeArrayList* _tmp11_ = NULL;
	GXmlDocument* _tmp12_ = NULL;
	xmlTextWriter* _tmp13_ = NULL;
	GXmlDocument* _tmp14_ = NULL;
	xmlTextWriter* _tmp15_ = NULL;
	xmlTextWriter* _tmp16_ = NULL;
	xmlTextWriter* _tmp17_ = NULL;
	GError * _inner_error_ = NULL;
	g_return_if_fail (doc != NULL);
	g_return_if_fail (tw != NULL);
	_tmp0_ = tw;
	xmlTextWriterStartDocument (_tmp0_, NULL, NULL, NULL);
	_tmp1_ = tw;
	_tmp2_ = doc;
	_tmp3_ = gxml_document_get_indent (_tmp2_);
	_tmp4_ = _tmp3_;
	xmlTextWriterSetIndent (_tmp1_, _tmp4_);
	_tmp5_ = doc;
	_tmp6_ = gxml_document_get_root (_tmp5_);
	_tmp7_ = _tmp6_;
	_tmp8_ = _tmp7_;
	_tmp9_ = _tmp8_ == NULL;
	_g_object_unref0 (_tmp8_);
	if (_tmp9_) {
		xmlTextWriter* _tmp10_ = NULL;
		_tmp10_ = tw;
		xmlTextWriterEndDocument (_tmp10_);
	}
	_tmp11_ = gee_array_list_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, NULL, NULL, NULL);
	dns = _tmp11_;
	_tmp12_ = doc;
	_tmp13_ = tw;
	_tmp14_ = doc;
	gxml_tdocument_start_node (_tmp12_, _tmp13_, (GXmlNode*) _tmp14_, FALSE, &dns, &_inner_error_);
	if (G_UNLIKELY (_inner_error_ != NULL)) {
		g_propagate_error (error, _inner_error_);
		_g_object_unref0 (dns);
		return;
	}
	_tmp15_ = tw;
	xmlTextWriterEndElement (_tmp15_);
	_tmp16_ = tw;
	xmlTextWriterEndDocument (_tmp16_);
	_tmp17_ = tw;
	xmlTextWriterFlush (_tmp17_);
	_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;
	GXmlNode* _tmp0_ = NULL;
	GError * _inner_error_ = 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;
	_tmp0_ = node;
	if (G_TYPE_CHECK_INSTANCE_TYPE (_tmp0_, GXML_TYPE_ELEMENT)) {
		gboolean _tmp1_ = FALSE;
		_tmp1_ = root;
		if (_tmp1_) {
			GXmlNode* _tmp2_ = NULL;
			GXmlDocument* _tmp3_ = NULL;
			GXmlDocument* _tmp4_ = NULL;
			GeeList* _tmp5_ = NULL;
			GeeList* _tmp6_ = NULL;
			GeeList* _tmp7_ = NULL;
			gint _tmp8_ = 0;
			gint _tmp9_ = 0;
			gboolean _tmp10_ = FALSE;
			_tmp2_ = node;
			_tmp3_ = gxml_node_get_document (_tmp2_);
			_tmp4_ = _tmp3_;
			_tmp5_ = gxml_node_get_namespaces ((GXmlNode*) _tmp4_);
			_tmp6_ = _tmp5_;
			_tmp7_ = _tmp6_;
			_tmp8_ = gee_collection_get_size ((GeeCollection*) _tmp7_);
			_tmp9_ = _tmp8_;
			_tmp10_ = _tmp9_ > 0;
			_g_object_unref0 (_tmp7_);
			if (_tmp10_) {
				GXmlNamespace* dns = NULL;
				GXmlNode* _tmp11_ = NULL;
				GXmlDocument* _tmp12_ = NULL;
				GXmlDocument* _tmp13_ = NULL;
				GeeList* _tmp14_ = NULL;
				GeeList* _tmp15_ = NULL;
				GeeList* _tmp16_ = NULL;
				gpointer _tmp17_ = NULL;
				GXmlNamespace* _tmp18_ = NULL;
				GXmlNamespace* _tmp19_ = NULL;
				GXmlDocument* _tmp20_ = NULL;
				gboolean _tmp21_ = FALSE;
				gboolean _tmp22_ = FALSE;
				gboolean _tmp72_ = FALSE;
				GXmlNode* _tmp73_ = NULL;
				GXmlDocument* _tmp74_ = NULL;
				GXmlDocument* _tmp75_ = NULL;
				GeeList* _tmp76_ = NULL;
				GeeList* _tmp77_ = NULL;
				GeeList* _tmp78_ = NULL;
				gint _tmp79_ = 0;
				gint _tmp80_ = 0;
				gboolean _tmp81_ = FALSE;
				_tmp11_ = node;
				_tmp12_ = gxml_node_get_document (_tmp11_);
				_tmp13_ = _tmp12_;
				_tmp14_ = gxml_node_get_namespaces ((GXmlNode*) _tmp13_);
				_tmp15_ = _tmp14_;
				_tmp16_ = _tmp15_;
				_tmp17_ = gee_list_get (_tmp16_, 0);
				_tmp18_ = (GXmlNamespace*) _tmp17_;
				_g_object_unref0 (_tmp16_);
				dns = _tmp18_;
				_tmp19_ = dns;
				_vala_assert (_tmp19_ != NULL, "dns != null");
				_tmp20_ = doc;
				_tmp21_ = gxml_document_get_prefix_default_ns (_tmp20_);
				_tmp22_ = _tmp21_;
				if (_tmp22_) {
					xmlTextWriter* _tmp23_ = NULL;
					GXmlNamespace* _tmp24_ = NULL;
					gchar* _tmp25_ = NULL;
					gchar* _tmp26_ = NULL;
					gchar* _tmp27_ = NULL;
					GXmlNode* _tmp28_ = NULL;
					gchar* _tmp29_ = NULL;
					gchar* _tmp30_ = NULL;
					gchar* _tmp31_ = NULL;
					GXmlNamespace* _tmp32_ = NULL;
					gchar* _tmp33_ = NULL;
					gchar* _tmp34_ = NULL;
					gchar* _tmp35_ = NULL;
					GeeArrayList* _tmp36_ = NULL;
					GXmlNamespace* _tmp37_ = NULL;
					gchar* _tmp38_ = NULL;
					gchar* _tmp39_ = NULL;
					gchar* _tmp40_ = NULL;
					_tmp23_ = tw;
					_tmp24_ = dns;
					_tmp25_ = gxml_namespace_get_prefix (_tmp24_);
					_tmp26_ = _tmp25_;
					_tmp27_ = _tmp26_;
					_tmp28_ = node;
					_tmp29_ = gxml_node_get_name (_tmp28_);
					_tmp30_ = _tmp29_;
					_tmp31_ = _tmp30_;
					_tmp32_ = dns;
					_tmp33_ = gxml_namespace_get_uri (_tmp32_);
					_tmp34_ = _tmp33_;
					_tmp35_ = _tmp34_;
					xmlTextWriterStartElementNS (_tmp23_, (xmlChar*) _tmp27_, (xmlChar*) _tmp31_, (xmlChar*) _tmp35_);
					_g_free0 (_tmp35_);
					_g_free0 (_tmp31_);
					_g_free0 (_tmp27_);
					_tmp36_ = *declared_ns;
					_tmp37_ = dns;
					_tmp38_ = gxml_namespace_get_uri (_tmp37_);
					_tmp39_ = _tmp38_;
					_tmp40_ = _tmp39_;
					gee_abstract_collection_add ((GeeAbstractCollection*) _tmp36_, _tmp40_);
					_g_free0 (_tmp40_);
				} else {
					xmlTextWriter* _tmp41_ = NULL;
					GXmlNode* _tmp42_ = NULL;
					gchar* _tmp43_ = NULL;
					gchar* _tmp44_ = NULL;
					gchar* _tmp45_ = NULL;
					GXmlNamespace* _tmp46_ = NULL;
					gchar* _tmp47_ = NULL;
					gchar* _tmp48_ = NULL;
					gchar* _tmp49_ = NULL;
					gboolean _tmp50_ = FALSE;
					GeeArrayList* _tmp67_ = NULL;
					GXmlNamespace* _tmp68_ = NULL;
					gchar* _tmp69_ = NULL;
					gchar* _tmp70_ = NULL;
					gchar* _tmp71_ = NULL;
					_tmp41_ = tw;
					_tmp42_ = node;
					_tmp43_ = gxml_node_get_name (_tmp42_);
					_tmp44_ = _tmp43_;
					_tmp45_ = _tmp44_;
					xmlTextWriterStartElement (_tmp41_, (xmlChar*) _tmp45_);
					_g_free0 (_tmp45_);
					_tmp46_ = dns;
					_tmp47_ = gxml_namespace_get_prefix (_tmp46_);
					_tmp48_ = _tmp47_;
					_tmp49_ = _tmp48_;
					_tmp50_ = _tmp49_ == NULL;
					_g_free0 (_tmp49_);
					if (_tmp50_) {
						xmlTextWriter* _tmp51_ = NULL;
						GXmlNamespace* _tmp52_ = NULL;
						gchar* _tmp53_ = NULL;
						gchar* _tmp54_ = NULL;
						gchar* _tmp55_ = NULL;
						_tmp51_ = tw;
						_tmp52_ = dns;
						_tmp53_ = gxml_namespace_get_uri (_tmp52_);
						_tmp54_ = _tmp53_;
						_tmp55_ = _tmp54_;
						xmlTextWriterWriteAttribute (_tmp51_, (xmlChar*) "xmlns", (xmlChar*) _tmp55_);
						_g_free0 (_tmp55_);
					} else {
						xmlTextWriter* _tmp56_ = NULL;
						GXmlNamespace* _tmp57_ = NULL;
						gchar* _tmp58_ = NULL;
						gchar* _tmp59_ = NULL;
						gchar* _tmp60_ = NULL;
						gchar* _tmp61_ = NULL;
						gchar* _tmp62_ = NULL;
						GXmlNamespace* _tmp63_ = NULL;
						gchar* _tmp64_ = NULL;
						gchar* _tmp65_ = NULL;
						gchar* _tmp66_ = NULL;
						_tmp56_ = tw;
						_tmp57_ = dns;
						_tmp58_ = gxml_namespace_get_prefix (_tmp57_);
						_tmp59_ = _tmp58_;
						_tmp60_ = _tmp59_;
						_tmp61_ = g_strconcat ("xmlns:", _tmp60_, NULL);
						_tmp62_ = _tmp61_;
						_tmp63_ = dns;
						_tmp64_ = gxml_namespace_get_uri (_tmp63_);
						_tmp65_ = _tmp64_;
						_tmp66_ = _tmp65_;
						xmlTextWriterWriteAttribute (_tmp56_, (xmlChar*) _tmp62_, (xmlChar*) _tmp66_);
						_g_free0 (_tmp66_);
						_g_free0 (_tmp62_);
						_g_free0 (_tmp60_);
					}
					_tmp67_ = *declared_ns;
					_tmp68_ = dns;
					_tmp69_ = gxml_namespace_get_uri (_tmp68_);
					_tmp70_ = _tmp69_;
					_tmp71_ = _tmp70_;
					gee_abstract_collection_add ((GeeAbstractCollection*) _tmp67_, _tmp71_);
					_g_free0 (_tmp71_);
				}
				_tmp73_ = node;
				_tmp74_ = gxml_node_get_document (_tmp73_);
				_tmp75_ = _tmp74_;
				_tmp76_ = gxml_node_get_namespaces ((GXmlNode*) _tmp75_);
				_tmp77_ = _tmp76_;
				_tmp78_ = _tmp77_;
				_tmp79_ = gee_collection_get_size ((GeeCollection*) _tmp78_);
				_tmp80_ = _tmp79_;
				_tmp81_ = _tmp80_ > 1;
				_g_object_unref0 (_tmp78_);
				if (_tmp81_) {
					GXmlNode* _tmp82_ = NULL;
					GXmlDocument* _tmp83_ = NULL;
					GXmlDocument* _tmp84_ = NULL;
					gboolean _tmp85_ = FALSE;
					gboolean _tmp86_ = FALSE;
					_tmp82_ = node;
					_tmp83_ = gxml_node_get_document (_tmp82_);
					_tmp84_ = _tmp83_;
					_tmp85_ = gxml_document_get_ns_top (_tmp84_);
					_tmp86_ = _tmp85_;
					_tmp72_ = _tmp86_;
				} else {
					_tmp72_ = FALSE;
				}
				if (_tmp72_) {
					{
						gint i = 0;
						i = 1;
						{
							gboolean _tmp87_ = FALSE;
							_tmp87_ = TRUE;
							while (TRUE) {
								gint _tmp89_ = 0;
								GXmlNode* _tmp90_ = NULL;
								GXmlDocument* _tmp91_ = NULL;
								GXmlDocument* _tmp92_ = NULL;
								GeeList* _tmp93_ = NULL;
								GeeList* _tmp94_ = NULL;
								GeeList* _tmp95_ = NULL;
								gint _tmp96_ = 0;
								gint _tmp97_ = 0;
								gboolean _tmp98_ = FALSE;
								GXmlNamespace* ns = NULL;
								GXmlNode* _tmp99_ = NULL;
								GXmlDocument* _tmp100_ = NULL;
								GXmlDocument* _tmp101_ = NULL;
								GeeList* _tmp102_ = NULL;
								GeeList* _tmp103_ = NULL;
								GeeList* _tmp104_ = NULL;
								gint _tmp105_ = 0;
								gpointer _tmp106_ = NULL;
								GXmlNamespace* _tmp107_ = NULL;
								GXmlNamespace* _tmp108_ = NULL;
								gchar* _tmp109_ = NULL;
								gchar* _tmp110_ = NULL;
								gchar* _tmp111_ = NULL;
								gboolean _tmp112_ = FALSE;
								xmlTextWriter* _tmp113_ = NULL;
								GXmlNamespace* _tmp114_ = NULL;
								gchar* _tmp115_ = NULL;
								gchar* _tmp116_ = NULL;
								gchar* _tmp117_ = NULL;
								gchar* _tmp118_ = NULL;
								gchar* _tmp119_ = NULL;
								GXmlNamespace* _tmp120_ = NULL;
								gchar* _tmp121_ = NULL;
								gchar* _tmp122_ = NULL;
								gchar* _tmp123_ = NULL;
								GeeArrayList* _tmp124_ = NULL;
								GXmlNamespace* _tmp125_ = NULL;
								gchar* _tmp126_ = NULL;
								gchar* _tmp127_ = NULL;
								gchar* _tmp128_ = NULL;
								if (!_tmp87_) {
									gint _tmp88_ = 0;
									_tmp88_ = i;
									i = _tmp88_ + 1;
								}
								_tmp87_ = FALSE;
								_tmp89_ = i;
								_tmp90_ = node;
								_tmp91_ = gxml_node_get_document (_tmp90_);
								_tmp92_ = _tmp91_;
								_tmp93_ = gxml_node_get_namespaces ((GXmlNode*) _tmp92_);
								_tmp94_ = _tmp93_;
								_tmp95_ = _tmp94_;
								_tmp96_ = gee_collection_get_size ((GeeCollection*) _tmp95_);
								_tmp97_ = _tmp96_;
								_tmp98_ = !(_tmp89_ < _tmp97_);
								_g_object_unref0 (_tmp95_);
								if (_tmp98_) {
									break;
								}
								_tmp99_ = node;
								_tmp100_ = gxml_node_get_document (_tmp99_);
								_tmp101_ = _tmp100_;
								_tmp102_ = gxml_node_get_namespaces ((GXmlNode*) _tmp101_);
								_tmp103_ = _tmp102_;
								_tmp104_ = _tmp103_;
								_tmp105_ = i;
								_tmp106_ = gee_list_get (_tmp104_, _tmp105_);
								_tmp107_ = (GXmlNamespace*) _tmp106_;
								_g_object_unref0 (_tmp104_);
								ns = _tmp107_;
								_tmp108_ = ns;
								_tmp109_ = gxml_namespace_get_prefix (_tmp108_);
								_tmp110_ = _tmp109_;
								_tmp111_ = _tmp110_;
								_tmp112_ = _tmp111_ == NULL;
								_g_free0 (_tmp111_);
								if (_tmp112_) {
									_g_object_unref0 (ns);
									continue;
								}
								_tmp113_ = tw;
								_tmp114_ = ns;
								_tmp115_ = gxml_namespace_get_prefix (_tmp114_);
								_tmp116_ = _tmp115_;
								_tmp117_ = _tmp116_;
								_tmp118_ = g_strconcat ("xmlns:", _tmp117_, NULL);
								_tmp119_ = _tmp118_;
								_tmp120_ = ns;
								_tmp121_ = gxml_namespace_get_uri (_tmp120_);
								_tmp122_ = _tmp121_;
								_tmp123_ = _tmp122_;
								xmlTextWriterWriteAttribute (_tmp113_, (xmlChar*) _tmp119_, (xmlChar*) _tmp123_);
								_g_free0 (_tmp123_);
								_g_free0 (_tmp119_);
								_g_free0 (_tmp117_);
								_tmp124_ = *declared_ns;
								_tmp125_ = ns;
								_tmp126_ = gxml_namespace_get_uri (_tmp125_);
								_tmp127_ = _tmp126_;
								_tmp128_ = _tmp127_;
								gee_abstract_collection_add ((GeeAbstractCollection*) _tmp124_, _tmp128_);
								_g_free0 (_tmp128_);
								_g_object_unref0 (ns);
							}
						}
					}
				}
				_g_object_unref0 (dns);
			} else {
				xmlTextWriter* _tmp129_ = NULL;
				GXmlNode* _tmp130_ = NULL;
				gchar* _tmp131_ = NULL;
				gchar* _tmp132_ = NULL;
				gchar* _tmp133_ = NULL;
				_tmp129_ = tw;
				_tmp130_ = node;
				_tmp131_ = gxml_node_get_name (_tmp130_);
				_tmp132_ = _tmp131_;
				_tmp133_ = _tmp132_;
				xmlTextWriterStartElement (_tmp129_, (xmlChar*) _tmp133_);
				_g_free0 (_tmp133_);
			}
		} else {
			GXmlNode* _tmp134_ = NULL;
			GeeList* _tmp135_ = NULL;
			GeeList* _tmp136_ = NULL;
			GeeList* _tmp137_ = NULL;
			gint _tmp138_ = 0;
			gint _tmp139_ = 0;
			gboolean _tmp140_ = FALSE;
			_tmp134_ = node;
			_tmp135_ = gxml_node_get_namespaces (_tmp134_);
			_tmp136_ = _tmp135_;
			_tmp137_ = _tmp136_;
			_tmp138_ = gee_collection_get_size ((GeeCollection*) _tmp137_);
			_tmp139_ = _tmp138_;
			_tmp140_ = _tmp139_ > 0;
			_g_object_unref0 (_tmp137_);
			if (_tmp140_) {
				GXmlNode* _tmp141_ = NULL;
				GXmlDocument* _tmp142_ = NULL;
				GXmlDocument* _tmp143_ = NULL;
				gchar* _tmp144_ = NULL;
				gchar* _tmp145_ = NULL;
				GXmlNode* _tmp146_ = NULL;
				gchar* _tmp147_ = NULL;
				gchar* _tmp148_ = NULL;
				gboolean _tmp149_ = FALSE;
				_tmp141_ = node;
				_tmp142_ = gxml_node_get_document (_tmp141_);
				_tmp143_ = _tmp142_;
				_tmp144_ = gxml_node_ns_uri ((GXmlNode*) _tmp143_);
				_tmp145_ = _tmp144_;
				_tmp146_ = node;
				_tmp147_ = gxml_node_ns_uri (_tmp146_);
				_tmp148_ = _tmp147_;
				_tmp149_ = g_strcmp0 (_tmp145_, _tmp148_) == 0;
				_g_free0 (_tmp148_);
				_g_free0 (_tmp145_);
				if (_tmp149_) {
					GXmlNode* _tmp150_ = NULL;
					GXmlDocument* _tmp151_ = NULL;
					GXmlDocument* _tmp152_ = NULL;
					gboolean _tmp153_ = FALSE;
					gboolean _tmp154_ = FALSE;
					_tmp150_ = node;
					_tmp151_ = gxml_node_get_document (_tmp150_);
					_tmp152_ = _tmp151_;
					_tmp153_ = gxml_document_get_prefix_default_ns (_tmp152_);
					_tmp154_ = _tmp153_;
					if (_tmp154_) {
						xmlTextWriter* _tmp155_ = NULL;
						GXmlNode* _tmp156_ = NULL;
						gchar* _tmp157_ = NULL;
						gchar* _tmp158_ = NULL;
						GXmlNode* _tmp159_ = NULL;
						gchar* _tmp160_ = NULL;
						gchar* _tmp161_ = NULL;
						gchar* _tmp162_ = NULL;
						_tmp155_ = tw;
						_tmp156_ = node;
						_tmp157_ = gxml_node_ns_prefix (_tmp156_);
						_tmp158_ = _tmp157_;
						_tmp159_ = node;
						_tmp160_ = gxml_node_get_name (_tmp159_);
						_tmp161_ = _tmp160_;
						_tmp162_ = _tmp161_;
						xmlTextWriterStartElementNS (_tmp155_, (xmlChar*) _tmp158_, (xmlChar*) _tmp162_, (xmlChar*) NULL);
						_g_free0 (_tmp162_);
						_g_free0 (_tmp158_);
					} else {
						xmlTextWriter* _tmp163_ = NULL;
						GXmlNode* _tmp164_ = NULL;
						gchar* _tmp165_ = NULL;
						gchar* _tmp166_ = NULL;
						gchar* _tmp167_ = NULL;
						_tmp163_ = tw;
						_tmp164_ = node;
						_tmp165_ = gxml_node_get_name (_tmp164_);
						_tmp166_ = _tmp165_;
						_tmp167_ = _tmp166_;
						xmlTextWriterStartElement (_tmp163_, (xmlChar*) _tmp167_);
						_g_free0 (_tmp167_);
					}
				} else {
					gboolean _tmp168_ = FALSE;
					GXmlNode* _tmp169_ = NULL;
					gchar* _tmp170_ = NULL;
					gchar* _tmp171_ = NULL;
					gboolean _tmp172_ = FALSE;
					_tmp169_ = node;
					_tmp170_ = gxml_node_ns_prefix (_tmp169_);
					_tmp171_ = _tmp170_;
					_tmp172_ = _tmp171_ == NULL;
					_g_free0 (_tmp171_);
					if (_tmp172_) {
						GeeArrayList* _tmp173_ = NULL;
						GXmlNode* _tmp174_ = NULL;
						gchar* _tmp175_ = NULL;
						gchar* _tmp176_ = NULL;
						gboolean _tmp177_ = FALSE;
						_tmp173_ = *declared_ns;
						_tmp174_ = node;
						_tmp175_ = gxml_node_ns_uri (_tmp174_);
						_tmp176_ = _tmp175_;
						_tmp177_ = gee_abstract_collection_contains ((GeeAbstractCollection*) _tmp173_, _tmp176_);
						_tmp168_ = !_tmp177_;
						_g_free0 (_tmp176_);
					} else {
						_tmp168_ = FALSE;
					}
					if (_tmp168_) {
						xmlTextWriter* _tmp178_ = NULL;
						GXmlNode* _tmp179_ = NULL;
						gchar* _tmp180_ = NULL;
						gchar* _tmp181_ = NULL;
						GXmlNode* _tmp182_ = NULL;
						gchar* _tmp183_ = NULL;
						gchar* _tmp184_ = NULL;
						gchar* _tmp185_ = NULL;
						GXmlNode* _tmp186_ = NULL;
						gchar* _tmp187_ = NULL;
						gchar* _tmp188_ = NULL;
						GeeArrayList* _tmp189_ = NULL;
						GXmlNode* _tmp190_ = NULL;
						gchar* _tmp191_ = NULL;
						gchar* _tmp192_ = NULL;
						_tmp178_ = tw;
						_tmp179_ = node;
						_tmp180_ = gxml_node_ns_prefix (_tmp179_);
						_tmp181_ = _tmp180_;
						_tmp182_ = node;
						_tmp183_ = gxml_node_get_name (_tmp182_);
						_tmp184_ = _tmp183_;
						_tmp185_ = _tmp184_;
						_tmp186_ = node;
						_tmp187_ = gxml_node_ns_uri (_tmp186_);
						_tmp188_ = _tmp187_;
						xmlTextWriterStartElementNS (_tmp178_, (xmlChar*) _tmp181_, (xmlChar*) _tmp185_, (xmlChar*) _tmp188_);
						_g_free0 (_tmp188_);
						_g_free0 (_tmp185_);
						_g_free0 (_tmp181_);
						_tmp189_ = *declared_ns;
						_tmp190_ = node;
						_tmp191_ = gxml_node_ns_uri (_tmp190_);
						_tmp192_ = _tmp191_;
						gee_abstract_collection_add ((GeeAbstractCollection*) _tmp189_, _tmp192_);
						_g_free0 (_tmp192_);
					} else {
						gboolean _tmp193_ = FALSE;
						GXmlNode* _tmp194_ = NULL;
						GXmlDocument* _tmp195_ = NULL;
						GXmlDocument* _tmp196_ = NULL;
						gboolean _tmp197_ = FALSE;
						gboolean _tmp198_ = FALSE;
						_tmp194_ = node;
						_tmp195_ = gxml_node_get_document (_tmp194_);
						_tmp196_ = _tmp195_;
						_tmp197_ = gxml_document_get_ns_top (_tmp196_);
						_tmp198_ = _tmp197_;
						if (_tmp198_) {
							_tmp193_ = TRUE;
						} else {
							GeeArrayList* _tmp199_ = NULL;
							GXmlNode* _tmp200_ = NULL;
							gchar* _tmp201_ = NULL;
							gchar* _tmp202_ = NULL;
							gboolean _tmp203_ = FALSE;
							_tmp199_ = *declared_ns;
							_tmp200_ = node;
							_tmp201_ = gxml_node_ns_uri (_tmp200_);
							_tmp202_ = _tmp201_;
							_tmp203_ = gee_abstract_collection_contains ((GeeAbstractCollection*) _tmp199_, _tmp202_);
							_tmp193_ = _tmp203_;
							_g_free0 (_tmp202_);
						}
						if (_tmp193_) {
							xmlTextWriter* _tmp204_ = NULL;
							GXmlNode* _tmp205_ = NULL;
							gchar* _tmp206_ = NULL;
							gchar* _tmp207_ = NULL;
							GXmlNode* _tmp208_ = NULL;
							gchar* _tmp209_ = NULL;
							gchar* _tmp210_ = NULL;
							gchar* _tmp211_ = NULL;
							_tmp204_ = tw;
							_tmp205_ = node;
							_tmp206_ = gxml_node_ns_prefix (_tmp205_);
							_tmp207_ = _tmp206_;
							_tmp208_ = node;
							_tmp209_ = gxml_node_get_name (_tmp208_);
							_tmp210_ = _tmp209_;
							_tmp211_ = _tmp210_;
							xmlTextWriterStartElementNS (_tmp204_, (xmlChar*) _tmp207_, (xmlChar*) _tmp211_, (xmlChar*) NULL);
							_g_free0 (_tmp211_);
							_g_free0 (_tmp207_);
						} else {
							xmlTextWriter* _tmp212_ = NULL;
							GXmlNode* _tmp213_ = NULL;
							gchar* _tmp214_ = NULL;
							gchar* _tmp215_ = NULL;
							GXmlNode* _tmp216_ = NULL;
							gchar* _tmp217_ = NULL;
							gchar* _tmp218_ = NULL;
							gchar* _tmp219_ = NULL;
							GXmlNode* _tmp220_ = NULL;
							gchar* _tmp221_ = NULL;
							gchar* _tmp222_ = NULL;
							GeeArrayList* _tmp223_ = NULL;
							GXmlNode* _tmp224_ = NULL;
							gchar* _tmp225_ = NULL;
							gchar* _tmp226_ = NULL;
							_tmp212_ = tw;
							_tmp213_ = node;
							_tmp214_ = gxml_node_ns_prefix (_tmp213_);
							_tmp215_ = _tmp214_;
							_tmp216_ = node;
							_tmp217_ = gxml_node_get_name (_tmp216_);
							_tmp218_ = _tmp217_;
							_tmp219_ = _tmp218_;
							_tmp220_ = node;
							_tmp221_ = gxml_node_ns_uri (_tmp220_);
							_tmp222_ = _tmp221_;
							xmlTextWriterStartElementNS (_tmp212_, (xmlChar*) _tmp215_, (xmlChar*) _tmp219_, (xmlChar*) _tmp222_);
							_g_free0 (_tmp222_);
							_g_free0 (_tmp219_);
							_g_free0 (_tmp215_);
							_tmp223_ = *declared_ns;
							_tmp224_ = node;
							_tmp225_ = gxml_node_ns_uri (_tmp224_);
							_tmp226_ = _tmp225_;
							gee_abstract_collection_add ((GeeAbstractCollection*) _tmp223_, _tmp226_);
							_g_free0 (_tmp226_);
						}
					}
				}
			} else {
				GXmlNode* _tmp227_ = NULL;
				GXmlDocument* _tmp228_ = NULL;
				GXmlDocument* _tmp229_ = NULL;
				gboolean _tmp230_ = FALSE;
				gboolean _tmp231_ = FALSE;
				_tmp227_ = node;
				_tmp228_ = gxml_node_get_document (_tmp227_);
				_tmp229_ = _tmp228_;
				_tmp230_ = gxml_document_get_prefix_default_ns (_tmp229_);
				_tmp231_ = _tmp230_;
				if (_tmp231_) {
					xmlTextWriter* _tmp232_ = NULL;
					GXmlNode* _tmp233_ = NULL;
					GXmlDocument* _tmp234_ = NULL;
					GXmlDocument* _tmp235_ = NULL;
					gchar* _tmp236_ = NULL;
					gchar* _tmp237_ = NULL;
					GXmlNode* _tmp238_ = NULL;
					gchar* _tmp239_ = NULL;
					gchar* _tmp240_ = NULL;
					gchar* _tmp241_ = NULL;
					_tmp232_ = tw;
					_tmp233_ = node;
					_tmp234_ = gxml_node_get_document (_tmp233_);
					_tmp235_ = _tmp234_;
					_tmp236_ = gxml_node_ns_prefix ((GXmlNode*) _tmp235_);
					_tmp237_ = _tmp236_;
					_tmp238_ = node;
					_tmp239_ = gxml_node_get_name (_tmp238_);
					_tmp240_ = _tmp239_;
					_tmp241_ = _tmp240_;
					xmlTextWriterStartElementNS (_tmp232_, (xmlChar*) _tmp237_, (xmlChar*) _tmp241_, (xmlChar*) NULL);
					_g_free0 (_tmp241_);
					_g_free0 (_tmp237_);
				} else {
					xmlTextWriter* _tmp242_ = NULL;
					GXmlNode* _tmp243_ = NULL;
					gchar* _tmp244_ = NULL;
					gchar* _tmp245_ = NULL;
					gchar* _tmp246_ = NULL;
					_tmp242_ = tw;
					_tmp243_ = node;
					_tmp244_ = gxml_node_get_name (_tmp243_);
					_tmp245_ = _tmp244_;
					_tmp246_ = _tmp245_;
					xmlTextWriterStartElement (_tmp242_, (xmlChar*) _tmp246_);
					_g_free0 (_tmp246_);
				}
			}
		}
		{
			GeeList* _ns_list = NULL;
			GXmlNode* _tmp247_ = NULL;
			GeeList* _tmp248_ = NULL;
			GeeList* _tmp249_ = NULL;
			gint _ns_size = 0;
			GeeList* _tmp250_ = NULL;
			gint _tmp251_ = 0;
			gint _tmp252_ = 0;
			gint _ns_index = 0;
			_tmp247_ = node;
			_tmp248_ = gxml_node_get_namespaces (_tmp247_);
			_tmp249_ = _tmp248_;
			_ns_list = _tmp249_;
			_tmp250_ = _ns_list;
			_tmp251_ = gee_collection_get_size ((GeeCollection*) _tmp250_);
			_tmp252_ = _tmp251_;
			_ns_size = _tmp252_;
			_ns_index = -1;
			while (TRUE) {
				gint _tmp253_ = 0;
				gint _tmp254_ = 0;
				gint _tmp255_ = 0;
				GXmlNamespace* ns = NULL;
				GeeList* _tmp256_ = NULL;
				gint _tmp257_ = 0;
				gpointer _tmp258_ = NULL;
				GeeArrayList* _tmp259_ = NULL;
				GXmlNamespace* _tmp260_ = NULL;
				gchar* _tmp261_ = NULL;
				gchar* _tmp262_ = NULL;
				gchar* _tmp263_ = NULL;
				gboolean _tmp264_ = FALSE;
				gboolean _tmp265_ = FALSE;
				xmlTextWriter* _tmp266_ = NULL;
				GXmlNamespace* _tmp267_ = NULL;
				gchar* _tmp268_ = NULL;
				gchar* _tmp269_ = NULL;
				gchar* _tmp270_ = NULL;
				gchar* _tmp271_ = NULL;
				gchar* _tmp272_ = NULL;
				GXmlNamespace* _tmp273_ = NULL;
				gchar* _tmp274_ = NULL;
				gchar* _tmp275_ = NULL;
				gchar* _tmp276_ = NULL;
				GeeArrayList* _tmp277_ = NULL;
				GXmlNamespace* _tmp278_ = NULL;
				gchar* _tmp279_ = NULL;
				gchar* _tmp280_ = NULL;
				gchar* _tmp281_ = NULL;
				_tmp253_ = _ns_index;
				_ns_index = _tmp253_ + 1;
				_tmp254_ = _ns_index;
				_tmp255_ = _ns_size;
				if (!(_tmp254_ < _tmp255_)) {
					break;
				}
				_tmp256_ = _ns_list;
				_tmp257_ = _ns_index;
				_tmp258_ = gee_list_get (_tmp256_, _tmp257_);
				ns = (GXmlNamespace*) _tmp258_;
				_tmp259_ = *declared_ns;
				_tmp260_ = ns;
				_tmp261_ = gxml_namespace_get_uri (_tmp260_);
				_tmp262_ = _tmp261_;
				_tmp263_ = _tmp262_;
				_tmp264_ = gee_abstract_collection_contains ((GeeAbstractCollection*) _tmp259_, _tmp263_);
				_tmp265_ = _tmp264_;
				_g_free0 (_tmp263_);
				if (_tmp265_) {
					_g_object_unref0 (ns);
					continue;
				}
				_tmp266_ = tw;
				_tmp267_ = ns;
				_tmp268_ = gxml_namespace_get_prefix (_tmp267_);
				_tmp269_ = _tmp268_;
				_tmp270_ = _tmp269_;
				_tmp271_ = g_strconcat ("xmlns:", _tmp270_, NULL);
				_tmp272_ = _tmp271_;
				_tmp273_ = ns;
				_tmp274_ = gxml_namespace_get_uri (_tmp273_);
				_tmp275_ = _tmp274_;
				_tmp276_ = _tmp275_;
				xmlTextWriterWriteAttribute (_tmp266_, (xmlChar*) _tmp272_, (xmlChar*) _tmp276_);
				_g_free0 (_tmp276_);
				_g_free0 (_tmp272_);
				_g_free0 (_tmp270_);
				_tmp277_ = *declared_ns;
				_tmp278_ = ns;
				_tmp279_ = gxml_namespace_get_uri (_tmp278_);
				_tmp280_ = _tmp279_;
				_tmp281_ = _tmp280_;
				gee_abstract_collection_add ((GeeAbstractCollection*) _tmp277_, _tmp281_);
				_g_free0 (_tmp281_);
				_g_object_unref0 (ns);
			}
			_g_object_unref0 (_ns_list);
		}
		{
			GeeIterator* _attr_it = NULL;
			GXmlNode* _tmp282_ = NULL;
			GeeMap* _tmp283_ = NULL;
			GeeMap* _tmp284_ = NULL;
			GeeMap* _tmp285_ = NULL;
			GeeCollection* _tmp286_ = NULL;
			GeeCollection* _tmp287_ = NULL;
			GeeCollection* _tmp288_ = NULL;
			GeeIterator* _tmp289_ = NULL;
			GeeIterator* _tmp290_ = NULL;
			_tmp282_ = node;
			_tmp283_ = gxml_node_get_attrs (_tmp282_);
			_tmp284_ = _tmp283_;
			_tmp285_ = _tmp284_;
			_tmp286_ = gee_map_get_values (_tmp285_);
			_tmp287_ = _tmp286_;
			_tmp288_ = _tmp287_;
			_tmp289_ = gee_iterable_iterator ((GeeIterable*) _tmp288_);
			_tmp290_ = _tmp289_;
			_g_object_unref0 (_tmp288_);
			_g_object_unref0 (_tmp285_);
			_attr_it = _tmp290_;
			while (TRUE) {
				GeeIterator* _tmp291_ = NULL;
				gboolean _tmp292_ = FALSE;
				GXmlNode* attr = NULL;
				GeeIterator* _tmp293_ = NULL;
				gpointer _tmp294_ = NULL;
				GXmlNode* _tmp295_ = NULL;
				GeeList* _tmp296_ = NULL;
				GeeList* _tmp297_ = NULL;
				GeeList* _tmp298_ = NULL;
				gint _tmp299_ = 0;
				gint _tmp300_ = 0;
				gboolean _tmp301_ = FALSE;
				gint _tmp354_ = 0;
				_tmp291_ = _attr_it;
				_tmp292_ = gee_iterator_next (_tmp291_);
				if (!_tmp292_) {
					break;
				}
				_tmp293_ = _attr_it;
				_tmp294_ = gee_iterator_get (_tmp293_);
				attr = (GXmlNode*) _tmp294_;
				_tmp295_ = attr;
				_tmp296_ = gxml_node_get_namespaces (_tmp295_);
				_tmp297_ = _tmp296_;
				_tmp298_ = _tmp297_;
				_tmp299_ = gee_collection_get_size ((GeeCollection*) _tmp298_);
				_tmp300_ = _tmp299_;
				_tmp301_ = _tmp300_ > 0;
				_g_object_unref0 (_tmp298_);
				if (_tmp301_) {
					GeeArrayList* _tmp302_ = NULL;
					GXmlNode* _tmp303_ = NULL;
					gchar* _tmp304_ = NULL;
					gchar* _tmp305_ = NULL;
					gboolean _tmp306_ = FALSE;
					gboolean _tmp307_ = FALSE;
					_tmp302_ = *declared_ns;
					_tmp303_ = attr;
					_tmp304_ = gxml_node_ns_uri (_tmp303_);
					_tmp305_ = _tmp304_;
					_tmp306_ = gee_abstract_collection_contains ((GeeAbstractCollection*) _tmp302_, _tmp305_);
					_tmp307_ = !_tmp306_;
					_g_free0 (_tmp305_);
					if (_tmp307_) {
						gint _tmp308_ = 0;
						xmlTextWriter* _tmp309_ = NULL;
						GXmlNode* _tmp310_ = NULL;
						gchar* _tmp311_ = NULL;
						gchar* _tmp312_ = NULL;
						GXmlNode* _tmp313_ = NULL;
						gchar* _tmp314_ = NULL;
						gchar* _tmp315_ = NULL;
						gchar* _tmp316_ = NULL;
						GXmlNode* _tmp317_ = NULL;
						gchar* _tmp318_ = NULL;
						gchar* _tmp319_ = NULL;
						GXmlNode* _tmp320_ = NULL;
						gchar* _tmp321_ = NULL;
						gchar* _tmp322_ = NULL;
						gchar* _tmp323_ = NULL;
						gint _tmp324_ = 0;
						GeeArrayList* _tmp325_ = NULL;
						GXmlNode* _tmp326_ = NULL;
						gchar* _tmp327_ = NULL;
						gchar* _tmp328_ = NULL;
						_tmp308_ = size;
						_tmp309_ = tw;
						_tmp310_ = attr;
						_tmp311_ = gxml_node_ns_prefix (_tmp310_);
						_tmp312_ = _tmp311_;
						_tmp313_ = attr;
						_tmp314_ = gxml_node_get_name (_tmp313_);
						_tmp315_ = _tmp314_;
						_tmp316_ = _tmp315_;
						_tmp317_ = attr;
						_tmp318_ = gxml_node_ns_uri (_tmp317_);
						_tmp319_ = _tmp318_;
						_tmp320_ = attr;
						_tmp321_ = gxml_node_get_value (_tmp320_);
						_tmp322_ = _tmp321_;
						_tmp323_ = _tmp322_;
						_tmp324_ = xmlTextWriterWriteAttributeNS (_tmp309_, (xmlChar*) _tmp312_, (xmlChar*) _tmp316_, (xmlChar*) _tmp319_, (xmlChar*) _tmp323_);
						size = _tmp308_ + _tmp324_;
						_g_free0 (_tmp323_);
						_g_free0 (_tmp319_);
						_g_free0 (_tmp316_);
						_g_free0 (_tmp312_);
						_tmp325_ = *declared_ns;
						_tmp326_ = attr;
						_tmp327_ = gxml_node_ns_uri (_tmp326_);
						_tmp328_ = _tmp327_;
						gee_abstract_collection_add ((GeeAbstractCollection*) _tmp325_, _tmp328_);
						_g_free0 (_tmp328_);
					} else {
						gint _tmp329_ = 0;
						xmlTextWriter* _tmp330_ = NULL;
						GXmlNode* _tmp331_ = NULL;
						gchar* _tmp332_ = NULL;
						gchar* _tmp333_ = NULL;
						GXmlNode* _tmp334_ = NULL;
						gchar* _tmp335_ = NULL;
						gchar* _tmp336_ = NULL;
						gchar* _tmp337_ = NULL;
						GXmlNode* _tmp338_ = NULL;
						gchar* _tmp339_ = NULL;
						gchar* _tmp340_ = NULL;
						gchar* _tmp341_ = NULL;
						gint _tmp342_ = 0;
						_tmp329_ = size;
						_tmp330_ = tw;
						_tmp331_ = attr;
						_tmp332_ = gxml_node_ns_prefix (_tmp331_);
						_tmp333_ = _tmp332_;
						_tmp334_ = attr;
						_tmp335_ = gxml_node_get_name (_tmp334_);
						_tmp336_ = _tmp335_;
						_tmp337_ = _tmp336_;
						_tmp338_ = attr;
						_tmp339_ = gxml_node_get_value (_tmp338_);
						_tmp340_ = _tmp339_;
						_tmp341_ = _tmp340_;
						_tmp342_ = xmlTextWriterWriteAttributeNS (_tmp330_, (xmlChar*) _tmp333_, (xmlChar*) _tmp337_, (xmlChar*) NULL, (xmlChar*) _tmp341_);
						size = _tmp329_ + _tmp342_;
						_g_free0 (_tmp341_);
						_g_free0 (_tmp337_);
						_g_free0 (_tmp333_);
					}
				} else {
					gint _tmp343_ = 0;
					xmlTextWriter* _tmp344_ = NULL;
					GXmlNode* _tmp345_ = NULL;
					gchar* _tmp346_ = NULL;
					gchar* _tmp347_ = NULL;
					gchar* _tmp348_ = NULL;
					GXmlNode* _tmp349_ = NULL;
					gchar* _tmp350_ = NULL;
					gchar* _tmp351_ = NULL;
					gchar* _tmp352_ = NULL;
					gint _tmp353_ = 0;
					_tmp343_ = size;
					_tmp344_ = tw;
					_tmp345_ = attr;
					_tmp346_ = gxml_node_get_name (_tmp345_);
					_tmp347_ = _tmp346_;
					_tmp348_ = _tmp347_;
					_tmp349_ = attr;
					_tmp350_ = gxml_node_get_value (_tmp349_);
					_tmp351_ = _tmp350_;
					_tmp352_ = _tmp351_;
					_tmp353_ = xmlTextWriterWriteAttribute (_tmp344_, (xmlChar*) _tmp348_, (xmlChar*) _tmp352_);
					size = _tmp343_ + _tmp353_;
					_g_free0 (_tmp352_);
					_g_free0 (_tmp348_);
				}
				_tmp354_ = size;
				if (_tmp354_ > 1500) {
					xmlTextWriter* _tmp355_ = NULL;
					_tmp355_ = tw;
					xmlTextWriterFlush (_tmp355_);
				}
				_g_object_unref0 (attr);
			}
			_g_object_unref0 (_attr_it);
		}
	}
	{
		GeeBidirList* _n_list = NULL;
		GXmlNode* _tmp356_ = NULL;
		GeeBidirList* _tmp357_ = NULL;
		GeeBidirList* _tmp358_ = NULL;
		gint _n_size = 0;
		GeeBidirList* _tmp359_ = NULL;
		gint _tmp360_ = 0;
		gint _tmp361_ = 0;
		gint _n_index = 0;
		_tmp356_ = node;
		_tmp357_ = gxml_node_get_children_nodes (_tmp356_);
		_tmp358_ = _tmp357_;
		_n_list = _tmp358_;
		_tmp359_ = _n_list;
		_tmp360_ = gee_collection_get_size ((GeeCollection*) _tmp359_);
		_tmp361_ = _tmp360_;
		_n_size = _tmp361_;
		_n_index = -1;
		while (TRUE) {
			gint _tmp362_ = 0;
			gint _tmp363_ = 0;
			gint _tmp364_ = 0;
			GXmlNode* n = NULL;
			GeeBidirList* _tmp365_ = NULL;
			gint _tmp366_ = 0;
			gpointer _tmp367_ = NULL;
			GXmlNode* _tmp368_ = NULL;
			GXmlNode* _tmp422_ = NULL;
			GXmlNode* _tmp432_ = NULL;
			GXmlNode* _tmp442_ = NULL;
			GXmlNode* _tmp452_ = NULL;
			_tmp362_ = _n_index;
			_n_index = _tmp362_ + 1;
			_tmp363_ = _n_index;
			_tmp364_ = _n_size;
			if (!(_tmp363_ < _tmp364_)) {
				break;
			}
			_tmp365_ = _n_list;
			_tmp366_ = _n_index;
			_tmp367_ = gee_list_get ((GeeList*) _tmp365_, _tmp366_);
			n = (GXmlNode*) _tmp367_;
			_tmp368_ = n;
			if (G_TYPE_CHECK_INSTANCE_TYPE (_tmp368_, GXML_TYPE_ELEMENT)) {
				GXmlNode* _tmp369_ = NULL;
				GeeList* _tmp370_ = NULL;
				GeeList* _tmp371_ = NULL;
				GeeList* _tmp372_ = NULL;
				gint _tmp373_ = 0;
				gint _tmp374_ = 0;
				gboolean _tmp375_ = FALSE;
				GXmlNode* _tmp410_ = NULL;
				gint _tmp417_ = 0;
				xmlTextWriter* _tmp418_ = NULL;
				gint _tmp419_ = 0;
				gint _tmp420_ = 0;
				_tmp369_ = node;
				_tmp370_ = gxml_node_get_namespaces (_tmp369_);
				_tmp371_ = _tmp370_;
				_tmp372_ = _tmp371_;
				_tmp373_ = gee_collection_get_size ((GeeCollection*) _tmp372_);
				_tmp374_ = _tmp373_;
				_tmp375_ = _tmp374_ > 0;
				_g_object_unref0 (_tmp372_);
				if (_tmp375_) {
					GXmlNode* _tmp376_ = NULL;
					GXmlDocument* _tmp377_ = NULL;
					GXmlDocument* _tmp378_ = NULL;
					GeeList* _tmp379_ = NULL;
					GeeList* _tmp380_ = NULL;
					GeeList* _tmp381_ = NULL;
					gint _tmp382_ = 0;
					gint _tmp383_ = 0;
					gboolean _tmp384_ = FALSE;
					_tmp376_ = node;
					_tmp377_ = gxml_node_get_document (_tmp376_);
					_tmp378_ = _tmp377_;
					_tmp379_ = gxml_node_get_namespaces ((GXmlNode*) _tmp378_);
					_tmp380_ = _tmp379_;
					_tmp381_ = _tmp380_;
					_tmp382_ = gee_collection_get_size ((GeeCollection*) _tmp381_);
					_tmp383_ = _tmp382_;
					_tmp384_ = _tmp383_ > 0;
					_g_object_unref0 (_tmp381_);
					if (_tmp384_) {
						GXmlNode* _tmp385_ = NULL;
						gchar* _tmp386_ = NULL;
						gchar* _tmp387_ = NULL;
						GXmlNode* _tmp388_ = NULL;
						GXmlDocument* _tmp389_ = NULL;
						GXmlDocument* _tmp390_ = NULL;
						gchar* _tmp391_ = NULL;
						gchar* _tmp392_ = NULL;
						gboolean _tmp393_ = FALSE;
						_tmp385_ = node;
						_tmp386_ = gxml_node_ns_uri (_tmp385_);
						_tmp387_ = _tmp386_;
						_tmp388_ = node;
						_tmp389_ = gxml_node_get_document (_tmp388_);
						_tmp390_ = _tmp389_;
						_tmp391_ = gxml_node_ns_uri ((GXmlNode*) _tmp390_);
						_tmp392_ = _tmp391_;
						_tmp393_ = g_strcmp0 (_tmp387_, _tmp392_) != 0;
						_g_free0 (_tmp392_);
						_g_free0 (_tmp387_);
						if (_tmp393_) {
							gboolean _tmp394_ = FALSE;
							GXmlNode* _tmp395_ = NULL;
							GeeList* _tmp396_ = NULL;
							GeeList* _tmp397_ = NULL;
							GeeList* _tmp398_ = NULL;
							gint _tmp399_ = 0;
							gint _tmp400_ = 0;
							gboolean _tmp401_ = FALSE;
							_tmp395_ = n;
							_tmp396_ = gxml_node_get_namespaces (_tmp395_);
							_tmp397_ = _tmp396_;
							_tmp398_ = _tmp397_;
							_tmp399_ = gee_collection_get_size ((GeeCollection*) _tmp398_);
							_tmp400_ = _tmp399_;
							_tmp401_ = _tmp400_ == 0;
							_g_object_unref0 (_tmp398_);
							if (_tmp401_) {
								GXmlNode* _tmp402_ = NULL;
								_tmp402_ = node;
								_tmp394_ = gxml_node_ns_prefix == NULL;
							} else {
								_tmp394_ = FALSE;
							}
							if (_tmp394_) {
								GXmlNode* _tmp403_ = NULL;
								GXmlNode* _tmp404_ = NULL;
								gchar* _tmp405_ = NULL;
								gchar* _tmp406_ = NULL;
								GXmlNode* _tmp407_ = NULL;
								gchar* _tmp408_ = NULL;
								gchar* _tmp409_ = NULL;
								_tmp403_ = n;
								_tmp404_ = node;
								_tmp405_ = gxml_node_ns_uri (_tmp404_);
								_tmp406_ = _tmp405_;
								_tmp407_ = node;
								_tmp408_ = gxml_node_ns_prefix (_tmp407_);
								_tmp409_ = _tmp408_;
								gxml_node_set_namespace (_tmp403_, _tmp406_, _tmp409_);
								_g_free0 (_tmp409_);
								_g_free0 (_tmp406_);
							}
						}
					}
				}
				_tmp410_ = node;
				if (G_TYPE_CHECK_INSTANCE_TYPE (_tmp410_, GXML_TYPE_DOCUMENT)) {
					GXmlDocument* _tmp411_ = NULL;
					xmlTextWriter* _tmp412_ = NULL;
					GXmlNode* _tmp413_ = NULL;
					_tmp411_ = doc;
					_tmp412_ = tw;
					_tmp413_ = n;
					gxml_tdocument_start_node (_tmp411_, _tmp412_, _tmp413_, TRUE, declared_ns, &_inner_error_);
					if (G_UNLIKELY (_inner_error_ != NULL)) {
						g_propagate_error (error, _inner_error_);
						_g_object_unref0 (n);
						_g_object_unref0 (_n_list);
						return;
					}
				} else {
					GXmlDocument* _tmp414_ = NULL;
					xmlTextWriter* _tmp415_ = NULL;
					GXmlNode* _tmp416_ = NULL;
					_tmp414_ = doc;
					_tmp415_ = tw;
					_tmp416_ = n;
					gxml_tdocument_start_node (_tmp414_, _tmp415_, _tmp416_, FALSE, declared_ns, &_inner_error_);
					if (G_UNLIKELY (_inner_error_ != NULL)) {
						g_propagate_error (error, _inner_error_);
						_g_object_unref0 (n);
						_g_object_unref0 (_n_list);
						return;
					}
				}
				_tmp417_ = size;
				_tmp418_ = tw;
				_tmp419_ = xmlTextWriterEndElement (_tmp418_);
				size = _tmp417_ + _tmp419_;
				_tmp420_ = size;
				if (_tmp420_ > 1500) {
					xmlTextWriter* _tmp421_ = NULL;
					_tmp421_ = tw;
					xmlTextWriterFlush (_tmp421_);
				}
			}
			_tmp422_ = n;
			if (G_TYPE_CHECK_INSTANCE_TYPE (_tmp422_, GXML_TYPE_TEXT)) {
				gint _tmp423_ = 0;
				xmlTextWriter* _tmp424_ = NULL;
				GXmlNode* _tmp425_ = NULL;
				gchar* _tmp426_ = NULL;
				gchar* _tmp427_ = NULL;
				gchar* _tmp428_ = NULL;
				gint _tmp429_ = 0;
				gint _tmp430_ = 0;
				_tmp423_ = size;
				_tmp424_ = tw;
				_tmp425_ = n;
				_tmp426_ = gxml_node_get_value (_tmp425_);
				_tmp427_ = _tmp426_;
				_tmp428_ = _tmp427_;
				_tmp429_ = xmlTextWriterWriteString (_tmp424_, (xmlChar*) _tmp428_);
				size = _tmp423_ + _tmp429_;
				_g_free0 (_tmp428_);
				_tmp430_ = size;
				if (_tmp430_ > 1500) {
					xmlTextWriter* _tmp431_ = NULL;
					_tmp431_ = tw;
					xmlTextWriterFlush (_tmp431_);
				}
			}
			_tmp432_ = n;
			if (G_TYPE_CHECK_INSTANCE_TYPE (_tmp432_, GXML_TYPE_COMMENT)) {
				gint _tmp433_ = 0;
				xmlTextWriter* _tmp434_ = NULL;
				GXmlNode* _tmp435_ = NULL;
				gchar* _tmp436_ = NULL;
				gchar* _tmp437_ = NULL;
				gchar* _tmp438_ = NULL;
				gint _tmp439_ = 0;
				gint _tmp440_ = 0;
				_tmp433_ = size;
				_tmp434_ = tw;
				_tmp435_ = n;
				_tmp436_ = gxml_node_get_value (_tmp435_);
				_tmp437_ = _tmp436_;
				_tmp438_ = _tmp437_;
				_tmp439_ = xmlTextWriterWriteComment (_tmp434_, (xmlChar*) _tmp438_);
				size = _tmp433_ + _tmp439_;
				_g_free0 (_tmp438_);
				_tmp440_ = size;
				if (_tmp440_ > 1500) {
					xmlTextWriter* _tmp441_ = NULL;
					_tmp441_ = tw;
					xmlTextWriterFlush (_tmp441_);
				}
			}
			_tmp442_ = n;
			if (G_TYPE_CHECK_INSTANCE_TYPE (_tmp442_, GXML_TYPE_CDATA)) {
				gint _tmp443_ = 0;
				xmlTextWriter* _tmp444_ = NULL;
				GXmlNode* _tmp445_ = NULL;
				gchar* _tmp446_ = NULL;
				gchar* _tmp447_ = NULL;
				gchar* _tmp448_ = NULL;
				gint _tmp449_ = 0;
				gint _tmp450_ = 0;
				_tmp443_ = size;
				_tmp444_ = tw;
				_tmp445_ = n;
				_tmp446_ = gxml_node_get_value (_tmp445_);
				_tmp447_ = _tmp446_;
				_tmp448_ = _tmp447_;
				_tmp449_ = xmlTextWriterWriteCDATA (_tmp444_, (xmlChar*) _tmp448_);
				size = _tmp443_ + _tmp449_;
				_g_free0 (_tmp448_);
				_tmp450_ = size;
				if (_tmp450_ > 1500) {
					xmlTextWriter* _tmp451_ = NULL;
					_tmp451_ = tw;
					xmlTextWriterFlush (_tmp451_);
				}
			}
			_tmp452_ = n;
			if (G_TYPE_CHECK_INSTANCE_TYPE (_tmp452_, GXML_TYPE_PROCESSING_INSTRUCTION)) {
				gint _tmp453_ = 0;
				xmlTextWriter* _tmp454_ = NULL;
				GXmlNode* _tmp455_ = NULL;
				gchar* _tmp456_ = NULL;
				gchar* _tmp457_ = NULL;
				gchar* _tmp458_ = NULL;
				GXmlNode* _tmp459_ = NULL;
				gchar* _tmp460_ = NULL;
				gchar* _tmp461_ = NULL;
				gchar* _tmp462_ = NULL;
				gint _tmp463_ = 0;
				gint _tmp464_ = 0;
				_tmp453_ = size;
				_tmp454_ = tw;
				_tmp455_ = n;
				_tmp456_ = gxml_processing_instruction_get_target (G_TYPE_CHECK_INSTANCE_CAST (_tmp455_, GXML_TYPE_PROCESSING_INSTRUCTION, GXmlProcessingInstruction));
				_tmp457_ = _tmp456_;
				_tmp458_ = _tmp457_;
				_tmp459_ = n;
				_tmp460_ = gxml_processing_instruction_get_data (G_TYPE_CHECK_INSTANCE_CAST (_tmp459_, GXML_TYPE_PROCESSING_INSTRUCTION, GXmlProcessingInstruction));
				_tmp461_ = _tmp460_;
				_tmp462_ = _tmp461_;
				_tmp463_ = xmlTextWriterWritePI (_tmp454_, (xmlChar*) _tmp458_, (xmlChar*) _tmp462_);
				size = _tmp453_ + _tmp463_;
				_g_free0 (_tmp462_);
				_g_free0 (_tmp458_);
				_tmp464_ = size;
				if (_tmp464_ > 1500) {
					xmlTextWriter* _tmp465_ = NULL;
					_tmp465_ = tw;
					xmlTextWriterFlush (_tmp465_);
				}
			}
			_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_error_ = NULL;
	self = (GXmlTDocument*) base;
	{
		xmlDoc* doc = NULL;
		xmlTextWriter* tw = NULL;
		xmlTextWriter* _tmp0_ = NULL;
		gchar* str = NULL;
		gint size = 0;
		xmlDoc* _tmp1_ = NULL;
		gchar* _tmp2_ = NULL;
		gint _tmp3_ = 0;
		doc = NULL;
		_tmp0_ = xmlNewTextWriterDoc (&doc, FALSE);
		tw = _tmp0_;
		gxml_tdocument_write_document ((GXmlDocument*) self, tw, &_inner_error_);
		if (G_UNLIKELY (_inner_error_ != 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_ = NULL;
		const gchar* _tmp5_ = NULL;
		gchar* _tmp6_ = NULL;
		e = _inner_error_;
		_inner_error_ = 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_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
	g_clear_error (&_inner_error_);
	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, void* rtfunc_target, GError** error) {
	GFile* _tmp0_ = NULL;
	gboolean _tmp1_ = FALSE;
	GFileInputStream* _tmp4_ = NULL;
	GFile* _tmp5_ = NULL;
	GFileInputStream* _tmp6_ = NULL;
	GXmlDocument* _tmp7_ = NULL;
	GXmlTDocumentReadTypeFunc _tmp8_ = NULL;
	void* _tmp8__target = NULL;
	GError * _inner_error_ = NULL;
	g_return_if_fail (doc != NULL);
	g_return_if_fail (file != NULL);
	_tmp0_ = file;
	_tmp1_ = g_file_query_exists (_tmp0_, NULL);
	if (!_tmp1_) {
		const gchar* _tmp2_ = NULL;
		GError* _tmp3_ = NULL;
		_tmp2_ = _ ("File doesn't exist");
		_tmp3_ = g_error_new_literal (GXML_DOCUMENT_ERROR, GXML_DOCUMENT_ERROR_INVALID_FILE, _tmp2_);
		_inner_error_ = _tmp3_;
		g_propagate_error (error, _inner_error_);
		return;
	}
	_tmp5_ = file;
	_tmp6_ = g_file_read (_tmp5_, NULL, &_inner_error_);
	_tmp4_ = _tmp6_;
	if (G_UNLIKELY (_inner_error_ != NULL)) {
		g_propagate_error (error, _inner_error_);
		return;
	}
	_tmp7_ = doc;
	_tmp8_ = rtfunc;
	_tmp8__target = rtfunc_target;
	gxml_tdocument_read_doc_stream (_tmp7_, (GInputStream*) _tmp4_, _tmp8_, _tmp8__target, &_inner_error_);
	if (G_UNLIKELY (_inner_error_ != NULL)) {
		g_propagate_error (error, _inner_error_);
		_g_object_unref0 (_tmp4_);
		return;
	}
	_g_object_unref0 (_tmp4_);
}


/**
   * Reads document from {@link GLib.InputStream} objects.
   */
void gxml_tdocument_read_doc_stream (GXmlDocument* doc, GInputStream* istream, GXmlTDocumentReadTypeFunc rtfunc, void* rtfunc_target, GError** error) {
	GMemoryOutputStream* b = NULL;
	GMemoryOutputStream* _tmp0_ = NULL;
	GMemoryOutputStream* _tmp1_ = NULL;
	GInputStream* _tmp2_ = NULL;
	xmlTextReader* tr = NULL;
	GMemoryOutputStream* _tmp3_ = NULL;
	void* _tmp4_ = NULL;
	void* _tmp5_ = NULL;
	GMemoryOutputStream* _tmp6_ = NULL;
	gsize _tmp7_ = 0UL;
	xmlTextReader* _tmp8_ = NULL;
	GError * _inner_error_ = 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;
	_tmp2_ = istream;
	g_output_stream_splice ((GOutputStream*) _tmp1_, _tmp2_, 0, NULL, &_inner_error_);
	if (G_UNLIKELY (_inner_error_ != NULL)) {
		g_propagate_error (error, _inner_error_);
		_g_object_unref0 (b);
		return;
	}
	_tmp3_ = b;
	_tmp4_ = g_memory_output_stream_get_data (_tmp3_);
	_tmp5_ = _tmp4_;
	_tmp6_ = b;
	_tmp7_ = g_memory_output_stream_get_data_size (_tmp6_);
	_tmp8_ = xmlReaderForMemory ((gchar*) _tmp5_, (gint) _tmp7_, "/gxml_memory", NULL, 0);
	tr = _tmp8_;
	while (TRUE) {
		GXmlTDocumentReadType _tmp9_ = 0;
		GXmlDocument* _tmp10_ = NULL;
		xmlTextReader* _tmp11_ = NULL;
		GXmlTDocumentReadTypeFunc _tmp12_ = NULL;
		void* _tmp12__target = NULL;
		GXmlTDocumentReadType _tmp13_ = 0;
		_tmp10_ = doc;
		_tmp11_ = tr;
		_tmp12_ = rtfunc;
		_tmp12__target = rtfunc_target;
		_tmp13_ = gxml_tdocument_read_node ((GXmlNode*) _tmp10_, _tmp11_, _tmp12_, _tmp12__target, &_inner_error_);
		_tmp9_ = _tmp13_;
		if (G_UNLIKELY (_inner_error_ != NULL)) {
			g_propagate_error (error, _inner_error_);
			_xmlFreeTextReader0 (tr);
			_g_object_unref0 (b);
			return;
		}
		if (!(_tmp9_ == GXML_TDOCUMENT_READ_TYPE_CONTINUE)) {
			break;
		}
	}
	_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, void* rntfunc_target, GError** error) {
	GXmlTDocumentReadType result = 0;
	GXmlNode* n = NULL;
	gchar* prefix = NULL;
	gchar* nsuri = NULL;
	GXmlTDocumentReadType rt = 0;
	GXmlTDocumentReadTypeFunc _tmp0_ = NULL;
	void* _tmp0__target = NULL;
	GXmlTDocumentReadType _tmp5_ = 0;
	GXmlTDocumentReadType _tmp8_ = 0;
	gint t = 0;
	xmlTextReader* _tmp11_ = NULL;
	gint _tmp12_ = 0;
	gint _tmp13_ = 0;
	GError * _inner_error_ = 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;
	_tmp0_ = rntfunc;
	_tmp0__target = rntfunc_target;
	if (_tmp0_ != NULL) {
		GXmlTDocumentReadTypeFunc _tmp1_ = NULL;
		void* _tmp1__target = NULL;
		GXmlNode* _tmp2_ = NULL;
		xmlTextReader* _tmp3_ = NULL;
		GXmlTDocumentReadType _tmp4_ = 0;
		_tmp1_ = rntfunc;
		_tmp1__target = rntfunc_target;
		_tmp2_ = node;
		_tmp3_ = tr;
		_tmp4_ = _tmp1_ (_tmp2_, _tmp3_, _tmp1__target);
		rt = _tmp4_;
	}
	_tmp5_ = rt;
	if (_tmp5_ == GXML_TDOCUMENT_READ_TYPE_CONTINUE) {
		xmlTextReader* _tmp6_ = NULL;
		gint _tmp7_ = 0;
		_tmp6_ = tr;
		_tmp7_ = xmlTextReaderRead (_tmp6_);
		if (_tmp7_ != 1) {
			result = GXML_TDOCUMENT_READ_TYPE_STOP;
			_g_free0 (nsuri);
			_g_free0 (prefix);
			_g_object_unref0 (n);
			return result;
		}
	}
	_tmp8_ = rt;
	if (_tmp8_ == GXML_TDOCUMENT_READ_TYPE_NEXT) {
		xmlTextReader* _tmp9_ = NULL;
		gint _tmp10_ = 0;
		_tmp9_ = tr;
		_tmp10_ = xmlTextReaderNext (_tmp9_);
		if (_tmp10_ != 1) {
			result = GXML_TDOCUMENT_READ_TYPE_STOP;
			_g_free0 (nsuri);
			_g_free0 (prefix);
			_g_object_unref0 (n);
			return result;
		}
	}
	_tmp11_ = tr;
	_tmp12_ = xmlTextReaderNodeType (_tmp11_);
	t = _tmp12_;
	_tmp13_ = t;
	switch (_tmp13_) {
		case XML_READER_TYPE_NONE:
		{
			xmlTextReader* _tmp14_ = NULL;
			gint _tmp15_ = 0;
			_tmp14_ = tr;
			_tmp15_ = xmlTextReaderRead (_tmp14_);
			if (_tmp15_ != 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;
			xmlTextReader* _tmp16_ = NULL;
			gint _tmp17_ = 0;
			GXmlNode* _tmp18_ = NULL;
			GXmlNode* _tmp19_ = NULL;
			GXmlDocument* _tmp20_ = NULL;
			GXmlDocument* _tmp21_ = NULL;
			xmlTextReader* _tmp22_ = NULL;
			const gchar* _tmp23_ = NULL;
			GXmlNode* _tmp24_ = NULL;
			GXmlNode* _tmp25_ = NULL;
			GXmlTDocumentReadType nrt = 0;
			GXmlTDocumentReadTypeFunc _tmp26_ = NULL;
			void* _tmp26__target = NULL;
			GXmlTDocumentReadType _tmp31_ = 0;
			GXmlTDocumentReadType _tmp46_ = 0;
			GXmlNode* _tmp48_ = NULL;
			GeeBidirList* _tmp49_ = NULL;
			GeeBidirList* _tmp50_ = NULL;
			GeeBidirList* _tmp51_ = NULL;
			GXmlNode* _tmp52_ = NULL;
			xmlTextReader* _tmp53_ = NULL;
			gchar* _tmp54_ = NULL;
			const gchar* _tmp55_ = NULL;
			gint nattr = 0;
			xmlTextReader* _tmp63_ = NULL;
			gint _tmp64_ = 0;
			gboolean _tmp119_ = FALSE;
			_tmp16_ = tr;
			_tmp17_ = xmlTextReaderIsEmptyElement (_tmp16_);
			isempty = _tmp17_ == 1;
			_tmp19_ = node;
			_tmp20_ = gxml_node_get_document (_tmp19_);
			_tmp21_ = _tmp20_;
			_tmp22_ = tr;
			_tmp23_ = (const gchar*) xmlTextReaderConstLocalName (_tmp22_);
			_tmp24_ = gxml_document_create_element (_tmp21_, _tmp23_, &_inner_error_);
			_tmp18_ = _tmp24_;
			if (G_UNLIKELY (_inner_error_ != NULL)) {
				g_propagate_error (error, _inner_error_);
				_g_free0 (nsuri);
				_g_free0 (prefix);
				_g_object_unref0 (n);
				return 0;
			}
			_tmp25_ = _tmp18_;
			_tmp18_ = NULL;
			_g_object_unref0 (n);
			n = _tmp25_;
			nrt = GXML_TDOCUMENT_READ_TYPE_CONTINUE;
			_tmp26_ = rntfunc;
			_tmp26__target = rntfunc_target;
			if (_tmp26_ != NULL) {
				GXmlTDocumentReadTypeFunc _tmp27_ = NULL;
				void* _tmp27__target = NULL;
				GXmlNode* _tmp28_ = NULL;
				xmlTextReader* _tmp29_ = NULL;
				GXmlTDocumentReadType _tmp30_ = 0;
				_tmp27_ = rntfunc;
				_tmp27__target = rntfunc_target;
				_tmp28_ = n;
				_tmp29_ = tr;
				_tmp30_ = _tmp27_ (_tmp28_, _tmp29_, _tmp27__target);
				nrt = _tmp30_;
			}
			_tmp31_ = nrt;
			if (_tmp31_ == GXML_TDOCUMENT_READ_TYPE_NEXT) {
				gboolean _tmp32_ = FALSE;
				gboolean cont = FALSE;
				_tmp32_ = isempty;
				if (_tmp32_) {
					result = GXML_TDOCUMENT_READ_TYPE_CONTINUE;
					_g_object_unref0 (_tmp18_);
					_g_free0 (nsuri);
					_g_free0 (prefix);
					_g_object_unref0 (n);
					return result;
				}
				cont = TRUE;
				while (TRUE) {
					gboolean _tmp33_ = FALSE;
					xmlTextReader* _tmp34_ = NULL;
					gint _tmp35_ = 0;
					xmlTextReader* _tmp36_ = NULL;
					gint _tmp37_ = 0;
					gint _tmp38_ = 0;
					_tmp33_ = cont;
					if (!_tmp33_) {
						break;
					}
					_tmp34_ = tr;
					_tmp35_ = xmlTextReaderRead (_tmp34_);
					if (_tmp35_ != 1) {
						result = GXML_TDOCUMENT_READ_TYPE_STOP;
						_g_object_unref0 (_tmp18_);
						_g_free0 (nsuri);
						_g_free0 (prefix);
						_g_object_unref0 (n);
						return result;
					}
					_tmp36_ = tr;
					_tmp37_ = xmlTextReaderNodeType (_tmp36_);
					t = _tmp37_;
					_tmp38_ = t;
					if (_tmp38_ == ((gint) XML_READER_TYPE_END_ELEMENT)) {
						xmlTextReader* _tmp39_ = NULL;
						const gchar* _tmp40_ = NULL;
						GXmlNode* _tmp41_ = NULL;
						gchar* _tmp42_ = NULL;
						gchar* _tmp43_ = NULL;
						gchar* _tmp44_ = NULL;
						gboolean _tmp45_ = FALSE;
						_tmp39_ = tr;
						_tmp40_ = (const gchar*) xmlTextReaderConstLocalName (_tmp39_);
						_tmp41_ = n;
						_tmp42_ = gxml_node_get_name (_tmp41_);
						_tmp43_ = _tmp42_;
						_tmp44_ = _tmp43_;
						_tmp45_ = g_strcmp0 (_tmp40_, _tmp44_) == 0;
						_g_free0 (_tmp44_);
						if (_tmp45_) {
							cont = FALSE;
						}
					}
				}
				result = GXML_TDOCUMENT_READ_TYPE_CONTINUE;
				_g_object_unref0 (_tmp18_);
				_g_free0 (nsuri);
				_g_free0 (prefix);
				_g_object_unref0 (n);
				return result;
			}
			_tmp46_ = nrt;
			if (_tmp46_ == GXML_TDOCUMENT_READ_TYPE_STOP) {
				xmlTextReader* _tmp47_ = NULL;
				_tmp47_ = tr;
				xmlTextReaderClose (_tmp47_);
				result = GXML_TDOCUMENT_READ_TYPE_STOP;
				_g_object_unref0 (_tmp18_);
				_g_free0 (nsuri);
				_g_free0 (prefix);
				_g_object_unref0 (n);
				return result;
			}
			_tmp48_ = node;
			_tmp49_ = gxml_node_get_children_nodes (_tmp48_);
			_tmp50_ = _tmp49_;
			_tmp51_ = _tmp50_;
			_tmp52_ = n;
			gee_collection_add ((GeeCollection*) _tmp51_, _tmp52_);
			_g_object_unref0 (_tmp51_);
			_tmp53_ = tr;
			_tmp54_ = (gchar*) xmlTextReaderPrefix (_tmp53_);
			_g_free0 (prefix);
			prefix = _tmp54_;
			_tmp55_ = prefix;
			if (_tmp55_ != NULL) {
				xmlTextReader* _tmp56_ = NULL;
				const gchar* _tmp57_ = NULL;
				gchar* _tmp58_ = NULL;
				const gchar* _tmp59_ = NULL;
				_tmp56_ = tr;
				_tmp57_ = prefix;
				_tmp58_ = (gchar*) xmlTextReaderLookupNamespace (_tmp56_, (xmlChar*) _tmp57_);
				_g_free0 (nsuri);
				nsuri = _tmp58_;
				_tmp59_ = nsuri;
				if (_tmp59_ != NULL) {
					GXmlNode* _tmp60_ = NULL;
					const gchar* _tmp61_ = NULL;
					const gchar* _tmp62_ = NULL;
					_tmp60_ = n;
					_tmp61_ = nsuri;
					_tmp62_ = prefix;
					gxml_node_set_namespace (_tmp60_, _tmp61_, _tmp62_);
				}
			}
			_tmp63_ = tr;
			_tmp64_ = xmlTextReaderAttributeCount (_tmp63_);
			nattr = _tmp64_;
			{
				gint i = 0;
				i = 0;
				{
					gboolean _tmp65_ = FALSE;
					_tmp65_ = TRUE;
					while (TRUE) {
						gint _tmp67_ = 0;
						gint _tmp68_ = 0;
						gint c = 0;
						xmlTextReader* _tmp69_ = NULL;
						gint _tmp70_ = 0;
						gint _tmp71_ = 0;
						gint _tmp72_ = 0;
						xmlTextReader* _tmp79_ = NULL;
						gint _tmp80_ = 0;
						if (!_tmp65_) {
							gint _tmp66_ = 0;
							_tmp66_ = i;
							i = _tmp66_ + 1;
						}
						_tmp65_ = FALSE;
						_tmp67_ = i;
						_tmp68_ = nattr;
						if (!(_tmp67_ < _tmp68_)) {
							break;
						}
						_tmp69_ = tr;
						_tmp70_ = i;
						_tmp71_ = xmlTextReaderMoveToAttributeNo (_tmp69_, _tmp70_);
						c = _tmp71_;
						_tmp72_ = c;
						if (_tmp72_ != 1) {
							const gchar* _tmp73_ = NULL;
							gint _tmp74_ = 0;
							gchar* _tmp75_ = NULL;
							gchar* _tmp76_ = NULL;
							GError* _tmp77_ = NULL;
							GError* _tmp78_ = NULL;
							_tmp73_ = _ ("Parsing ERROR: Fail to move to attribute number: %i");
							_tmp74_ = i;
							_tmp75_ = g_strdup_printf (_tmp73_, _tmp74_);
							_tmp76_ = _tmp75_;
							_tmp77_ = g_error_new_literal (GXML_DOCUMENT_ERROR, GXML_DOCUMENT_ERROR_INVALID_DOCUMENT_ERROR, _tmp76_);
							_tmp78_ = _tmp77_;
							_g_free0 (_tmp76_);
							_inner_error_ = _tmp78_;
							g_propagate_error (error, _inner_error_);
							_g_object_unref0 (_tmp18_);
							_g_free0 (nsuri);
							_g_free0 (prefix);
							_g_object_unref0 (n);
							return 0;
						}
						_tmp79_ = tr;
						_tmp80_ = xmlTextReaderIsNamespaceDecl (_tmp79_);
						if (_tmp80_ == 1) {
							gchar* nsp = NULL;
							xmlTextReader* _tmp81_ = NULL;
							const gchar* _tmp82_ = NULL;
							gchar* _tmp83_ = NULL;
							xmlTextReader* _tmp84_ = NULL;
							xmlTextReader* _tmp85_ = NULL;
							gint _tmp86_ = 0;
							_tmp81_ = tr;
							_tmp82_ = (const gchar*) xmlTextReaderConstLocalName (_tmp81_);
							_tmp83_ = g_strdup (_tmp82_);
							nsp = _tmp83_;
							_tmp84_ = tr;
							xmlTextReaderReadAttributeValue (_tmp84_);
							_tmp85_ = tr;
							_tmp86_ = xmlTextReaderNodeType (_tmp85_);
							if (_tmp86_ == ((gint) XML_READER_TYPE_TEXT)) {
								xmlTextReader* _tmp87_ = NULL;
								gchar* _tmp88_ = NULL;
								GXmlNode* _tmp89_ = NULL;
								const gchar* _tmp90_ = NULL;
								const gchar* _tmp91_ = NULL;
								_tmp87_ = tr;
								_tmp88_ = (gchar*) xmlTextReaderReadString (_tmp87_);
								_g_free0 (nsuri);
								nsuri = _tmp88_;
								_tmp89_ = n;
								_tmp90_ = nsuri;
								_tmp91_ = nsp;
								gxml_node_set_namespace (_tmp89_, _tmp90_, _tmp91_);
							}
							_g_free0 (nsp);
						} else {
							gchar* attrname = NULL;
							xmlTextReader* _tmp92_ = NULL;
							const gchar* _tmp93_ = NULL;
							gchar* _tmp94_ = NULL;
							xmlTextReader* _tmp95_ = NULL;
							gchar* _tmp96_ = NULL;
							xmlTextReader* _tmp97_ = NULL;
							xmlTextReader* _tmp98_ = NULL;
							gint _tmp99_ = 0;
							_tmp92_ = tr;
							_tmp93_ = (const gchar*) xmlTextReaderConstLocalName (_tmp92_);
							_tmp94_ = g_strdup (_tmp93_);
							attrname = _tmp94_;
							_tmp95_ = tr;
							_tmp96_ = (gchar*) xmlTextReaderPrefix (_tmp95_);
							_g_free0 (prefix);
							prefix = _tmp96_;
							_tmp97_ = tr;
							xmlTextReaderReadAttributeValue (_tmp97_);
							_tmp98_ = tr;
							_tmp99_ = xmlTextReaderNodeType (_tmp98_);
							if (_tmp99_ == ((gint) XML_READER_TYPE_TEXT)) {
								gchar* attrval = NULL;
								xmlTextReader* _tmp100_ = NULL;
								gchar* _tmp101_ = NULL;
								const gchar* _tmp102_ = NULL;
								_tmp100_ = tr;
								_tmp101_ = (gchar*) xmlTextReaderReadString (_tmp100_);
								attrval = _tmp101_;
								_tmp102_ = prefix;
								if (_tmp102_ != NULL) {
									xmlTextReader* _tmp103_ = NULL;
									const gchar* _tmp104_ = NULL;
									gchar* _tmp105_ = NULL;
									const gchar* _tmp106_ = NULL;
									_tmp103_ = tr;
									_tmp104_ = prefix;
									_tmp105_ = (gchar*) xmlTextReaderLookupNamespace (_tmp103_, (xmlChar*) _tmp104_);
									_g_free0 (nsuri);
									nsuri = _tmp105_;
									_tmp106_ = nsuri;
									if (_tmp106_ != NULL) {
										GXmlNode* _tmp107_ = NULL;
										const gchar* _tmp108_ = NULL;
										gchar* _tmp109_ = NULL;
										gchar* _tmp110_ = NULL;
										const gchar* _tmp111_ = NULL;
										gchar* _tmp112_ = NULL;
										gchar* _tmp113_ = NULL;
										const gchar* _tmp114_ = NULL;
										const gchar* _tmp115_ = NULL;
										_tmp107_ = n;
										_tmp108_ = prefix;
										_tmp109_ = g_strconcat (_tmp108_, ":", NULL);
										_tmp110_ = _tmp109_;
										_tmp111_ = nsuri;
										_tmp112_ = g_strconcat (_tmp110_, _tmp111_, NULL);
										_tmp113_ = _tmp112_;
										_tmp114_ = attrname;
										_tmp115_ = attrval;
										gxml_element_set_ns_attr (G_TYPE_CHECK_INSTANCE_TYPE (_tmp107_, GXML_TYPE_ELEMENT) ? ((GXmlElement*) _tmp107_) : NULL, _tmp113_, _tmp114_, _tmp115_);
										_g_free0 (_tmp113_);
										_g_free0 (_tmp110_);
									}
								} else {
									GXmlNode* _tmp116_ = NULL;
									const gchar* _tmp117_ = NULL;
									const gchar* _tmp118_ = NULL;
									_tmp116_ = n;
									_tmp117_ = attrname;
									_tmp118_ = attrval;
									gxml_element_set_attr (G_TYPE_CHECK_INSTANCE_TYPE (_tmp116_, GXML_TYPE_ELEMENT) ? ((GXmlElement*) _tmp116_) : NULL, _tmp117_, _tmp118_);
								}
								_g_free0 (attrval);
							}
							_g_free0 (attrname);
						}
					}
				}
			}
			_tmp119_ = isempty;
			if (_tmp119_) {
				result = GXML_TDOCUMENT_READ_TYPE_CONTINUE;
				_g_object_unref0 (_tmp18_);
				_g_free0 (nsuri);
				_g_free0 (prefix);
				_g_object_unref0 (n);
				return result;
			}
			while (TRUE) {
				GXmlTDocumentReadType _tmp120_ = 0;
				GXmlNode* _tmp121_ = NULL;
				xmlTextReader* _tmp122_ = NULL;
				GXmlTDocumentReadTypeFunc _tmp123_ = NULL;
				void* _tmp123__target = NULL;
				GXmlTDocumentReadType _tmp124_ = 0;
				_tmp121_ = n;
				_tmp122_ = tr;
				_tmp123_ = rntfunc;
				_tmp123__target = rntfunc_target;
				_tmp124_ = gxml_tdocument_read_node (_tmp121_, _tmp122_, _tmp123_, _tmp123__target, &_inner_error_);
				_tmp120_ = _tmp124_;
				if (G_UNLIKELY (_inner_error_ != NULL)) {
					g_propagate_error (error, _inner_error_);
					_g_object_unref0 (_tmp18_);
					_g_free0 (nsuri);
					_g_free0 (prefix);
					_g_object_unref0 (n);
					return 0;
				}
				if (!(_tmp120_ == GXML_TDOCUMENT_READ_TYPE_CONTINUE)) {
					break;
				}
			}
			_g_object_unref0 (_tmp18_);
			break;
		}
		case XML_READER_TYPE_ATTRIBUTE:
		{
			break;
		}
		case XML_READER_TYPE_TEXT:
		{
			gchar* txtval = NULL;
			xmlTextReader* _tmp125_ = NULL;
			gchar* _tmp126_ = NULL;
			GXmlNode* _tmp127_ = NULL;
			GXmlDocument* _tmp128_ = NULL;
			GXmlDocument* _tmp129_ = NULL;
			const gchar* _tmp130_ = NULL;
			GXmlNode* _tmp131_ = NULL;
			GXmlNode* _tmp132_ = NULL;
			GeeBidirList* _tmp133_ = NULL;
			GeeBidirList* _tmp134_ = NULL;
			GeeBidirList* _tmp135_ = NULL;
			GXmlNode* _tmp136_ = NULL;
			_tmp125_ = tr;
			_tmp126_ = (gchar*) xmlTextReaderReadString (_tmp125_);
			txtval = _tmp126_;
			_tmp127_ = node;
			_tmp128_ = gxml_node_get_document (_tmp127_);
			_tmp129_ = _tmp128_;
			_tmp130_ = txtval;
			_tmp131_ = gxml_document_create_text (_tmp129_, _tmp130_);
			_g_object_unref0 (n);
			n = _tmp131_;
			_tmp132_ = node;
			_tmp133_ = gxml_node_get_children_nodes (_tmp132_);
			_tmp134_ = _tmp133_;
			_tmp135_ = _tmp134_;
			_tmp136_ = n;
			gee_collection_add ((GeeCollection*) _tmp135_, _tmp136_);
			_g_object_unref0 (_tmp135_);
			_g_free0 (txtval);
			break;
		}
		case XML_READER_TYPE_CDATA:
		{
			gchar* cdval = NULL;
			xmlTextReader* _tmp137_ = NULL;
			gchar* _tmp138_ = NULL;
			GXmlNode* _tmp139_ = NULL;
			GXmlDocument* _tmp140_ = NULL;
			GXmlDocument* _tmp141_ = NULL;
			const gchar* _tmp142_ = NULL;
			GXmlNode* _tmp143_ = NULL;
			GXmlNode* _tmp144_ = NULL;
			GeeBidirList* _tmp145_ = NULL;
			GeeBidirList* _tmp146_ = NULL;
			GeeBidirList* _tmp147_ = NULL;
			GXmlNode* _tmp148_ = NULL;
			_tmp137_ = tr;
			_tmp138_ = (gchar*) xmlTextReaderValue (_tmp137_);
			cdval = _tmp138_;
			_tmp139_ = node;
			_tmp140_ = gxml_node_get_document (_tmp139_);
			_tmp141_ = _tmp140_;
			_tmp142_ = cdval;
			_tmp143_ = gxml_document_create_cdata (_tmp141_, _tmp142_);
			_g_object_unref0 (n);
			n = _tmp143_;
			_tmp144_ = node;
			_tmp145_ = gxml_node_get_children_nodes (_tmp144_);
			_tmp146_ = _tmp145_;
			_tmp147_ = _tmp146_;
			_tmp148_ = n;
			gee_collection_add ((GeeCollection*) _tmp147_, _tmp148_);
			_g_object_unref0 (_tmp147_);
			_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;
			xmlTextReader* _tmp149_ = NULL;
			const gchar* _tmp150_ = NULL;
			gchar* _tmp151_ = NULL;
			gchar* pival = NULL;
			xmlTextReader* _tmp152_ = NULL;
			gchar* _tmp153_ = NULL;
			GXmlNode* _tmp154_ = NULL;
			GXmlDocument* _tmp155_ = NULL;
			GXmlDocument* _tmp156_ = NULL;
			const gchar* _tmp157_ = NULL;
			const gchar* _tmp158_ = NULL;
			GXmlNode* _tmp159_ = NULL;
			GXmlNode* _tmp160_ = NULL;
			GeeBidirList* _tmp161_ = NULL;
			GeeBidirList* _tmp162_ = NULL;
			GeeBidirList* _tmp163_ = NULL;
			GXmlNode* _tmp164_ = NULL;
			_tmp149_ = tr;
			_tmp150_ = (const gchar*) xmlTextReaderConstLocalName (_tmp149_);
			_tmp151_ = g_strdup (_tmp150_);
			pit = _tmp151_;
			_tmp152_ = tr;
			_tmp153_ = (gchar*) xmlTextReaderValue (_tmp152_);
			pival = _tmp153_;
			_tmp154_ = node;
			_tmp155_ = gxml_node_get_document (_tmp154_);
			_tmp156_ = _tmp155_;
			_tmp157_ = pit;
			_tmp158_ = pival;
			_tmp159_ = gxml_document_create_pi (_tmp156_, _tmp157_, _tmp158_);
			_g_object_unref0 (n);
			n = _tmp159_;
			_tmp160_ = node;
			_tmp161_ = gxml_node_get_children_nodes (_tmp160_);
			_tmp162_ = _tmp161_;
			_tmp163_ = _tmp162_;
			_tmp164_ = n;
			gee_collection_add ((GeeCollection*) _tmp163_, _tmp164_);
			_g_object_unref0 (_tmp163_);
			_g_free0 (pival);
			_g_free0 (pit);
			break;
		}
		case XML_READER_TYPE_COMMENT:
		{
			gchar* commval = NULL;
			xmlTextReader* _tmp165_ = NULL;
			gchar* _tmp166_ = NULL;
			GXmlNode* _tmp167_ = NULL;
			GXmlDocument* _tmp168_ = NULL;
			GXmlDocument* _tmp169_ = NULL;
			const gchar* _tmp170_ = NULL;
			GXmlNode* _tmp171_ = NULL;
			GXmlNode* _tmp172_ = NULL;
			GeeBidirList* _tmp173_ = NULL;
			GeeBidirList* _tmp174_ = NULL;
			GeeBidirList* _tmp175_ = NULL;
			GXmlNode* _tmp176_ = NULL;
			_tmp165_ = tr;
			_tmp166_ = (gchar*) xmlTextReaderValue (_tmp165_);
			commval = _tmp166_;
			_tmp167_ = node;
			_tmp168_ = gxml_node_get_document (_tmp167_);
			_tmp169_ = _tmp168_;
			_tmp170_ = commval;
			_tmp171_ = gxml_document_create_comment (_tmp169_, _tmp170_);
			_g_object_unref0 (n);
			n = _tmp171_;
			_tmp172_ = node;
			_tmp173_ = gxml_node_get_children_nodes (_tmp172_);
			_tmp174_ = _tmp173_;
			_tmp175_ = _tmp174_;
			_tmp176_ = n;
			gee_collection_add ((GeeCollection*) _tmp175_, _tmp176_);
			_g_object_unref0 (_tmp175_);
			_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_ = NULL;
	GeeArrayList* _tmp2_ = NULL;
	GObject* _tmp3_ = NULL;
	GeeList* _tmp4_ = NULL;
	self = (GXmlTDocument*) base;
	_tmp0_ = self->_namespaces;
	if (_tmp0_ == NULL) {
		GeeArrayList* _tmp1_ = NULL;
		_tmp1_ = gee_array_list_new (GXML_TYPE_NODE, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, NULL, NULL, NULL);
		_g_object_unref0 (self->_namespaces);
		self->_namespaces = _tmp1_;
	}
	_tmp2_ = self->_namespaces;
	_tmp3_ = g_object_ref ((GObject*) _tmp2_);
	_tmp4_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (_tmp3_, GEE_TYPE_LIST) ? ((GeeList*) _tmp3_) : NULL);
	result = _tmp4_;
	return result;
}


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


static void gxml_tdocument_real_set_indent (GXmlDocument* base, gboolean value) {
	GXmlTDocument* self;
	gboolean _tmp0_ = FALSE;
	self = (GXmlTDocument*) base;
	_tmp0_ = value;
	self->priv->_indent = _tmp0_;
	g_object_notify ((GObject *) self, "indent");
}


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


static void gxml_tdocument_real_set_ns_top (GXmlDocument* base, gboolean value) {
	GXmlTDocument* self;
	gboolean _tmp0_ = FALSE;
	self = (GXmlTDocument*) base;
	_tmp0_ = value;
	self->priv->_ns_top = _tmp0_;
	g_object_notify ((GObject *) self, "ns-top");
}


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


static void gxml_tdocument_real_set_prefix_default_ns (GXmlDocument* base, gboolean value) {
	GXmlTDocument* self;
	gboolean _tmp0_ = FALSE;
	self = (GXmlTDocument*) base;
	_tmp0_ = value;
	self->priv->_prefix_default_ns = _tmp0_;
	g_object_notify ((GObject *) self, "prefix-default-ns");
}


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


static void gxml_tdocument_real_set_backup (GXmlDocument* base, gboolean value) {
	GXmlTDocument* self;
	gboolean _tmp0_ = FALSE;
	self = (GXmlTDocument*) base;
	_tmp0_ = value;
	self->priv->_backup = _tmp0_;
	g_object_notify ((GObject *) self, "backup");
}


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


static void gxml_tdocument_real_set_file (GXmlDocument* base, GFile* value) {
	GXmlTDocument* self;
	GFile* _tmp0_ = NULL;
	GFile* _tmp1_ = NULL;
	self = (GXmlTDocument*) base;
	_tmp0_ = value;
	_tmp1_ = _g_object_ref0 (_tmp0_);
	_g_object_unref0 (self->priv->_file);
	self->priv->_file = _tmp1_;
	g_object_notify ((GObject *) self, "file");
}


static GXmlNode* gxml_tdocument_real_get_root (GXmlDocument* base) {
	GXmlNode* result;
	GXmlTDocument* self;
	GeeArrayList* _tmp0_ = NULL;
	GXmlElement* _tmp2_ = NULL;
	GXmlElement* _tmp23_ = NULL;
	GXmlNode* _tmp24_ = NULL;
	self = (GXmlTDocument*) base;
	_tmp0_ = self->_children;
	if (_tmp0_ == NULL) {
		GeeArrayList* _tmp1_ = NULL;
		_tmp1_ = gee_array_list_new (GXML_TYPE_NODE, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, NULL, NULL, NULL);
		_g_object_unref0 (self->_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) {
					gint _tmp5_ = 0;
					GeeBidirList* _tmp6_ = NULL;
					GeeBidirList* _tmp7_ = NULL;
					GeeBidirList* _tmp8_ = NULL;
					gint _tmp9_ = 0;
					gint _tmp10_ = 0;
					gboolean _tmp11_ = FALSE;
					GXmlNode* n = NULL;
					GeeBidirList* _tmp12_ = NULL;
					GeeBidirList* _tmp13_ = NULL;
					GeeBidirList* _tmp14_ = NULL;
					gint _tmp15_ = 0;
					gpointer _tmp16_ = NULL;
					GXmlNode* _tmp17_ = NULL;
					GXmlNode* _tmp18_ = NULL;
					if (!_tmp3_) {
						gint _tmp4_ = 0;
						_tmp4_ = i;
						i = _tmp4_ + 1;
					}
					_tmp3_ = FALSE;
					_tmp5_ = i;
					_tmp6_ = gxml_tnode_get_children_nodes ((GXmlTNode*) self);
					_tmp7_ = _tmp6_;
					_tmp8_ = _tmp7_;
					_tmp9_ = gee_collection_get_size ((GeeCollection*) _tmp8_);
					_tmp10_ = _tmp9_;
					_tmp11_ = !(_tmp5_ < _tmp10_);
					_g_object_unref0 (_tmp8_);
					if (_tmp11_) {
						break;
					}
					_tmp12_ = gxml_tnode_get_children_nodes ((GXmlTNode*) self);
					_tmp13_ = _tmp12_;
					_tmp14_ = _tmp13_;
					_tmp15_ = i;
					_tmp16_ = gee_list_get ((GeeList*) _tmp14_, _tmp15_);
					_tmp17_ = (GXmlNode*) _tmp16_;
					_g_object_unref0 (_tmp14_);
					n = _tmp17_;
					_tmp18_ = n;
					if (G_TYPE_CHECK_INSTANCE_TYPE (_tmp18_, GXML_TYPE_ELEMENT)) {
						gint _tmp19_ = 0;
						gint _tmp20_ = 0;
						_tmp19_ = found;
						found = _tmp19_ + 1;
						_tmp20_ = found;
						if (_tmp20_ == 1) {
							GXmlNode* _tmp21_ = NULL;
							GXmlElement* _tmp22_ = NULL;
							_tmp21_ = n;
							_tmp22_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp21_, GXML_TYPE_ELEMENT, GXmlElement));
							_g_object_unref0 (self->priv->_root);
							self->priv->_root = _tmp22_;
						}
					}
					_g_object_unref0 (n);
				}
			}
		}
	}
	_tmp23_ = self->priv->_root;
	_tmp24_ = _g_object_ref0 ((GXmlNode*) _tmp23_);
	result = _tmp24_;
	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_ = NULL;
	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) {
	gxml_tdocument_parent_class = g_type_class_peek_parent (klass);
	g_type_class_add_private (klass, sizeof (GXmlTDocumentPrivate));
	((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, g_param_spec_object ("namespaces", "namespaces", "namespaces", GEE_TYPE_LIST, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GXML_TDOCUMENT_CHILDREN_NODES, g_param_spec_object ("children-nodes", "children-nodes", "children-nodes", GEE_TYPE_BIDIR_LIST, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GXML_TDOCUMENT_DOCUMENT, g_param_spec_object ("document", "document", "document", GXML_TYPE_DOCUMENT, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GXML_TDOCUMENT_INDENT, g_param_spec_boolean ("indent", "indent", "indent", FALSE, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GXML_TDOCUMENT_NS_TOP, g_param_spec_boolean ("ns-top", "ns-top", "ns-top", FALSE, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GXML_TDOCUMENT_PREFIX_DEFAULT_NS, g_param_spec_boolean ("prefix-default-ns", "prefix-default-ns", "prefix-default-ns", FALSE, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GXML_TDOCUMENT_BACKUP, g_param_spec_boolean ("backup", "backup", "backup", TRUE, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GXML_TDOCUMENT_FILE, g_param_spec_object ("file", "file", "file", g_file_get_type (), G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GXML_TDOCUMENT_ROOT, g_param_spec_object ("root", "root", "root", GXML_TYPE_NODE, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE));
}


static void gxml_tdocument_gxml_document_interface_init (GXmlDocumentIface * iface) {
	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) {
	self->priv = GXML_TDOCUMENT_GET_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);
}


/**
 * 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);
		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:
		g_value_take_object (value, gxml_tnode_get_namespaces ((GXmlTNode*) self));
		break;
		case GXML_TDOCUMENT_CHILDREN_NODES:
		g_value_take_object (value, gxml_tnode_get_children_nodes ((GXmlTNode*) self));
		break;
		case GXML_TDOCUMENT_DOCUMENT:
		g_value_set_object (value, gxml_tnode_get_document ((GXmlTNode*) self));
		break;
		case GXML_TDOCUMENT_INDENT:
		g_value_set_boolean (value, gxml_document_get_indent ((GXmlDocument*) self));
		break;
		case GXML_TDOCUMENT_NS_TOP:
		g_value_set_boolean (value, gxml_document_get_ns_top ((GXmlDocument*) self));
		break;
		case GXML_TDOCUMENT_PREFIX_DEFAULT_NS:
		g_value_set_boolean (value, gxml_document_get_prefix_default_ns ((GXmlDocument*) self));
		break;
		case GXML_TDOCUMENT_BACKUP:
		g_value_set_boolean (value, gxml_document_get_backup ((GXmlDocument*) self));
		break;
		case GXML_TDOCUMENT_FILE:
		g_value_set_object (value, gxml_document_get_file ((GXmlDocument*) self));
		break;
		case GXML_TDOCUMENT_ROOT:
		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:
		gxml_document_set_indent ((GXmlDocument*) self, g_value_get_boolean (value));
		break;
		case GXML_TDOCUMENT_NS_TOP:
		gxml_document_set_ns_top ((GXmlDocument*) self, g_value_get_boolean (value));
		break;
		case GXML_TDOCUMENT_PREFIX_DEFAULT_NS:
		gxml_document_set_prefix_default_ns ((GXmlDocument*) self, g_value_get_boolean (value));
		break;
		case GXML_TDOCUMENT_BACKUP:
		gxml_document_set_backup ((GXmlDocument*) self, g_value_get_boolean (value));
		break;
		case GXML_TDOCUMENT_FILE:
		gxml_document_set_file ((GXmlDocument*) self, g_value_get_object (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}



