/*
* testXPath.c : a small tester program for XPath.
*
* See Copyright for the status of this software.
*
* daniel@veillard.com
*/
#include "libxml.h"
#if defined(LIBXML_XPATH_ENABLED) && defined(LIBXML_DEBUG_ENABLED)
#include <string.h>
#ifdef HAVE_SYS_TYPES_H
#endif
#ifdef HAVE_SYS_STAT_H
#endif
#ifdef HAVE_FCNTL_H
#include <fcntl.h>
#endif
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
#endif
#include <libxml/debugXML.h>
#include <libxml/xmlmemory.h>
#include <libxml/parserInternals.h>
#include <libxml/xpathInternals.h>
#include <libxml/xmlerror.h>
#if defined(LIBXML_XPTR_ENABLED)
#include <libxml/xpointer.h>
static int xptr = 0;
#endif
static int debug = 0;
static int valid = 0;
static int expr = 0;
static int tree = 0;
static int nocdata = 0;
/*
* Default document
*/
"<?xml version=\"1.0\"?>\n\
<EXAMPLE prop1=\"gnome is great\" prop2=\"& linux too\">\n\
<head>\n\
<title>Welcome to Gnome</title>\n\
</head>\n\
<chapter>\n\
<title>The Linux adventure</title>\n\
<p>bla bla bla ...</p>\n\
<image href=\"linus.gif\"/>\n\
<p>...</p>\n\
</chapter>\n\
<chapter>\n\
<title>Chapter 2</title>\n\
<p>this is chapter 2 ...</p>\n\
</chapter>\n\
<chapter>\n\
<title>Chapter 3</title>\n\
<p>this is chapter 3 ...</p>\n\
</chapter>\n\
</EXAMPLE>\n\
";
static void
#if defined(LIBXML_XPTR_ENABLED)
if (xptr) {
} else {
#endif
if (expr)
else {
/* res = xmlXPathEval(BAD_CAST str, ctxt); */
if (tree)
} else
}
#if defined(LIBXML_XPTR_ENABLED)
}
#endif
}
static void
int len;
"Cannot open %s for reading\n", filename);
return;
}
len--;
while ((len >= 0) &&
if (len >= 0) {
}
}
}
int i;
int strings = 0;
int usefile = 0;
for (i = 1; i < argc ; i++) {
#if defined(LIBXML_XPTR_ENABLED)
xptr++;
else
#endif
debug++;
valid++;
expr++;
tree++;
nocdata++;
usefile++;
}
if (nocdata != 0) {
}
else
}
for (i = 1; i < argc ; i++) {
i++; continue;
}
if (argv[i][0] != '-') {
if (usefile)
testXPathFile(argv[i]);
else
strings ++;
}
}
if (strings == 0) {
printf("Usage : %s [--debug] [--copy] stringsorfiles ...\n",
argv[0]);
printf("\tParse the XPath strings and output the result of the parsing\n");
printf("\t--debug : dump a debug version of the result\n");
printf("\t--valid : switch on DTD support in the parser\n");
#if defined(LIBXML_XPTR_ENABLED)
printf("\t--xptr : expressions are XPointer expressions\n");
#endif
printf("\t--expr : debug XPath expressions only\n");
printf("\t--tree : show the compiled XPath tree\n");
printf("\t--nocdata : do not generate CDATA nodes\n");
printf("\t--input filename : or\n");
printf("\t-i filename : read the document from filename\n");
printf("\t--file : or\n");
printf("\t-f : read queries from files, args\n");
}
return(0);
}
#else
#include <stdio.h>
return(0);
}
#endif /* LIBXML_XPATH_ENABLED */