Commit 740abf5a authored by Daniel Veillard's avatar Daniel Veillard
Browse files

Big XPath cleanup continues, one URI fix:

- xpath.[ch] debugXML.c testXPath.c: fixed the XPath evaluation
  engine, should be far more stable, incorporated a new version of
  preceding/following axis, need testing
- uri.c: fixed file:///c:/a/b/c problem
- test/XPath/tests/idsimple: augmented the XPath tests
Daniel
parent 3bff2b0e
Mon Oct 2 23:47:32 CEST 2000 Daniel Veillard <Daniel.Veillard@w3.org>
* xpath.[ch] debugXML.c testXPath.c: fixed the XPath evaluation
engine, should be far more stable, incorporated a new version of
preceding/following axis, need testing
* uri.c: fixed file:///c:/a/b/c problem
* test/XPath/tests/idsimple: augmented the XPath tests
Sun Oct 1 22:33:00 CEST 2000 Daniel Veillard <Daniel.Veillard@w3.org>
* doc/* rebuilding docs for 2.2.4 release
......
......@@ -1649,9 +1649,7 @@ xmlShell(xmlDocPtr doc, char *filename, xmlShellReadlineFunc input,
} else {
ctxt->pctxt->node = ctxt->node;
#ifdef LIBXML_XPATH_ENABLED
if (ctxt->pctxt->nodelist != NULL)
xmlXPathFreeNodeSet(ctxt->pctxt->nodelist);
ctxt->pctxt->nodelist = xmlXPathNodeSetCreate(ctxt->node);
ctxt->pctxt->node = ctxt->node;
list = xmlXPathEval((xmlChar *) arg, ctxt->pctxt);
#else
list = NULL;
......@@ -1688,21 +1686,14 @@ xmlShell(xmlDocPtr doc, char *filename, xmlShellReadlineFunc input,
} else {
fprintf(stderr, "%s: no such node\n", arg);
}
#ifdef LIBXML_XPATH_ENABLED
if (ctxt->pctxt->nodelist != NULL)
xmlXPathFreeNodeSet(ctxt->pctxt->nodelist);
#endif /* LIBXML_XPATH_ENABLED */
ctxt->pctxt->nodelist = NULL;
ctxt->pctxt->node = NULL;
}
} else if (!strcmp(command, "cd")) {
if (arg[0] == 0) {
ctxt->node = (xmlNodePtr) ctxt->doc;
} else {
ctxt->pctxt->node = ctxt->node;
#ifdef LIBXML_XPATH_ENABLED
if (ctxt->pctxt->nodelist != NULL)
xmlXPathFreeNodeSet(ctxt->pctxt->nodelist);
ctxt->pctxt->nodelist = xmlXPathNodeSetCreate(ctxt->node);
ctxt->pctxt->node = ctxt->node;
list = xmlXPathEval((xmlChar *) arg, ctxt->pctxt);
#else
list = NULL;
......@@ -1733,11 +1724,7 @@ xmlShell(xmlDocPtr doc, char *filename, xmlShellReadlineFunc input,
} else {
fprintf(stderr, "%s: no such node\n", arg);
}
#ifdef LIBXML_XPATH_ENABLED
if (ctxt->pctxt->nodelist != NULL)
xmlXPathFreeNodeSet(ctxt->pctxt->nodelist);
#endif /* LIBXML_XPATH_ENABLED */
ctxt->pctxt->nodelist = NULL;
ctxt->pctxt->node = NULL;
}
} else if (!strcmp(command, "cat")) {
if (arg[0] == 0) {
......@@ -1745,9 +1732,7 @@ xmlShell(xmlDocPtr doc, char *filename, xmlShellReadlineFunc input,
} else {
ctxt->pctxt->node = ctxt->node;
#ifdef LIBXML_XPATH_ENABLED
if (ctxt->pctxt->nodelist != NULL)
xmlXPathFreeNodeSet(ctxt->pctxt->nodelist);
ctxt->pctxt->nodelist = xmlXPathNodeSetCreate(ctxt->node);
ctxt->pctxt->node = ctxt->node;
list = xmlXPathEval((xmlChar *) arg, ctxt->pctxt);
#else
list = NULL;
......@@ -1781,11 +1766,7 @@ xmlShell(xmlDocPtr doc, char *filename, xmlShellReadlineFunc input,
} else {
fprintf(stderr, "%s: no such node\n", arg);
}
#ifdef LIBXML_XPATH_ENABLED
if (ctxt->pctxt->nodelist != NULL)
xmlXPathFreeNodeSet(ctxt->pctxt->nodelist);
#endif /* LIBXML_XPATH_ENABLED */
ctxt->pctxt->nodelist = NULL;
ctxt->pctxt->node = NULL;
}
} else {
fprintf(stderr, "Unknown command %s\n", command);
......
......@@ -143,7 +143,6 @@ struct _xmlXPathAxis {
struct _xmlXPathContext {
xmlDocPtr doc; /* The current document */
xmlNodePtr node; /* The current node */
xmlNodeSetPtr nodelist; /* The current node list */
int nb_variables; /* number of defined variables */
int max_variables; /* max number of variables */
......
Object is a Node Set :
Set contains 1 nodes:
1 ELEMENT EXAMPLE
ATTRIBUTE id
TEXT
content=root
ATTRIBUTE prop1
TEXT
content=gnome is great
ATTRIBUTE prop2
TEXT
content=& linux too
Object is a Node Set :
Set contains 1 nodes:
1 ELEMENT chapter
ATTRIBUTE id
TEXT
content=chapter2
Object is a Node Set :
Set contains 1 nodes:
1 ELEMENT chapter
ATTRIBUTE id
TEXT
content=chapter5
//*[@id="root"]
//*[@id="chapter2"]
//*[@id="chapter5"]
......@@ -40,8 +40,10 @@
#include <libxml/parser.h>
#include <libxml/debugXML.h>
#include <libxml/xmlmemory.h>
#include <libxml/parserInternals.h>
static int debug = 0;
static int valid = 0;
static int expr = 0;
static xmlDocPtr document = NULL;
......@@ -171,6 +173,8 @@ int main(int argc, char **argv) {
for (i = 1; i < argc ; i++) {
if ((!strcmp(argv[i], "-debug")) || (!strcmp(argv[i], "--debug")))
debug++;
if ((!strcmp(argv[i], "-valid")) || (!strcmp(argv[i], "--valid")))
valid++;
if ((!strcmp(argv[i], "-expr")) || (!strcmp(argv[i], "--expr")))
expr++;
if ((!strcmp(argv[i], "-i")) || (!strcmp(argv[i], "--input")))
......@@ -178,6 +182,7 @@ int main(int argc, char **argv) {
if ((!strcmp(argv[i], "-f")) || (!strcmp(argv[i], "--file")))
usefile++;
}
if (valid != 0) xmlDoValidityCheckingDefaultValue = 1;
if (document == NULL) {
if (filename == NULL)
document = xmlParseDoc(buffer);
......@@ -201,6 +206,7 @@ int main(int argc, char **argv) {
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");
printf("\t--expr : debug XPath expressions only\n");
printf("\t--input filename : or\n");
printf("\t-i filename : read the document from filename\n");
......
......@@ -373,6 +373,17 @@ xmlSaveUri(xmlURIPtr uri) {
ret[len++] = lo + (lo > 9? 'A'-10 : '0');
}
}
} else if (uri->scheme != NULL) {
if (len + 3 >= max) {
max *= 2;
ret = (xmlChar *) xmlRealloc(ret, (max + 1) * sizeof(xmlChar));
if (ret == NULL) {
fprintf(stderr, "xmlSaveUri: out of memory\n");
return(NULL);
}
}
ret[len++] = '/';
ret[len++] = '/';
}
if (uri->path != NULL) {
p = uri->path;
......@@ -766,12 +777,25 @@ xmlParseURIServer(xmlURIPtr uri, const char **str) {
}
cur = *str;
}
/*
* This can be empty in the case where there is no server
*/
host = cur;
if (*cur == '/') {
if (uri != NULL) {
if (uri->authority != NULL) xmlFree(uri->authority);
uri->authority = NULL;
if (uri->server != NULL) xmlFree(uri->server);
uri->server = NULL;
uri->port = 0;
}
return(0);
}
/*
* host part of hostport can derive either an IPV4 address
* or an unresolved name. Check the IP first, it easier to detect
* errors if wrong one
*/
host = cur;
if (IS_DIGIT(*cur)) {
while(IS_DIGIT(*cur)) cur++;
if (*cur != '.')
......
This diff is collapsed.
......@@ -143,7 +143,6 @@ struct _xmlXPathAxis {
struct _xmlXPathContext {
xmlDocPtr doc; /* The current document */
xmlNodePtr node; /* The current node */
xmlNodeSetPtr nodelist; /* The current node list */
int nb_variables; /* number of defined variables */
int max_variables; /* max number of variables */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment