#include "config.h"

#include "xml/from-txt.h"
#include "xml/pathnode.h"
#include "xml/listnode.h"
#include "xml/dumpnode.h"
#include "xml/dumptree.h"
#include "xml/addspcre.h"
#include "xml/from-xmf.h"
#include "xml/gerror.h"
#include <stdlib.h>
#include <string.h>

#define ___ {
#define ____ }

int
main (int argc, char** argv)
{
    xml_g_set_prgname(argv[0]); 

    if (argc < 4)
    
{
	g_printerr ("> %s filename xpath regex [markup]... [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. On each substring the\n"
		    "\t given perl-regex will be run and any result area\n"
		    "\t will be marked with that markup. The markup series \n"
		    "\t is interpreted as in perl - the first is $0 that \n"
		    "\t matches on the complete regex and subsequent markups\n"
		    "\t are $1..$9 that match paren-enclosed sub-matches.\n"
		    "\t the default markup is $0 = Q and no markup else.\n"
		    "\t example: if there is a text 'uku' in the textarray\n"
		    "\t matched by the xpath-expression and you give the\n"
		    "\t further args 'u(k)u' Q V then the resulting xml\n"
		    "\t looks like '<Q>u<V>k</V>u</Q>'.\n",
		    g_get_prgname());
	return 1;
    }
___ gchar *filename = 0; const gchar *xpath = 0, *regex = 0, *styleflag = ""; const gchar * markup[10] =
{0}
;
{   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 (! regex)
{ regex = argv[i]; continue; }
if (! markup[0])
{ markup[0] = argv[i]; continue; }
if (! markup[1])
{ markup[1] = argv[i]; continue; }
if (! markup[2])
{ markup[2] = argv[i]; continue; }
if (! markup[3])
{ markup[3] = argv[i]; continue; }
if (! markup[4])
{ markup[4] = argv[i]; continue; }
if (! markup[5])
{ markup[5] = argv[i]; continue; }
if (! markup[6])
{ markup[6] = argv[i]; continue; }
if (! markup[7])
{ markup[7] = argv[i]; continue; }
if (! markup[8])
{ markup[8] = argv[i]; continue; }
if (! markup[9])
{ markup[9] = argv[i]; continue; }
g_warning ("extra argument on commandline, ignored: %s", argv[i]); }
}
if (! *markup) *markup = "Q"; ___ xml_GNode* tree; GError* error = 0; tree = xml_g_parse_file (0, filename, &error); if (error) xml_g_show_error (&error, "after parsing file:\n\t'%s'", filename); ___ auto GError* error = 0; xml_path_pcre_add9 (tree, xpath, regex, markup, &error); if (error) xml_g_show_error (&error, "after adding"); /* and print the result */ xml_tree_dump_to_xml_file (tree, 0, 1|xml_tree_dump_to_xml_flags (styleflag)); return 0; ____;____;____; }
/* 
   Local variables:
   c-file-style: "stroustrup"
   End:
 */