#include "xml/from-txt.h"
#include "xml/pathnode.h"
#include "xml/listnode.h"
#include "xml/dumpnode.h"
#include "xml/attrnode.h"
#include "xml/gerror.h"
#include <string.h>

#define ___ {
#define ____ }

typedef struct
{
    const gchar* name;
    const gchar* value;
}
 Data;
void func (xml_GNode* node, gpointer data)
{
    Data* attr = data;
    xml_node_attribute_add (node, attr->name, attr->value);
}
int
main (int argc, char** argv)
{
    xml_g_set_prgname(argv[0]); 

    if (argc < 4)
    
{
	g_printerr ("> %s filename xpath attribute [value] [options]\n"
		    "\t walk the tree looking for nodes matching the xpath\n"
		    "\t specification - even in an abbreviated form it\n"
		    "\t can match a number of nodes. To each of the nodes\n"
		    "\t add an attribute. If no value is given it is assumed\n"
		    "\t to be 1.\n",
		    g_get_prgname());
	return 1;
    }
___ gchar *filename = 0; const gchar *xpath = 0, *attribute = 0, *value = 0, *styleflag = "";
{   int i ; for (i=1; i < argc ; i++) 
{
	if (argv[i][0] == '-') 
{ styleflag = argv[i]; continue; }
if (! filename)
{ filename = argv[i]; continue; }
if (! xpath)
{ xpath = argv[i]; continue; }
if (! attribute)
{ attribute = argv[i]; continue; }
if (! value)
{ value = argv[i]; continue; }
g_warning ("extra argument on commandline, ignored: %s", argv[i]); }
}
if (! value) value = "1"; ___ xml_GNode* tree; GError* error = 0; tree = xml_g_markup_parse_file (0, filename, &error); if (error) xml_g_show_error (&error, "after parsing file:\n\t'%s'", filename); ___ int style = xml_path_CANON; if (strstr (styleflag, "-match")) style = xml_path_MATCH; if (strstr (styleflag, "-strict")) style = xml_path_STRICT; if (strstr (styleflag, "-canon")) style = xml_path_CANON; ___ auto Data data =
{ attribute, value }
; xml_path_node_foreach (tree, xpath, func, &data); /* and print the result */ xml_tree_node_to_xml_file (tree, 0); return 0; ____;____;____;____; }
/* 
   Local variables:
   c-file-style: "stroustrup"
   End:
 */