diff --git a/ChangeLog b/ChangeLog index 0f747186..1ecb82d7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Sat Feb 24 03:35:48 CET 2001 Daniel Veillard + + * xmllint.[c1] : added return code errors for xmllint + * xpath.c: specific debug dump function for result value trees + Thu Feb 22 07:52:27 CET 2001 Daniel Veillard * xpath.c: finally implemented xmlXPathCompareNodeSets diff --git a/xmllint.1 b/xmllint.1 index c2cc694b..62a85bf6 100644 --- a/xmllint.1 +++ b/xmllint.1 @@ -95,6 +95,10 @@ Test user i/o support. .TP .B \-\-valid Validate the document in addition to std well-formed. +.SH RESULT +xmllint will return 1 if the XML is not well formed, 2 if the +Dtd could not be loaded and 3 if the valiadtion fails. If no +error is detected it will return 0. .SH FILES .TP 2.2i .B /depot/package/libxml_2.0.0/bin/xmllint diff --git a/xmllint.c b/xmllint.c index 7d6ec874..df4b4c1b 100644 --- a/xmllint.c +++ b/xmllint.c @@ -87,6 +87,7 @@ static char *encoding = NULL; #ifdef LIBXML_XINCLUDE_ENABLED static int xinclude = 0; #endif +static int progresult = 0; #ifdef VMS @@ -522,6 +523,7 @@ void parseAndPrintFile(char *filename) { * If we don't have a document we might as well give up. Do we * want an error message here? */ if (doc == NULL) { + progresult = 1; return; } @@ -615,6 +617,7 @@ void parseAndPrintFile(char *filename) { if (dtd == NULL) { xmlGenericError(xmlGenericErrorContext, "Could not parse DTD %s\n", dtdvalid); + progresult = 2; } else { xmlValidCtxt cvp; cvp.userData = (void *) stderr; cvp.error = (xmlValidityErrorFunc) fprintf; cvp.warning = (xmlValidityWarningFunc) fprintf; @@ -622,6 +625,7 @@ void parseAndPrintFile(char *filename) { xmlGenericError(xmlGenericErrorContext, "Document %s does not validate against %s\n", filename, dtdvalid); + progresult = 3; } xmlFreeDtd(dtd); } @@ -631,6 +635,7 @@ void parseAndPrintFile(char *filename) { if (!xmlValidateDocument(&cvp, doc)) { xmlGenericError(xmlGenericErrorContext, "Document %s does not validate\n", filename); + progresult = 3; } } @@ -831,6 +836,6 @@ main(int argc, char **argv) { xmlCleanupParser(); xmlMemoryDump(); - return(0); + return(progresult); } diff --git a/xpath.c b/xpath.c index 669e4cd3..1287d5da 100644 --- a/xpath.c +++ b/xpath.c @@ -211,6 +211,27 @@ void xmlXPathDebugDumpNode(FILE *output, xmlNodePtr cur, int depth) { else xmlDebugDumpOneNode(output, cur, depth); } +void xmlXPathDebugDumpNodeList(FILE *output, xmlNodePtr cur, int depth) { + xmlNodePtr tmp; + 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) { + fprintf(output, shift); + fprintf(output, "Node is NULL !\n"); + return; + + } + + while (cur != NULL) { + tmp = cur; + cur = cur->next; + xmlDebugDumpOneNode(output, tmp, depth); + } +} void xmlXPathDebugDumpNodeSet(FILE *output, xmlNodeSetPtr cur, int depth) { int i; @@ -235,6 +256,25 @@ void xmlXPathDebugDumpNodeSet(FILE *output, xmlNodeSetPtr cur, int depth) { } } +void xmlXPathDebugDumpValueTree(FILE *output, xmlNodeSetPtr 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) || (cur->nodeNr == 0) || (cur->nodeTab[0] == NULL)) { + fprintf(output, shift); + fprintf(output, "Value Tree is NULL !\n"); + return; + + } + + fprintf(output, shift); + fprintf(output, "%d", i + 1); + xmlXPathDebugDumpNodeList(output, cur->nodeTab[0]->children, depth + 1); +} #if defined(LIBXML_XPTR_ENABLED) void xmlXPathDebugDumpObject(FILE *output, xmlXPathObjectPtr cur, int depth); void xmlXPathDebugDumpLocationSet(FILE *output, xmlLocationSetPtr cur, int depth) { @@ -284,7 +324,7 @@ void xmlXPathDebugDumpObject(FILE *output, xmlXPathObjectPtr cur, int depth) { break; case XPATH_XSLT_TREE: fprintf(output, "Object is an XSLT value tree :\n"); - xmlXPathDebugDumpNode(output, cur->user, depth); + xmlXPathDebugDumpValueTree(output, cur->nodesetval, depth); break; case XPATH_BOOLEAN: fprintf(output, "Object is a Boolean : ");