#ifndef DONE_XML
#define DONE_XML 1


#include "dstr.h"

typedef struct XML {
	char *name;
	char *ns; // namexx space, e.g. dav: or http://x/y.z 
	char *ns_prefix; // keep prefix when storing multivalue properties
	Pair *attribs;
	struct XML *next;
	struct XML *next_last;
	struct XML *child; 
	struct XML *child_last;
	struct XML *parent; 
	char *text; // a fudge but should work. it's a fudge because the text may not be in one block at all...
	int status; // Temporary state flags for use during processing
} Xml;
Xml *xml_read_buffer(char *in, char *file, int line);
int xml_read_token(char **pin, char *bf);
int xml_read_node(Xml *cur, char **pin, int *end_found, char *file, int line);
Xml *xml_find_attrib(Xml *top, char *thing, char *param) ;
char *xml_get(Xml *top, char *thing) ;
int xml_print(Xml *top, int depth, Pair *xlate);
int xml_free(Xml *top);

Xml *xml_find(Xml *top, char *thing, char *ns) ;
Xml *xml_new(Xml *parent, char *file, int line);
char *xml_top_name(Xml *top, char *tmp);
int xml_exists(Xml *top, char *thing, char *ns) ;

Dstr *xml_to_text(Xml *p, int depth, Pair *xlate_inherit);
void xml_text_free(Dstr **s);
int xml_tobf(Xml *top, char *bf, int bfsz);
Xml *xml_find_child(Xml *top, char *thing, char *ns) ;
Dstr *xml_to_text_naked(Xml *top, int depth, Pair *xlate_inherit);
#define xml_read_file(a) xml_read_file_real(a,__FILE__,__LINE__) 
Xml *xml_read_file_real(char *fname, char *file, int line);
/*

<a b=c d=f>bla blaybla bla
<xxx/>
</a>

*/

#endif


