int
main (int argc, char** argv)
{
xml_g_set_prgname(argv[0]);
if (argc < 3)
{
g_printerr ("> %s filename xpath [options]\n"
"\t print all absolute xpaths for the given xpath\n"
"\t specification - an abbreviated regex form of it\n"
"\t can match a number of nodes. The xpaths of those\n"
"\t nodes are printed. You can use some other tools\n"
"\t to print the content of these nodes by handing over\n"
"\t the absolut xpaths this program prints to stdout.\n"
"\t style-options: -strict | -canon | -match\n",
g_get_prgname());
return 1;
} |
___ gchar *filename = 0;
const gchar *xpath = 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; } |
g_warning ("extra argument on commandline, ignored: %s", argv[i]);
} | } |
___ 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;
___ xml_GList* list = xml_path_pcre_list (tree, xpath);
if (! list && strstr(styleflag, "-note")) g_printerr ("# nothing!\n");
for (; list ; list = xml_g_list_free_head (list))
{
gchar* xpath = xml_path_strdup (tree, list->data.node, style);
if (xpath)
{
g_print (xpath);
g_free (xpath);
} |
if (strstr(styleflag, "-space") && list->next) g_print (" ");
else g_print ("\n");
} |
return 0;
____;____;____;____;
} |
|