mirror of
https://gitlab.gnome.org/GNOME/libxml2.git
synced 2025-07-29 11:41:22 +03:00
- testXPath.c : added a --tree option allowing to display the
tree dump of the XPath expression Daniel
This commit is contained in:
@ -1,3 +1,8 @@
|
|||||||
|
Tue Apr 3 20:20:51 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
|
||||||
|
|
||||||
|
* testXPath.c : added a --tree option allowing to display the
|
||||||
|
tree dump of the XPath expression
|
||||||
|
|
||||||
Mon Apr 2 17:13:51 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
|
Mon Apr 2 17:13:51 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
|
||||||
|
|
||||||
* xpath.c: fixed a memleak when comparing nodesets
|
* xpath.c: fixed a memleak when comparing nodesets
|
||||||
|
19
testXPath.c
19
testXPath.c
@ -50,6 +50,7 @@ static int xptr = 0;
|
|||||||
static int debug = 0;
|
static int debug = 0;
|
||||||
static int valid = 0;
|
static int valid = 0;
|
||||||
static int expr = 0;
|
static int expr = 0;
|
||||||
|
static int tree = 0;
|
||||||
static xmlDocPtr document = NULL;
|
static xmlDocPtr document = NULL;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -102,8 +103,19 @@ testXPath(const char *str) {
|
|||||||
ctxt->node = xmlDocGetRootElement(document);
|
ctxt->node = xmlDocGetRootElement(document);
|
||||||
if (expr)
|
if (expr)
|
||||||
res = xmlXPathEvalExpression(BAD_CAST str, ctxt);
|
res = xmlXPathEvalExpression(BAD_CAST str, ctxt);
|
||||||
else
|
else {
|
||||||
res = xmlXPathEval(BAD_CAST str, ctxt);
|
/* res = xmlXPathEval(BAD_CAST str, ctxt); */
|
||||||
|
xmlXPathCompExprPtr comp;
|
||||||
|
|
||||||
|
comp = xmlXPathCompile(BAD_CAST str);
|
||||||
|
if (comp != NULL) {
|
||||||
|
if (tree)
|
||||||
|
xmlXPathDebugDumpCompExpr(stdout, comp, 0);
|
||||||
|
|
||||||
|
res = xmlXPathCompiledEval(comp, ctxt);
|
||||||
|
} else
|
||||||
|
res = NULL;
|
||||||
|
}
|
||||||
#if defined(LIBXML_XPTR_ENABLED)
|
#if defined(LIBXML_XPTR_ENABLED)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -157,6 +169,8 @@ int main(int argc, char **argv) {
|
|||||||
valid++;
|
valid++;
|
||||||
if ((!strcmp(argv[i], "-expr")) || (!strcmp(argv[i], "--expr")))
|
if ((!strcmp(argv[i], "-expr")) || (!strcmp(argv[i], "--expr")))
|
||||||
expr++;
|
expr++;
|
||||||
|
if ((!strcmp(argv[i], "-tree")) || (!strcmp(argv[i], "--tree")))
|
||||||
|
tree++;
|
||||||
if ((!strcmp(argv[i], "-i")) || (!strcmp(argv[i], "--input")))
|
if ((!strcmp(argv[i], "-i")) || (!strcmp(argv[i], "--input")))
|
||||||
filename = argv[++i];
|
filename = argv[++i];
|
||||||
if ((!strcmp(argv[i], "-f")) || (!strcmp(argv[i], "--file")))
|
if ((!strcmp(argv[i], "-f")) || (!strcmp(argv[i], "--file")))
|
||||||
@ -191,6 +205,7 @@ int main(int argc, char **argv) {
|
|||||||
printf("\t--xptr : expressions are XPointer expressions\n");
|
printf("\t--xptr : expressions are XPointer expressions\n");
|
||||||
#endif
|
#endif
|
||||||
printf("\t--expr : debug XPath expressions only\n");
|
printf("\t--expr : debug XPath expressions only\n");
|
||||||
|
printf("\t--tree : show the compiled XPath tree\n");
|
||||||
printf("\t--input filename : or\n");
|
printf("\t--input filename : or\n");
|
||||||
printf("\t-i filename : read the document from filename\n");
|
printf("\t-i filename : read the document from filename\n");
|
||||||
printf("\t--file : or\n");
|
printf("\t--file : or\n");
|
||||||
|
Reference in New Issue
Block a user