version 1.21, 2000/10/05 16:36:25
|
version 1.22, 2000/10/05 22:56:03
|
Line 84 static xmlChar buffer[] =
|
Line 84 static xmlChar buffer[] =
|
</EXAMPLE>\n\ |
</EXAMPLE>\n\ |
"; |
"; |
|
|
void xmlXPAthDebugDumpNode(FILE *output, xmlNodePtr cur) { |
void xmlXPAthDebugDumpNode(FILE *output, xmlNodePtr cur, int depth) { |
|
int i; |
|
char shift[100]; |
|
|
|
for (i = 0;((i < depth) && (i < 25));i++) |
|
shift[2 * i] = shift[2 * i + 1] = ' '; |
|
shift[2 * i] = shift[2 * i + 1] = 0; |
if (cur == NULL) { |
if (cur == NULL) { |
|
fprintf(output, shift); |
fprintf(output, "Node is NULL !\n"); |
fprintf(output, "Node is NULL !\n"); |
return; |
return; |
|
|
} |
} |
|
|
if (cur == NULL) |
if ((cur->type == XML_DOCUMENT_NODE) || |
fprintf(output, " NULL\n"); |
(cur->type == XML_HTML_DOCUMENT_NODE)) { |
else if ((cur->type == XML_DOCUMENT_NODE) || |
fprintf(output, shift); |
(cur->type == XML_HTML_DOCUMENT_NODE)) |
|
fprintf(output, " /\n"); |
fprintf(output, " /\n"); |
else if (cur->type == XML_ATTRIBUTE_NODE) |
} else if (cur->type == XML_ATTRIBUTE_NODE) |
xmlDebugDumpAttr(output, (xmlAttrPtr)cur, 2); |
xmlDebugDumpAttr(output, (xmlAttrPtr)cur, depth); |
else |
else |
xmlDebugDumpOneNode(output, cur, 2); |
xmlDebugDumpOneNode(output, cur, depth); |
} |
} |
|
|
void xmlXPAthDebugDumpNodeSet(FILE *output, xmlNodeSetPtr cur) { |
void xmlXPAthDebugDumpNodeSet(FILE *output, xmlNodeSetPtr cur, int depth) { |
int i; |
int i; |
|
char shift[100]; |
|
|
|
for (i = 0;((i < depth) && (i < 25));i++) |
|
shift[2 * i] = shift[2 * i + 1] = ' '; |
|
shift[2 * i] = shift[2 * i + 1] = 0; |
|
|
if (cur == NULL) { |
if (cur == NULL) { |
|
fprintf(output, shift); |
fprintf(output, "NodeSet is NULL !\n"); |
fprintf(output, "NodeSet is NULL !\n"); |
return; |
return; |
|
|
Line 113 void xmlXPAthDebugDumpNodeSet(FILE *outp
|
Line 125 void xmlXPAthDebugDumpNodeSet(FILE *outp
|
|
|
fprintf(output, "Set contains %d nodes:\n", cur->nodeNr); |
fprintf(output, "Set contains %d nodes:\n", cur->nodeNr); |
for (i = 0;i < cur->nodeNr;i++) { |
for (i = 0;i < cur->nodeNr;i++) { |
|
fprintf(output, shift); |
fprintf(output, "%d", i + 1); |
fprintf(output, "%d", i + 1); |
xmlXPAthDebugDumpNode(output, cur->nodeTab[i]); |
xmlXPAthDebugDumpNode(output, cur->nodeTab[i], depth + 1); |
} |
} |
} |
} |
|
|
#if defined(LIBXML_XPTR_ENABLED) |
#if defined(LIBXML_XPTR_ENABLED) |
void xmlXPAthDebugDumpObject(FILE *output, xmlXPathObjectPtr cur); |
void xmlXPAthDebugDumpObject(FILE *output, xmlXPathObjectPtr cur, int depth); |
void xmlXPAthDebugDumpLocationSet(FILE *output, xmlLocationSetPtr cur) { |
void xmlXPAthDebugDumpLocationSet(FILE *output, xmlLocationSetPtr cur, int depth) { |
int i; |
int i; |
|
char shift[100]; |
|
|
|
for (i = 0;((i < depth) && (i < 25));i++) |
|
shift[2 * i] = shift[2 * i + 1] = ' '; |
|
shift[2 * i] = shift[2 * i + 1] = 0; |
|
|
if (cur == NULL) { |
if (cur == NULL) { |
|
fprintf(output, shift); |
fprintf(output, "LocationSet is NULL !\n"); |
fprintf(output, "LocationSet is NULL !\n"); |
return; |
return; |
|
|
} |
} |
|
|
fprintf(output, "Set contains %d ranges:\n", cur->locNr); |
|
for (i = 0;i < cur->locNr;i++) { |
for (i = 0;i < cur->locNr;i++) { |
fprintf(output, "%d", i + 1); |
fprintf(output, shift); |
xmlXPAthDebugDumpObject(output, cur->locTab[i]); |
fprintf(output, "%d :\n", i + 1); |
|
xmlXPAthDebugDumpObject(output, cur->locTab[i], depth + 1); |
} |
} |
} |
} |
#endif |
#endif |
|
|
void xmlXPAthDebugDumpObject(FILE *output, xmlXPathObjectPtr cur) { |
void xmlXPAthDebugDumpObject(FILE *output, xmlXPathObjectPtr cur, int depth) { |
|
int i; |
|
char shift[100]; |
|
|
|
for (i = 0;((i < depth) && (i < 25));i++) |
|
shift[2 * i] = shift[2 * i + 1] = ' '; |
|
shift[2 * i] = shift[2 * i + 1] = 0; |
|
|
|
fprintf(output, shift); |
|
|
if (cur == NULL) { |
if (cur == NULL) { |
fprintf(output, "Object is empty (NULL)\n"); |
fprintf(output, "Object is empty (NULL)\n"); |
return; |
return; |
Line 148 void xmlXPAthDebugDumpObject(FILE *outpu
|
Line 176 void xmlXPAthDebugDumpObject(FILE *outpu
|
break; |
break; |
case XPATH_NODESET: |
case XPATH_NODESET: |
fprintf(output, "Object is a Node Set :\n"); |
fprintf(output, "Object is a Node Set :\n"); |
xmlXPAthDebugDumpNodeSet(output, cur->nodesetval); |
xmlXPAthDebugDumpNodeSet(output, cur->nodesetval, depth); |
break; |
break; |
case XPATH_BOOLEAN: |
case XPATH_BOOLEAN: |
fprintf(output, "Object is a Boolean : "); |
fprintf(output, "Object is a Boolean : "); |
Line 165 void xmlXPAthDebugDumpObject(FILE *outpu
|
Line 193 void xmlXPAthDebugDumpObject(FILE *outpu
|
break; |
break; |
case XPATH_POINT: |
case XPATH_POINT: |
fprintf(output, "Object is a point : index %d in node", cur->index); |
fprintf(output, "Object is a point : index %d in node", cur->index); |
xmlXPAthDebugDumpNode(output, (xmlNodePtr) cur->user); |
xmlXPAthDebugDumpNode(output, (xmlNodePtr) cur->user, depth + 1); |
fprintf(output, "\n"); |
fprintf(output, "\n"); |
break; |
break; |
case XPATH_RANGE: |
case XPATH_RANGE: |
fprintf(output, "Object is a range : from"); |
fprintf(output, "Object is a range : from "); |
if (cur->index >= 0) |
if (cur->index >= 0) |
fprintf(output, "index %d in ", cur->index); |
fprintf(output, "index %d in ", cur->index); |
fprintf(output, "node"); |
fprintf(output, "node"); |
xmlXPAthDebugDumpNode(output, (xmlNodePtr) cur->user); |
xmlXPAthDebugDumpNode(output, (xmlNodePtr) cur->user, depth + 1); |
fprintf(output, " to "); |
fprintf(output, shift); |
|
fprintf(output, " to "); |
if (cur->index2 >= 0) |
if (cur->index2 >= 0) |
fprintf(output, "index %d in ", cur->index2); |
fprintf(output, "index %d in ", cur->index2); |
fprintf(output, "node"); |
fprintf(output, "node"); |
xmlXPAthDebugDumpNode(output, (xmlNodePtr) cur->user2); |
xmlXPAthDebugDumpNode(output, (xmlNodePtr) cur->user2, depth + 1); |
fprintf(output, "\n"); |
fprintf(output, "\n"); |
|
break; |
case XPATH_LOCATIONSET: |
case XPATH_LOCATIONSET: |
#if defined(LIBXML_XPTR_ENABLED) |
#if defined(LIBXML_XPTR_ENABLED) |
fprintf(output, "Object is a location set containing :"); |
fprintf(output, "Object is a Location Set:\n"); |
xmlXPAthDebugDumpLocationSet(output, (xmlLocationSetPtr) cur->user); |
xmlXPAthDebugDumpLocationSet(output, |
|
(xmlLocationSetPtr) cur->user, depth); |
#endif |
#endif |
|
break; |
case XPATH_USERS: |
case XPATH_USERS: |
fprintf(output, "Object is user defined\n"); |
fprintf(output, "Object is user defined\n"); |
|
break; |
} |
} |
} |
} |
|
|
Line 208 void testXPath(const char *str) {
|
Line 241 void testXPath(const char *str) {
|
#if defined(LIBXML_XPTR_ENABLED) |
#if defined(LIBXML_XPTR_ENABLED) |
} |
} |
#endif |
#endif |
xmlXPAthDebugDumpObject(stdout, res); |
xmlXPAthDebugDumpObject(stdout, res, 0); |
xmlXPathFreeObject(res); |
xmlXPathFreeObject(res); |
xmlXPathFreeContext(ctxt); |
xmlXPathFreeContext(ctxt); |
} |
} |
Line 216 void testXPath(const char *str) {
|
Line 249 void testXPath(const char *str) {
|
void testXPathFile(const char *filename) { |
void testXPathFile(const char *filename) { |
FILE *input; |
FILE *input; |
char expr[5000]; |
char expr[5000]; |
|
int len; |
|
|
input = fopen(filename, "r"); |
input = fopen(filename, "r"); |
if (input == NULL) { |
if (input == NULL) { |
fprintf(stderr, "Cannot open %s for reading\n", filename); |
fprintf(stderr, "Cannot open %s for reading\n", filename); |
return; |
return; |
} |
} |
while (fscanf(input, "%s", expr) != EOF) { |
while (fgets(expr, 4500, input) != NULL) { |
|
len = strlen(expr); |
|
len--; |
|
while ((len >= 0) && |
|
((expr[len] == '\n') || (expr[len] == '\t') || |
|
(expr[len] == '\r') || (expr[len] == ' '))) len--; |
|
expr[len + 1] = 0; |
printf("\n========================\nExpression: %s\n", expr) ; |
printf("\n========================\nExpression: %s\n", expr) ; |
testXPath(expr); |
testXPath(expr); |
} |
} |