Annotation of XML/testHTML.c, revision 1.15
1.1 daniel 1: /*
2: * testHTML.c : a small tester program for HTML input.
3: *
4: * See Copyright for the status of this software.
5: *
6: * Daniel.Veillard@w3.org
7: */
8:
9: #ifdef WIN32
1.9 daniel 10: #include "win32config.h"
1.1 daniel 11: #else
1.4 daniel 12: #include "config.h"
1.1 daniel 13: #endif
1.3 daniel 14:
1.12 daniel 15: #include "xmlversion.h"
16: #ifdef LIBXML_HTML_ENABLED
17:
1.3 daniel 18: #include <stdio.h>
19: #include <string.h>
1.7 daniel 20: #include <stdarg.h>
21:
1.3 daniel 22:
23: #ifdef HAVE_SYS_TYPES_H
1.1 daniel 24: #include <sys/types.h>
1.3 daniel 25: #endif
1.1 daniel 26: #ifdef HAVE_SYS_STAT_H
27: #include <sys/stat.h>
28: #endif
29: #ifdef HAVE_FCNTL_H
30: #include <fcntl.h>
31: #endif
32: #ifdef HAVE_UNISTD_H
33: #include <unistd.h>
34: #endif
1.3 daniel 35: #ifdef HAVE_STDLIB_H
1.1 daniel 36: #include <stdlib.h>
1.3 daniel 37: #endif
1.1 daniel 38:
1.12 daniel 39: #include <libxml/xmlmemory.h>
40: #include <libxml/HTMLparser.h>
41: #include <libxml/HTMLtree.h>
42: #include <libxml/debugXML.h>
1.1 daniel 43:
1.12 daniel 44: #ifdef LIBXML_DEBUG_ENABLED
1.1 daniel 45: static int debug = 0;
1.12 daniel 46: #endif
1.1 daniel 47: static int copy = 0;
1.7 daniel 48: static int sax = 0;
49: static int repeat = 0;
50: static int noout = 0;
1.10 daniel 51: static int push = 0;
1.13 veillard 52: static char *encoding = NULL;
1.1 daniel 53:
1.7 daniel 54: xmlSAXHandler emptySAXHandlerStruct = {
55: NULL, /* internalSubset */
56: NULL, /* isStandalone */
57: NULL, /* hasInternalSubset */
58: NULL, /* hasExternalSubset */
59: NULL, /* resolveEntity */
60: NULL, /* getEntity */
61: NULL, /* entityDecl */
62: NULL, /* notationDecl */
63: NULL, /* attributeDecl */
64: NULL, /* elementDecl */
65: NULL, /* unparsedEntityDecl */
66: NULL, /* setDocumentLocator */
67: NULL, /* startDocument */
68: NULL, /* endDocument */
69: NULL, /* startElement */
70: NULL, /* endElement */
71: NULL, /* reference */
72: NULL, /* characters */
73: NULL, /* ignorableWhitespace */
74: NULL, /* processingInstruction */
75: NULL, /* comment */
76: NULL, /* xmlParserWarning */
77: NULL, /* xmlParserError */
78: NULL, /* xmlParserError */
79: NULL, /* getParameterEntity */
80: };
81:
82: xmlSAXHandlerPtr emptySAXHandler = &emptySAXHandlerStruct;
83: extern xmlSAXHandlerPtr debugSAXHandler;
84:
85: /************************************************************************
86: * *
87: * Debug Handlers *
88: * *
89: ************************************************************************/
90:
91: /**
92: * isStandaloneDebug:
93: * @ctxt: An XML parser context
94: *
95: * Is this document tagged standalone ?
96: *
97: * Returns 1 if true
98: */
99: int
100: isStandaloneDebug(void *ctx)
101: {
102: fprintf(stdout, "SAX.isStandalone()\n");
103: return(0);
104: }
105:
106: /**
107: * hasInternalSubsetDebug:
108: * @ctxt: An XML parser context
109: *
110: * Does this document has an internal subset
111: *
112: * Returns 1 if true
113: */
114: int
115: hasInternalSubsetDebug(void *ctx)
116: {
117: fprintf(stdout, "SAX.hasInternalSubset()\n");
118: return(0);
119: }
120:
121: /**
122: * hasExternalSubsetDebug:
123: * @ctxt: An XML parser context
124: *
125: * Does this document has an external subset
126: *
127: * Returns 1 if true
128: */
129: int
130: hasExternalSubsetDebug(void *ctx)
131: {
132: fprintf(stdout, "SAX.hasExternalSubset()\n");
133: return(0);
134: }
135:
136: /**
137: * hasInternalSubsetDebug:
138: * @ctxt: An XML parser context
139: *
140: * Does this document has an internal subset
141: */
142: void
143: internalSubsetDebug(void *ctx, const xmlChar *name,
144: const xmlChar *ExternalID, const xmlChar *SystemID)
145: {
146: /* xmlDtdPtr externalSubset; */
147:
148: fprintf(stdout, "SAX.internalSubset(%s, %s, %s)\n",
149: name, ExternalID, SystemID);
150:
151: /***********
152: if ((ExternalID != NULL) || (SystemID != NULL)) {
153: externalSubset = xmlParseDTD(ExternalID, SystemID);
154: if (externalSubset != NULL) {
155: xmlFreeDtd(externalSubset);
156: }
157: }
158: ***********/
159: }
160:
161: /**
162: * resolveEntityDebug:
163: * @ctxt: An XML parser context
164: * @publicId: The public ID of the entity
165: * @systemId: The system ID of the entity
166: *
167: * Special entity resolver, better left to the parser, it has
168: * more context than the application layer.
169: * The default behaviour is to NOT resolve the entities, in that case
170: * the ENTITY_REF nodes are built in the structure (and the parameter
171: * values).
172: *
173: * Returns the xmlParserInputPtr if inlined or NULL for DOM behaviour.
174: */
175: xmlParserInputPtr
176: resolveEntityDebug(void *ctx, const xmlChar *publicId, const xmlChar *systemId)
177: {
178: /* xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx; */
179:
180:
181: fprintf(stdout, "SAX.resolveEntity(");
182: if (publicId != NULL)
183: fprintf(stdout, "%s", (char *)publicId);
184: else
185: fprintf(stdout, " ");
186: if (systemId != NULL)
187: fprintf(stdout, ", %s)\n", (char *)systemId);
188: else
189: fprintf(stdout, ", )\n");
190: /*********
191: if (systemId != NULL) {
192: return(xmlNewInputFromFile(ctxt, (char *) systemId));
193: }
194: *********/
195: return(NULL);
196: }
197:
198: /**
199: * getEntityDebug:
200: * @ctxt: An XML parser context
201: * @name: The entity name
202: *
203: * Get an entity by name
204: *
205: * Returns the xmlParserInputPtr if inlined or NULL for DOM behaviour.
206: */
207: xmlEntityPtr
208: getEntityDebug(void *ctx, const xmlChar *name)
209: {
210: fprintf(stdout, "SAX.getEntity(%s)\n", name);
211: return(NULL);
212: }
213:
214: /**
215: * getParameterEntityDebug:
216: * @ctxt: An XML parser context
217: * @name: The entity name
218: *
219: * Get a parameter entity by name
220: *
221: * Returns the xmlParserInputPtr
222: */
223: xmlEntityPtr
224: getParameterEntityDebug(void *ctx, const xmlChar *name)
225: {
226: fprintf(stdout, "SAX.getParameterEntity(%s)\n", name);
227: return(NULL);
228: }
229:
230:
231: /**
232: * entityDeclDebug:
233: * @ctxt: An XML parser context
234: * @name: the entity name
235: * @type: the entity type
236: * @publicId: The public ID of the entity
237: * @systemId: The system ID of the entity
238: * @content: the entity value (without processing).
239: *
240: * An entity definition has been parsed
241: */
242: void
243: entityDeclDebug(void *ctx, const xmlChar *name, int type,
244: const xmlChar *publicId, const xmlChar *systemId, xmlChar *content)
245: {
246: fprintf(stdout, "SAX.entityDecl(%s, %d, %s, %s, %s)\n",
247: name, type, publicId, systemId, content);
248: }
249:
250: /**
251: * attributeDeclDebug:
252: * @ctxt: An XML parser context
253: * @name: the attribute name
254: * @type: the attribute type
255: *
256: * An attribute definition has been parsed
257: */
258: void
259: attributeDeclDebug(void *ctx, const xmlChar *elem, const xmlChar *name,
260: int type, int def, const xmlChar *defaultValue,
261: xmlEnumerationPtr tree)
262: {
263: fprintf(stdout, "SAX.attributeDecl(%s, %s, %d, %d, %s, ...)\n",
264: elem, name, type, def, defaultValue);
265: }
266:
267: /**
268: * elementDeclDebug:
269: * @ctxt: An XML parser context
270: * @name: the element name
271: * @type: the element type
272: * @content: the element value (without processing).
273: *
274: * An element definition has been parsed
275: */
276: void
277: elementDeclDebug(void *ctx, const xmlChar *name, int type,
278: xmlElementContentPtr content)
279: {
280: fprintf(stdout, "SAX.elementDecl(%s, %d, ...)\n",
281: name, type);
282: }
283:
284: /**
285: * notationDeclDebug:
286: * @ctxt: An XML parser context
287: * @name: The name of the notation
288: * @publicId: The public ID of the entity
289: * @systemId: The system ID of the entity
290: *
291: * What to do when a notation declaration has been parsed.
292: */
293: void
294: notationDeclDebug(void *ctx, const xmlChar *name,
295: const xmlChar *publicId, const xmlChar *systemId)
296: {
297: fprintf(stdout, "SAX.notationDecl(%s, %s, %s)\n",
298: (char *) name, (char *) publicId, (char *) systemId);
299: }
300:
301: /**
302: * unparsedEntityDeclDebug:
303: * @ctxt: An XML parser context
304: * @name: The name of the entity
305: * @publicId: The public ID of the entity
306: * @systemId: The system ID of the entity
307: * @notationName: the name of the notation
308: *
309: * What to do when an unparsed entity declaration is parsed
310: */
311: void
312: unparsedEntityDeclDebug(void *ctx, const xmlChar *name,
313: const xmlChar *publicId, const xmlChar *systemId,
314: const xmlChar *notationName)
315: {
316: fprintf(stdout, "SAX.unparsedEntityDecl(%s, %s, %s, %s)\n",
317: (char *) name, (char *) publicId, (char *) systemId,
318: (char *) notationName);
319: }
320:
321: /**
322: * setDocumentLocatorDebug:
323: * @ctxt: An XML parser context
324: * @loc: A SAX Locator
325: *
326: * Receive the document locator at startup, actually xmlDefaultSAXLocator
327: * Everything is available on the context, so this is useless in our case.
328: */
329: void
330: setDocumentLocatorDebug(void *ctx, xmlSAXLocatorPtr loc)
331: {
332: fprintf(stdout, "SAX.setDocumentLocator()\n");
333: }
334:
335: /**
336: * startDocumentDebug:
337: * @ctxt: An XML parser context
338: *
339: * called when the document start being processed.
340: */
341: void
342: startDocumentDebug(void *ctx)
343: {
344: fprintf(stdout, "SAX.startDocument()\n");
345: }
346:
347: /**
348: * endDocumentDebug:
349: * @ctxt: An XML parser context
350: *
351: * called when the document end has been detected.
352: */
353: void
354: endDocumentDebug(void *ctx)
355: {
356: fprintf(stdout, "SAX.endDocument()\n");
357: }
358:
359: /**
360: * startElementDebug:
361: * @ctxt: An XML parser context
362: * @name: The element name
363: *
364: * called when an opening tag has been processed.
365: */
366: void
367: startElementDebug(void *ctx, const xmlChar *name, const xmlChar **atts)
368: {
369: int i;
370:
371: fprintf(stdout, "SAX.startElement(%s", (char *) name);
372: if (atts != NULL) {
373: for (i = 0;(atts[i] != NULL);i++) {
374: fprintf(stdout, ", %s='", atts[i++]);
375: fprintf(stdout, "%s'", atts[i]);
376: }
377: }
378: fprintf(stdout, ")\n");
379: }
380:
381: /**
382: * endElementDebug:
383: * @ctxt: An XML parser context
384: * @name: The element name
385: *
386: * called when the end of an element has been detected.
387: */
388: void
389: endElementDebug(void *ctx, const xmlChar *name)
390: {
391: fprintf(stdout, "SAX.endElement(%s)\n", (char *) name);
392: }
393:
394: /**
395: * charactersDebug:
396: * @ctxt: An XML parser context
397: * @ch: a xmlChar string
398: * @len: the number of xmlChar
399: *
400: * receiving some chars from the parser.
401: * Question: how much at a time ???
402: */
403: void
404: charactersDebug(void *ctx, const xmlChar *ch, int len)
405: {
1.15 ! veillard 406: char output[40];
1.7 daniel 407: int i;
408:
1.15 ! veillard 409: for (i = 0;(i<len) && (i < 30);i++)
! 410: output[i] = ch[i];
! 411: output[i] = 0;
! 412:
! 413: fprintf(stdout, "SAX.characters(%s, %d)\n", output, len);
1.7 daniel 414: }
415:
416: /**
417: * referenceDebug:
418: * @ctxt: An XML parser context
419: * @name: The entity name
420: *
421: * called when an entity reference is detected.
422: */
423: void
424: referenceDebug(void *ctx, const xmlChar *name)
425: {
426: fprintf(stdout, "SAX.reference(%s)\n", name);
427: }
428:
429: /**
430: * ignorableWhitespaceDebug:
431: * @ctxt: An XML parser context
432: * @ch: a xmlChar string
433: * @start: the first char in the string
434: * @len: the number of xmlChar
435: *
436: * receiving some ignorable whitespaces from the parser.
437: * Question: how much at a time ???
438: */
439: void
440: ignorableWhitespaceDebug(void *ctx, const xmlChar *ch, int len)
441: {
1.15 ! veillard 442: char output[40];
! 443: int i;
! 444:
! 445: for (i = 0;(i<len) && (i < 30);i++)
! 446: output[i] = ch[i];
! 447: output[i] = 0;
! 448:
! 449: fprintf(stdout, "SAX.ignorableWhitespace(%s, %d)\n", output, len);
1.7 daniel 450: }
451:
452: /**
453: * processingInstructionDebug:
454: * @ctxt: An XML parser context
455: * @target: the target name
456: * @data: the PI data's
457: * @len: the number of xmlChar
458: *
459: * A processing instruction has been parsed.
460: */
461: void
462: processingInstructionDebug(void *ctx, const xmlChar *target,
463: const xmlChar *data)
464: {
465: fprintf(stdout, "SAX.processingInstruction(%s, %s)\n",
466: (char *) target, (char *) data);
467: }
468:
469: /**
470: * commentDebug:
471: * @ctxt: An XML parser context
472: * @value: the comment content
473: *
474: * A comment has been parsed.
475: */
476: void
477: commentDebug(void *ctx, const xmlChar *value)
478: {
479: fprintf(stdout, "SAX.comment(%s)\n", value);
480: }
481:
482: /**
483: * warningDebug:
484: * @ctxt: An XML parser context
485: * @msg: the message to display/transmit
486: * @...: extra parameters for the message display
487: *
488: * Display and format a warning messages, gives file, line, position and
489: * extra parameters.
490: */
491: void
492: warningDebug(void *ctx, const char *msg, ...)
493: {
494: va_list args;
495:
496: va_start(args, msg);
497: fprintf(stdout, "SAX.warning: ");
498: vfprintf(stdout, msg, args);
499: va_end(args);
500: }
501:
502: /**
503: * errorDebug:
504: * @ctxt: An XML parser context
505: * @msg: the message to display/transmit
506: * @...: extra parameters for the message display
507: *
508: * Display and format a error messages, gives file, line, position and
509: * extra parameters.
510: */
511: void
512: errorDebug(void *ctx, const char *msg, ...)
513: {
514: va_list args;
515:
516: va_start(args, msg);
517: fprintf(stdout, "SAX.error: ");
518: vfprintf(stdout, msg, args);
519: va_end(args);
520: }
521:
522: /**
523: * fatalErrorDebug:
524: * @ctxt: An XML parser context
525: * @msg: the message to display/transmit
526: * @...: extra parameters for the message display
527: *
528: * Display and format a fatalError messages, gives file, line, position and
529: * extra parameters.
530: */
531: void
532: fatalErrorDebug(void *ctx, const char *msg, ...)
533: {
534: va_list args;
535:
536: va_start(args, msg);
537: fprintf(stdout, "SAX.fatalError: ");
538: vfprintf(stdout, msg, args);
539: va_end(args);
540: }
541:
542: xmlSAXHandler debugSAXHandlerStruct = {
543: internalSubsetDebug,
544: isStandaloneDebug,
545: hasInternalSubsetDebug,
546: hasExternalSubsetDebug,
547: resolveEntityDebug,
548: getEntityDebug,
549: entityDeclDebug,
550: notationDeclDebug,
551: attributeDeclDebug,
552: elementDeclDebug,
553: unparsedEntityDeclDebug,
554: setDocumentLocatorDebug,
555: startDocumentDebug,
556: endDocumentDebug,
557: startElementDebug,
558: endElementDebug,
559: referenceDebug,
560: charactersDebug,
561: ignorableWhitespaceDebug,
562: processingInstructionDebug,
563: commentDebug,
564: warningDebug,
565: errorDebug,
566: fatalErrorDebug,
567: getParameterEntityDebug,
568: };
569:
570: xmlSAXHandlerPtr debugSAXHandler = &debugSAXHandlerStruct;
1.1 daniel 571: /************************************************************************
572: * *
573: * Debug *
574: * *
575: ************************************************************************/
576:
1.7 daniel 577: void parseSAXFile(char *filename) {
578: htmlDocPtr doc;
579: /*
580: * Empty callbacks for checking
581: */
1.15 ! veillard 582: if (push) {
! 583: FILE *f;
! 584:
! 585: f = fopen(filename, "r");
! 586: if (f != NULL) {
! 587: int res, size = 3;
! 588: char chars[4096];
! 589: htmlParserCtxtPtr ctxt;
1.7 daniel 590:
1.15 ! veillard 591: /* if (repeat) */
! 592: size = 4096;
! 593: res = fread(chars, 1, 4, f);
! 594: if (res > 0) {
! 595: ctxt = htmlCreatePushParserCtxt(emptySAXHandler, NULL,
! 596: chars, res, filename, 0);
! 597: while ((res = fread(chars, 1, size, f)) > 0) {
! 598: htmlParseChunk(ctxt, chars, res, 0);
! 599: }
! 600: htmlParseChunk(ctxt, chars, 0, 1);
! 601: doc = ctxt->myDoc;
! 602: htmlFreeParserCtxt(ctxt);
! 603: }
! 604: if (doc != NULL) {
! 605: fprintf(stdout, "htmlSAXParseFile returned non-NULL\n");
! 606: xmlFreeDoc(doc);
! 607: }
! 608: fclose(f);
! 609: }
! 610: if (!noout) {
! 611: f = fopen(filename, "r");
! 612: if (f != NULL) {
! 613: int res, size = 3;
! 614: char chars[4096];
! 615: htmlParserCtxtPtr ctxt;
! 616:
! 617: /* if (repeat) */
! 618: size = 4096;
! 619: res = fread(chars, 1, 4, f);
! 620: if (res > 0) {
! 621: ctxt = htmlCreatePushParserCtxt(debugSAXHandler, NULL,
! 622: chars, res, filename, 0);
! 623: while ((res = fread(chars, 1, size, f)) > 0) {
! 624: htmlParseChunk(ctxt, chars, res, 0);
! 625: }
! 626: htmlParseChunk(ctxt, chars, 0, 1);
! 627: doc = ctxt->myDoc;
! 628: htmlFreeParserCtxt(ctxt);
! 629: }
! 630: if (doc != NULL) {
! 631: fprintf(stdout, "htmlSAXParseFile returned non-NULL\n");
! 632: xmlFreeDoc(doc);
! 633: }
! 634: fclose(f);
! 635: }
! 636: }
! 637: } else {
! 638: doc = htmlSAXParseFile(filename, NULL, emptySAXHandler, NULL);
1.7 daniel 639: if (doc != NULL) {
640: fprintf(stdout, "htmlSAXParseFile returned non-NULL\n");
641: xmlFreeDoc(doc);
642: }
1.15 ! veillard 643:
! 644: if (!noout) {
! 645: /*
! 646: * Debug callback
! 647: */
! 648: doc = htmlSAXParseFile(filename, NULL, debugSAXHandler, NULL);
! 649: if (doc != NULL) {
! 650: fprintf(stdout, "htmlSAXParseFile returned non-NULL\n");
! 651: xmlFreeDoc(doc);
! 652: }
! 653: }
1.7 daniel 654: }
655: }
656:
1.1 daniel 657: void parseAndPrintFile(char *filename) {
1.11 daniel 658: htmlDocPtr doc = NULL, tmp;
1.1 daniel 659:
660: /*
661: * build an HTML tree from a string;
662: */
1.10 daniel 663: if (push) {
664: FILE *f;
665:
666: f = fopen(filename, "r");
667: if (f != NULL) {
668: int res, size = 3;
1.14 veillard 669: char chars[4096];
1.10 daniel 670: htmlParserCtxtPtr ctxt;
671:
1.14 veillard 672: /* if (repeat) */
673: size = 4096;
1.10 daniel 674: res = fread(chars, 1, 4, f);
675: if (res > 0) {
676: ctxt = htmlCreatePushParserCtxt(NULL, NULL,
677: chars, res, filename, 0);
678: while ((res = fread(chars, 1, size, f)) > 0) {
679: htmlParseChunk(ctxt, chars, res, 0);
680: }
681: htmlParseChunk(ctxt, chars, 0, 1);
682: doc = ctxt->myDoc;
683: htmlFreeParserCtxt(ctxt);
684: }
1.15 ! veillard 685: fclose(f);
1.10 daniel 686: }
687: } else {
688: doc = htmlParseFile(filename, NULL);
689: }
690: if (doc == NULL) {
691: fprintf(stderr, "Could not parse %s\n", filename);
692: }
1.1 daniel 693:
694: /*
695: * test intermediate copy if needed.
696: */
697: if (copy) {
698: tmp = doc;
699: doc = xmlCopyDoc(doc, 1);
700: xmlFreeDoc(tmp);
701: }
702:
703: /*
704: * print it.
705: */
1.7 daniel 706: if (!noout) {
1.12 daniel 707: #ifdef LIBXML_DEBUG_ENABLED
1.13 veillard 708: if (!debug) {
709: if (encoding)
710: htmlSaveFileEnc("-", doc, encoding);
711: else
712: htmlDocDump(stdout, doc);
713: } else
1.7 daniel 714: xmlDebugDumpDocument(stdout, doc);
1.12 daniel 715: #else
1.13 veillard 716: if (encoding)
717: htmlSaveFileEnc("-", doc, encoding);
718: else
719: htmlDocDump(stdout, doc);
1.12 daniel 720: #endif
1.7 daniel 721: }
1.1 daniel 722:
723: /*
724: * free it.
725: */
726: xmlFreeDoc(doc);
727: }
728:
729: int main(int argc, char **argv) {
1.7 daniel 730: int i, count;
1.1 daniel 731: int files = 0;
732:
733: for (i = 1; i < argc ; i++) {
1.12 daniel 734: #ifdef LIBXML_DEBUG_ENABLED
1.1 daniel 735: if ((!strcmp(argv[i], "-debug")) || (!strcmp(argv[i], "--debug")))
736: debug++;
1.12 daniel 737: else
738: #endif
739: if ((!strcmp(argv[i], "-copy")) || (!strcmp(argv[i], "--copy")))
1.1 daniel 740: copy++;
1.10 daniel 741: else if ((!strcmp(argv[i], "-push")) || (!strcmp(argv[i], "--push")))
742: push++;
1.7 daniel 743: else if ((!strcmp(argv[i], "-sax")) || (!strcmp(argv[i], "--sax")))
744: sax++;
745: else if ((!strcmp(argv[i], "-noout")) || (!strcmp(argv[i], "--noout")))
746: noout++;
747: else if ((!strcmp(argv[i], "-repeat")) ||
748: (!strcmp(argv[i], "--repeat")))
749: repeat++;
1.13 veillard 750: else if ((!strcmp(argv[i], "-encode")) ||
751: (!strcmp(argv[i], "--encode"))) {
752: i++;
753: encoding = argv[i];
754: }
1.1 daniel 755: }
756: for (i = 1; i < argc ; i++) {
1.13 veillard 757: if ((!strcmp(argv[i], "-encode")) ||
758: (!strcmp(argv[i], "--encode"))) {
759: i++;
760: continue;
761: }
1.1 daniel 762: if (argv[i][0] != '-') {
1.7 daniel 763: if (repeat) {
764: for (count = 0;count < 100 * repeat;count++) {
765: if (sax)
766: parseSAXFile(argv[i]);
767: else
768: parseAndPrintFile(argv[i]);
769: }
770: } else {
771: if (sax)
772: parseSAXFile(argv[i]);
773: else
774: parseAndPrintFile(argv[i]);
775: }
1.1 daniel 776: files ++;
777: }
778: }
779: if (files == 0) {
1.7 daniel 780: printf("Usage : %s [--debug] [--copy] [--copy] HTMLfiles ...\n",
1.1 daniel 781: argv[0]);
782: printf("\tParse the HTML files and output the result of the parsing\n");
1.12 daniel 783: #ifdef LIBXML_DEBUG_ENABLED
1.1 daniel 784: printf("\t--debug : dump a debug tree of the in-memory document\n");
1.12 daniel 785: #endif
1.1 daniel 786: printf("\t--copy : used to test the internal copy implementation\n");
1.7 daniel 787: printf("\t--sax : debug the sequence of SAX callbacks\n");
1.10 daniel 788: printf("\t--repeat : parse the file 100 times, for timing\n");
1.7 daniel 789: printf("\t--noout : do not print the result\n");
1.10 daniel 790: printf("\t--push : use the push mode parser\n");
1.13 veillard 791: printf("\t--encode encoding : output in the given encoding\n");
1.1 daniel 792: }
1.8 daniel 793: xmlCleanupParser();
1.6 daniel 794: xmlMemoryDump();
1.1 daniel 795:
796: return(0);
797: }
1.12 daniel 798: #else /* !LIBXML_HTML_ENABLED */
799: #include <stdio.h>
800: int main(int argc, char **argv) {
801: printf("%s : HTML support not compiled in\n", argv[0]);
802: return(0);
803: }
804: #endif
Webmaster