Annotation of XML/xmllint.c, revision 1.17
1.1 daniel 1: /*
2: * xmllint.c : a small tester program for XML input.
3: *
4: * See Copyright for the status of this software.
5: *
6: * Daniel.Veillard@w3.org
7: */
8:
9: #ifdef WIN32
10: #include "win32config.h"
11: #else
12: #include "config.h"
13: #endif
14:
15: #include <stdio.h>
16: #include <string.h>
17: #include <stdio.h>
18: #include <stdarg.h>
19:
20: #ifdef HAVE_SYS_TYPES_H
21: #include <sys/types.h>
22: #endif
23: #ifdef HAVE_SYS_STAT_H
24: #include <sys/stat.h>
25: #endif
26: #ifdef HAVE_FCNTL_H
27: #include <fcntl.h>
28: #endif
29: #ifdef HAVE_UNISTD_H
30: #include <unistd.h>
31: #endif
1.7 veillard 32: #ifdef HAVE_SYS_MMAN_H
33: #include <sys/mman.h>
1.8 veillard 34: /* seems needed for Solaris */
1.9 veillard 35: #ifndef MAP_FAILED
36: #define MAP_FAILED ((void *) -1)
1.8 veillard 37: #endif
1.7 veillard 38: #endif
1.1 daniel 39: #ifdef HAVE_STDLIB_H
40: #include <stdlib.h>
41: #endif
42: #ifdef HAVE_LIBREADLINE
43: #include <readline/readline.h>
44: #ifdef HAVE_LIBHISTORY
45: #include <readline/history.h>
46: #endif
47: #endif
48:
49: #include <libxml/xmlmemory.h>
50: #include <libxml/parser.h>
51: #include <libxml/parserInternals.h>
52: #include <libxml/HTMLparser.h>
53: #include <libxml/HTMLtree.h>
54: #include <libxml/tree.h>
55: #include <libxml/xpath.h>
56: #include <libxml/debugXML.h>
57:
58: #ifdef LIBXML_DEBUG_ENABLED
59: static int debug = 0;
60: static int shell = 0;
61: static int debugent = 0;
62: #endif
63: static int copy = 0;
64: static int recovery = 0;
65: static int noent = 0;
66: static int noout = 0;
67: static int nowrap = 0;
68: static int valid = 0;
69: static int postvalid = 0;
1.16 veillard 70: static char * dtdvalid = NULL;
1.1 daniel 71: static int repeat = 0;
72: static int insert = 0;
73: static int compress = 0;
74: static int html = 0;
75: static int htmlout = 0;
76: static int push = 0;
1.7 veillard 77: #ifdef HAVE_SYS_MMAN_H
78: static int memory = 0;
79: #endif
1.1 daniel 80: static int noblanks = 0;
1.2 daniel 81: static int testIO = 0;
1.3 daniel 82: static char *encoding = NULL;
1.1 daniel 83:
84: extern int xmlDoValidityCheckingDefaultValue;
85: extern int xmlGetWarningsDefaultValue;
86:
87: /************************************************************************
88: * *
89: * HTML ouput *
90: * *
91: ************************************************************************/
92: char buffer[50000];
93:
94: void
95: xmlHTMLEncodeSend(void) {
96: char *result;
97:
98: result = (char *) xmlEncodeEntitiesReentrant(NULL, BAD_CAST buffer);
99: if (result) {
100: fprintf(stderr, "%s", result);
101: xmlFree(result);
102: }
103: buffer[0] = 0;
104: }
105:
106: /**
107: * xmlHTMLPrintFileInfo:
108: * @input: an xmlParserInputPtr input
109: *
110: * Displays the associated file and line informations for the current input
111: */
112:
113: void
114: xmlHTMLPrintFileInfo(xmlParserInputPtr input) {
115: fprintf(stderr, "<p>");
116: if (input != NULL) {
117: if (input->filename) {
118: sprintf(&buffer[strlen(buffer)], "%s:%d: ", input->filename,
119: input->line);
120: } else {
121: sprintf(&buffer[strlen(buffer)], "Entity: line %d: ", input->line);
122: }
123: }
124: xmlHTMLEncodeSend();
125: }
126:
127: /**
128: * xmlHTMLPrintFileContext:
129: * @input: an xmlParserInputPtr input
130: *
131: * Displays current context within the input content for error tracking
132: */
133:
134: void
135: xmlHTMLPrintFileContext(xmlParserInputPtr input) {
136: const xmlChar *cur, *base;
137: int n;
138:
139: if (input == NULL) return;
140: fprintf(stderr, "<pre>\n");
141: cur = input->cur;
142: base = input->base;
143: while ((cur > base) && ((*cur == '\n') || (*cur == '\r'))) {
144: cur--;
145: }
146: n = 0;
147: while ((n++ < 80) && (cur > base) && (*cur != '\n') && (*cur != '\r'))
148: cur--;
149: if ((*cur == '\n') || (*cur == '\r')) cur++;
150: base = cur;
151: n = 0;
152: while ((*cur != 0) && (*cur != '\n') && (*cur != '\r') && (n < 79)) {
153: sprintf(&buffer[strlen(buffer)], "%c", (unsigned char) *cur++);
154: n++;
155: }
156: sprintf(&buffer[strlen(buffer)], "\n");
157: cur = input->cur;
158: while ((*cur == '\n') || (*cur == '\r'))
159: cur--;
160: n = 0;
161: while ((cur != base) && (n++ < 80)) {
162: sprintf(&buffer[strlen(buffer)], " ");
163: base++;
164: }
165: sprintf(&buffer[strlen(buffer)],"^\n");
166: xmlHTMLEncodeSend();
167: fprintf(stderr, "</pre>");
168: }
169:
170: /**
171: * xmlHTMLError:
172: * @ctx: an XML parser context
173: * @msg: the message to display/transmit
174: * @...: extra parameters for the message display
175: *
176: * Display and format an error messages, gives file, line, position and
177: * extra parameters.
178: */
179: void
180: xmlHTMLError(void *ctx, const char *msg, ...)
181: {
182: xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
183: xmlParserInputPtr input;
184: xmlParserInputPtr cur = NULL;
185: va_list args;
186:
187: buffer[0] = 0;
188: input = ctxt->input;
189: if ((input != NULL) && (input->filename == NULL) && (ctxt->inputNr > 1)) {
190: cur = input;
191: input = ctxt->inputTab[ctxt->inputNr - 2];
192: }
193:
194: xmlHTMLPrintFileInfo(input);
195:
196: fprintf(stderr, "<b>error</b>: ");
197: va_start(args, msg);
198: vsprintf(&buffer[strlen(buffer)], msg, args);
199: va_end(args);
200: xmlHTMLEncodeSend();
201: fprintf(stderr, "</p>\n");
202:
203: xmlHTMLPrintFileContext(input);
204: xmlHTMLEncodeSend();
205: }
206:
207: /**
208: * xmlHTMLWarning:
209: * @ctx: an XML parser context
210: * @msg: the message to display/transmit
211: * @...: extra parameters for the message display
212: *
213: * Display and format a warning messages, gives file, line, position and
214: * extra parameters.
215: */
216: void
217: xmlHTMLWarning(void *ctx, const char *msg, ...)
218: {
219: xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
220: xmlParserInputPtr input;
221: xmlParserInputPtr cur = NULL;
222: va_list args;
223:
224: buffer[0] = 0;
225: input = ctxt->input;
226: if ((input != NULL) && (input->filename == NULL) && (ctxt->inputNr > 1)) {
227: cur = input;
228: input = ctxt->inputTab[ctxt->inputNr - 2];
229: }
230:
231:
232: xmlHTMLPrintFileInfo(input);
233:
234: fprintf(stderr, "<b>warning</b>: ");
235: va_start(args, msg);
236: vsprintf(&buffer[strlen(buffer)], msg, args);
237: va_end(args);
238: xmlHTMLEncodeSend();
239: fprintf(stderr, "</p>\n");
240:
241: xmlHTMLPrintFileContext(input);
242: xmlHTMLEncodeSend();
243: }
244:
245: /**
246: * xmlHTMLValidityError:
247: * @ctx: an XML parser context
248: * @msg: the message to display/transmit
249: * @...: extra parameters for the message display
250: *
251: * Display and format an validity error messages, gives file,
252: * line, position and extra parameters.
253: */
254: void
255: xmlHTMLValidityError(void *ctx, const char *msg, ...)
256: {
257: xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
258: xmlParserInputPtr input;
259: va_list args;
260:
261: buffer[0] = 0;
262: input = ctxt->input;
263: if ((input->filename == NULL) && (ctxt->inputNr > 1))
264: input = ctxt->inputTab[ctxt->inputNr - 2];
265:
266: xmlHTMLPrintFileInfo(input);
267:
268: fprintf(stderr, "<b>validity error</b>: ");
269: va_start(args, msg);
270: vsprintf(&buffer[strlen(buffer)], msg, args);
271: va_end(args);
272: xmlHTMLEncodeSend();
273: fprintf(stderr, "</p>\n");
274:
275: xmlHTMLPrintFileContext(input);
276: xmlHTMLEncodeSend();
277: }
278:
279: /**
280: * xmlHTMLValidityWarning:
281: * @ctx: an XML parser context
282: * @msg: the message to display/transmit
283: * @...: extra parameters for the message display
284: *
285: * Display and format a validity warning messages, gives file, line,
286: * position and extra parameters.
287: */
288: void
289: xmlHTMLValidityWarning(void *ctx, const char *msg, ...)
290: {
291: xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
292: xmlParserInputPtr input;
293: va_list args;
294:
295: buffer[0] = 0;
296: input = ctxt->input;
297: if ((input->filename == NULL) && (ctxt->inputNr > 1))
298: input = ctxt->inputTab[ctxt->inputNr - 2];
299:
300: xmlHTMLPrintFileInfo(input);
301:
302: fprintf(stderr, "<b>validity warning</b>: ");
303: va_start(args, msg);
304: vsprintf(&buffer[strlen(buffer)], msg, args);
305: va_end(args);
306: xmlHTMLEncodeSend();
307: fprintf(stderr, "</p>\n");
308:
309: xmlHTMLPrintFileContext(input);
310: xmlHTMLEncodeSend();
311: }
312:
313: /************************************************************************
314: * *
315: * Shell Interface *
316: * *
317: ************************************************************************/
318: /**
319: * xmlShellReadline:
320: * @prompt: the prompt value
321: *
322: * Read a string
323: *
324: * Returns a pointer to it or NULL on EOF the caller is expected to
325: * free the returned string.
326: */
327: char *
328: xmlShellReadline(char *prompt) {
329: #ifdef HAVE_LIBREADLINE
330: char *line_read;
331:
332: /* Get a line from the user. */
333: line_read = readline (prompt);
334:
335: /* If the line has any text in it, save it on the history. */
336: if (line_read && *line_read)
337: add_history (line_read);
338:
339: return (line_read);
340: #else
341: char line_read[501];
342:
343: if (prompt != NULL)
344: fprintf(stdout, "%s", prompt);
345: if (!fgets(line_read, 500, stdin))
346: return(NULL);
347: line_read[500] = 0;
348: return(strdup(line_read));
349: #endif
350: }
351:
352: /************************************************************************
353: * *
1.2 daniel 354: * I/O Interfaces *
355: * *
356: ************************************************************************/
357:
358: int myRead(FILE *f, char * buffer, int len) {
359: return(fread(buffer, 1, len, f));
360: }
361: void myClose(FILE *f) {
362: fclose(f);
363: }
364:
365: /************************************************************************
366: * *
1.1 daniel 367: * Test processing *
368: * *
369: ************************************************************************/
370: void parseAndPrintFile(char *filename) {
371: xmlDocPtr doc = NULL, tmp;
372:
373: #ifdef LIBXML_HTML_ENABLED
374: if (html) {
375: doc = htmlParseFile(filename, NULL);
376: } else {
377: #endif /* LIBXML_HTML_ENABLED */
378: /*
379: * build an XML tree from a string;
380: */
381: if (push) {
382: FILE *f;
383:
384: f = fopen(filename, "r");
385: if (f != NULL) {
1.14 veillard 386: int ret;
1.1 daniel 387: int res, size = 3;
388: char chars[1024];
389: xmlParserCtxtPtr ctxt;
390:
391: if (repeat)
392: size = 1024;
393: res = fread(chars, 1, 4, f);
394: if (res > 0) {
395: ctxt = xmlCreatePushParserCtxt(NULL, NULL,
396: chars, res, filename);
397: while ((res = fread(chars, 1, size, f)) > 0) {
398: xmlParseChunk(ctxt, chars, res, 0);
399: }
400: xmlParseChunk(ctxt, chars, 0, 1);
401: doc = ctxt->myDoc;
1.14 veillard 402: ret = ctxt->wellFormed;
1.1 daniel 403: xmlFreeParserCtxt(ctxt);
1.14 veillard 404: if (!ret) {
405: xmlFreeDoc(doc);
406: doc = NULL;
407: }
1.1 daniel 408: }
409: }
1.2 daniel 410: } else if (testIO) {
411: int ret;
412: FILE *f;
413:
414: f = fopen(filename, "r");
415: if (f != NULL) {
416: xmlParserCtxtPtr ctxt;
417:
418: ctxt = xmlCreateIOParserCtxt(NULL, NULL,
419: (xmlInputReadCallback) myRead,
420: (xmlInputCloseCallback) myClose,
421: f, XML_CHAR_ENCODING_NONE);
422: xmlParseDocument(ctxt);
423:
424: ret = ctxt->wellFormed;
425: doc = ctxt->myDoc;
426: xmlFreeParserCtxt(ctxt);
427: if (!ret) {
428: xmlFreeDoc(doc);
429: doc = NULL;
430: }
431: }
1.1 daniel 432: } else if (recovery) {
433: doc = xmlRecoverFile(filename);
434: } else if (htmlout) {
435: int ret;
436: xmlParserCtxtPtr ctxt;
437: xmlSAXHandler silent, *old;
438:
439: ctxt = xmlCreateFileParserCtxt(filename);
1.10 veillard 440:
441: if (ctxt == NULL) {
442: /* If xmlCreateFileParseCtxt() return NULL something
443: strange happened so we don't want to do anything. Do
444: we want to print an error message here?
445: <sven@zen.org> */
446: doc = NULL;
447: } else {
448: memcpy(&silent, ctxt->sax, sizeof(silent));
449: old = ctxt->sax;
450: silent.error = xmlHTMLError;
451: if (xmlGetWarningsDefaultValue)
1.1 daniel 452: silent.warning = xmlHTMLWarning;
1.10 veillard 453: else
1.1 daniel 454: silent.warning = NULL;
1.10 veillard 455: silent.fatalError = xmlHTMLError;
456: ctxt->sax = &silent;
457: ctxt->vctxt.error = xmlHTMLValidityError;
458: if (xmlGetWarningsDefaultValue)
1.1 daniel 459: ctxt->vctxt.warning = xmlHTMLValidityWarning;
1.10 veillard 460: else
1.1 daniel 461: ctxt->vctxt.warning = NULL;
462:
1.10 veillard 463: xmlParseDocument(ctxt);
1.1 daniel 464:
1.10 veillard 465: ret = ctxt->wellFormed;
466: doc = ctxt->myDoc;
467: ctxt->sax = old;
468: xmlFreeParserCtxt(ctxt);
469: if (!ret) {
1.1 daniel 470: xmlFreeDoc(doc);
471: doc = NULL;
1.10 veillard 472: }
1.1 daniel 473: }
1.7 veillard 474: #ifdef HAVE_SYS_MMAN_H
475: } else if (memory) {
476: int fd;
477: struct stat info;
478: const char *base;
479: if (stat(filename, &info) < 0)
480: return;
481: if ((fd = open(filename, O_RDONLY)) < 0)
482: return;
483: base = mmap(NULL, info.st_size, PROT_READ, MAP_SHARED, fd, 0) ;
1.11 veillard 484: if (base == (void *) MAP_FAILED)
1.7 veillard 485: return;
486:
487: doc = xmlParseMemory((char *) base, info.st_size);
488: munmap((char *) base, info.st_size);
489: #endif
1.1 daniel 490: } else
491: doc = xmlParseFile(filename);
492: #ifdef LIBXML_HTML_ENABLED
493: }
494: #endif
495:
1.10 veillard 496: /*
497: * If we don't have a document we might as well give up. Do we
498: * want an error message here? <sven@zen.org> */
499: if (doc == NULL)
500: {
501: return;
502: }
503:
1.1 daniel 504: #ifdef LIBXML_DEBUG_ENABLED
505: /*
506: * shell interraction
507: */
508: if (shell)
509: xmlShell(doc, filename, xmlShellReadline, stdout);
510: #endif
511:
512: /*
513: * test intermediate copy if needed.
514: */
515: if (copy) {
516: tmp = doc;
517: doc = xmlCopyDoc(doc, 1);
518: xmlFreeDoc(tmp);
519: }
520:
521: if ((insert) && (!html)) {
522: const xmlChar* list[256];
523: int nb, i;
524: xmlNodePtr node;
525:
526: if (doc->children != NULL) {
527: node = doc->children;
528: while ((node != NULL) && (node->last == NULL)) node = node->next;
529: if (node != NULL) {
530: nb = xmlValidGetValidElements(node->last, NULL, list, 256);
531: if (nb < 0) {
532: printf("could not get valid list of elements\n");
533: } else if (nb == 0) {
534: printf("No element can be indersted under root\n");
535: } else {
536: printf("%d element types can be indersted under root:\n",
537: nb);
538: for (i = 0;i < nb;i++) {
539: printf("%s\n", list[i]);
540: }
541: }
542: }
543: }
544: }else if (noout == 0) {
545: /*
546: * print it.
547: */
548: #ifdef LIBXML_DEBUG_ENABLED
549: if (!debug) {
550: #endif
551: if (compress)
552: xmlSaveFile("-", doc);
1.3 daniel 553: else if (encoding != NULL)
554: xmlSaveFileEnc("-", doc, encoding);
1.1 daniel 555: else
556: xmlDocDump(stdout, doc);
557: #ifdef LIBXML_DEBUG_ENABLED
558: } else
559: xmlDebugDumpDocument(stdout, doc);
560: #endif
561: }
562:
563: /*
564: * A posteriori validation test
565: */
1.16 veillard 566: if (dtdvalid != NULL) {
567: xmlDtdPtr dtd;
568:
569: dtd = xmlParseDTD(NULL, (const xmlChar *)dtdvalid);
570: if (dtd == NULL) {
571: fprintf(stderr, "Could not parse DTD %s\n", dtdvalid);
572: } else {
573: xmlValidCtxt cvp;
574: cvp.userData = (void *) stderr; cvp.error = (xmlValidityErrorFunc) fprintf; cvp.warning = (xmlValidityWarningFunc) fprintf;
1.17 ! veillard 575: if (!xmlValidateDtd(&cvp, doc, dtd)) {
! 576: fprintf(stderr, "Document %s does not validate against %s\n",
! 577: filename, dtdvalid);
! 578: }
! 579: xmlFreeDtd(dtd);
1.16 veillard 580: }
581: } else if (postvalid) {
1.1 daniel 582: xmlValidCtxt cvp;
583: cvp.userData = (void *) stderr; cvp.error = (xmlValidityErrorFunc) fprintf; cvp.warning = (xmlValidityWarningFunc) fprintf;
1.17 ! veillard 584: if (!xmlValidateDocument(&cvp, doc)) {
! 585: fprintf(stderr, "Document %s does not validate\n", filename);
! 586: }
1.1 daniel 587: }
588:
589: #ifdef LIBXML_DEBUG_ENABLED
590: if ((debugent) && (!html))
1.13 veillard 591: xmlDebugDumpEntities(stderr, doc);
1.1 daniel 592: #endif
593:
594: /*
595: * free it.
596: */
597: xmlFreeDoc(doc);
598: }
599:
600: int main(int argc, char **argv) {
601: int i, count;
602: int files = 0;
603:
1.4 daniel 604: LIBXML_TEST_VERSION
1.1 daniel 605: for (i = 1; i < argc ; i++) {
606: #ifdef LIBXML_DEBUG_ENABLED
607: if ((!strcmp(argv[i], "-debug")) || (!strcmp(argv[i], "--debug")))
608: debug++;
609: else if ((!strcmp(argv[i], "-shell")) ||
610: (!strcmp(argv[i], "--shell"))) {
611: shell++;
612: noout = 1;
613: } else
614: #endif
615: if ((!strcmp(argv[i], "-copy")) || (!strcmp(argv[i], "--copy")))
616: copy++;
617: else if ((!strcmp(argv[i], "-recover")) ||
618: (!strcmp(argv[i], "--recover")))
619: recovery++;
620: else if ((!strcmp(argv[i], "-noent")) ||
621: (!strcmp(argv[i], "--noent")))
622: noent++;
623: else if ((!strcmp(argv[i], "-noout")) ||
624: (!strcmp(argv[i], "--noout")))
625: noout++;
626: else if ((!strcmp(argv[i], "-htmlout")) ||
627: (!strcmp(argv[i], "--htmlout")))
628: htmlout++;
629: #ifdef LIBXML_HTML_ENABLED
630: else if ((!strcmp(argv[i], "-html")) ||
631: (!strcmp(argv[i], "--html"))) {
632: html++;
633: }
634: #endif /* LIBXML_HTML_ENABLED */
635: else if ((!strcmp(argv[i], "-nowrap")) ||
636: (!strcmp(argv[i], "--nowrap")))
637: nowrap++;
638: else if ((!strcmp(argv[i], "-valid")) ||
639: (!strcmp(argv[i], "--valid")))
640: valid++;
641: else if ((!strcmp(argv[i], "-postvalid")) ||
642: (!strcmp(argv[i], "--postvalid")))
643: postvalid++;
1.16 veillard 644: else if ((!strcmp(argv[i], "-dtdvalid")) ||
645: (!strcmp(argv[i], "--dtdvalid"))) {
646: i++;
647: dtdvalid = argv[i];
648: }
1.1 daniel 649: else if ((!strcmp(argv[i], "-insert")) ||
650: (!strcmp(argv[i], "--insert")))
651: insert++;
652: else if ((!strcmp(argv[i], "-repeat")) ||
653: (!strcmp(argv[i], "--repeat")))
654: repeat++;
655: else if ((!strcmp(argv[i], "-push")) ||
656: (!strcmp(argv[i], "--push")))
657: push++;
1.7 veillard 658: #ifdef HAVE_SYS_MMAN_H
659: else if ((!strcmp(argv[i], "-memory")) ||
660: (!strcmp(argv[i], "--memory")))
661: memory++;
662: #endif
1.2 daniel 663: else if ((!strcmp(argv[i], "-testIO")) ||
664: (!strcmp(argv[i], "--testIO")))
665: testIO++;
1.1 daniel 666: else if ((!strcmp(argv[i], "-compress")) ||
667: (!strcmp(argv[i], "--compress"))) {
668: compress++;
669: xmlSetCompressMode(9);
670: }
671: else if ((!strcmp(argv[i], "-nowarning")) ||
672: (!strcmp(argv[i], "--nowarning"))) {
673: xmlGetWarningsDefaultValue = 0;
1.13 veillard 674: xmlPedanticParserDefault(0);
675: }
676: else if ((!strcmp(argv[i], "-pedantic")) ||
677: (!strcmp(argv[i], "--pedantic"))) {
678: xmlGetWarningsDefaultValue = 1;
679: xmlPedanticParserDefault(1);
1.1 daniel 680: }
1.15 veillard 681: #ifdef LIBXML_DEBUG_ENABLED
1.13 veillard 682: else if ((!strcmp(argv[i], "-debugent")) ||
683: (!strcmp(argv[i], "--debugent"))) {
684: debugent++;
685: xmlParserDebugEntities = 1;
686: }
1.15 veillard 687: #endif
1.3 daniel 688: else if ((!strcmp(argv[i], "-encode")) ||
689: (!strcmp(argv[i], "--encode"))) {
690: i++;
691: encoding = argv[i];
1.12 veillard 692: /*
693: * OK it's for testing purposes
694: */
695: xmlAddEncodingAlias("UTF-8", "DVEnc");
1.3 daniel 696: }
1.1 daniel 697: else if ((!strcmp(argv[i], "-noblanks")) ||
698: (!strcmp(argv[i], "--noblanks"))) {
699: noblanks++;
700: xmlKeepBlanksDefault(0);
701: }
702: }
703: if (noent != 0) xmlSubstituteEntitiesDefault(1);
704: if (valid != 0) xmlDoValidityCheckingDefaultValue = 1;
705: if ((htmlout) && (!nowrap)) {
706: fprintf(stderr,
707: "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\"\n");
708: fprintf(stderr, "\t\"http://www.w3.org/TR/REC-html40/loose.dtd\">\n");
709: fprintf(stderr,
710: "<html><head><title>%s output</title></head>\n",
711: argv[0]);
712: fprintf(stderr,
713: "<body bgcolor=\"#ffffff\"><h1 align=\"center\">%s output</h1>\n",
714: argv[0]);
715: }
716: for (i = 1; i < argc ; i++) {
1.3 daniel 717: if ((!strcmp(argv[i], "-encode")) ||
718: (!strcmp(argv[i], "--encode"))) {
1.17 ! veillard 719: i++;
! 720: continue;
! 721: }
! 722: if ((!strcmp(argv[i], "-dtdvalid")) ||
! 723: (!strcmp(argv[i], "--dtdvalid"))) {
1.3 daniel 724: i++;
725: continue;
726: }
1.1 daniel 727: if (argv[i][0] != '-') {
728: if (repeat) {
729: for (count = 0;count < 100 * repeat;count++)
730: parseAndPrintFile(argv[i]);
731: } else
732: parseAndPrintFile(argv[i]);
733: files ++;
734: }
735: }
736: if ((htmlout) && (!nowrap)) {
737: fprintf(stderr, "</body></html>\n");
738: }
739: if (files == 0) {
740: printf("Usage : %s [--debug] [--debugent] [--copy] [--recover] [--noent] [--noout] [--valid] [--repeat] XMLfiles ...\n",
741: argv[0]);
742: printf("\tParse the XML files and output the result of the parsing\n");
743: #ifdef LIBXML_DEBUG_ENABLED
744: printf("\t--debug : dump a debug tree of the in-memory document\n");
745: printf("\t--shell : run a navigating shell\n");
746: printf("\t--debugent : debug the entities defined in the document\n");
747: #endif
748: printf("\t--copy : used to test the internal copy implementation\n");
749: printf("\t--recover : output what was parsable on broken XML documents\n");
750: printf("\t--noent : substitute entity references by their value\n");
751: printf("\t--noout : don't output the result tree\n");
752: printf("\t--htmlout : output results as HTML\n");
753: printf("\t--nowarp : do not put HTML doc wrapper\n");
754: printf("\t--valid : validate the document in addition to std well-formed check\n");
755: printf("\t--postvalid : do a posteriori validation, i.e after parsing\n");
1.16 veillard 756: printf("\t--dtdvalid URL : do a posteriori validation against a given DTD\n");
1.1 daniel 757: printf("\t--repeat : repeat 100 times, for timing or profiling\n");
758: printf("\t--insert : ad-hoc test for valid insertions\n");
759: printf("\t--compress : turn on gzip compression of output\n");
760: #ifdef LIBXML_HTML_ENABLED
761: printf("\t--html : use the HTML parser\n");
762: #endif
763: printf("\t--push : use the push mode of the parser\n");
1.7 veillard 764: #ifdef HAVE_SYS_MMAN_H
765: printf("\t--memory : parse from memory\n");
766: #endif
1.1 daniel 767: printf("\t--nowarning : do not emit warnings from parser/validator\n");
768: printf("\t--noblanks : drop (ignorable?) blanks spaces\n");
1.2 daniel 769: printf("\t--testIO : test user I/O support\n");
1.6 veillard 770: printf("\t--encode encoding : output in the given encoding\n");
1.1 daniel 771: }
772: xmlCleanupParser();
773: xmlMemoryDump();
774:
775: return(0);
776: }
1.10 veillard 777:
Webmaster