blob: e159ec63976a470c82632264b0bdc169fbdcfe5f [file] [log] [blame]
Daniel Veillardce8b83b2000-04-05 18:38:42 +00001/*
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
Bjorn Reese70a9da52001-04-21 16:57:29 +00009#include "libxml.h"
Daniel Veillardce8b83b2000-04-05 18:38:42 +000010
Daniel Veillardce8b83b2000-04-05 18:38:42 +000011#include <string.h>
Daniel Veillardce8b83b2000-04-05 18:38:42 +000012#include <stdarg.h>
Daniel Veillard2d90de42001-04-16 17:46:18 +000013#ifdef _WIN32
14#ifdef _MSC_VER
15#include <winsock2.h>
16#pragma comment(lib, "ws2_32.lib")
17#define gettimeofday(p1,p2)
18#endif /* _MSC_VER */
19#else /* _WIN32 */
Daniel Veillard48b2f892001-02-25 16:11:03 +000020#include <sys/time.h>
Daniel Veillard2d90de42001-04-16 17:46:18 +000021#endif /* _WIN32 */
Daniel Veillard48b2f892001-02-25 16:11:03 +000022
Daniel Veillardce8b83b2000-04-05 18:38:42 +000023
24#ifdef HAVE_SYS_TYPES_H
25#include <sys/types.h>
26#endif
27#ifdef HAVE_SYS_STAT_H
28#include <sys/stat.h>
29#endif
30#ifdef HAVE_FCNTL_H
31#include <fcntl.h>
32#endif
33#ifdef HAVE_UNISTD_H
34#include <unistd.h>
35#endif
Daniel Veillard46e370e2000-07-21 20:32:03 +000036#ifdef HAVE_SYS_MMAN_H
37#include <sys/mman.h>
Daniel Veillard87b95392000-08-12 21:12:04 +000038/* seems needed for Solaris */
39#ifndef MAP_FAILED
40#define MAP_FAILED ((void *) -1)
41#endif
Daniel Veillard46e370e2000-07-21 20:32:03 +000042#endif
Daniel Veillardce8b83b2000-04-05 18:38:42 +000043#ifdef HAVE_STDLIB_H
44#include <stdlib.h>
45#endif
46#ifdef HAVE_LIBREADLINE
47#include <readline/readline.h>
48#ifdef HAVE_LIBHISTORY
49#include <readline/history.h>
50#endif
51#endif
52
53#include <libxml/xmlmemory.h>
54#include <libxml/parser.h>
55#include <libxml/parserInternals.h>
56#include <libxml/HTMLparser.h>
57#include <libxml/HTMLtree.h>
58#include <libxml/tree.h>
59#include <libxml/xpath.h>
60#include <libxml/debugXML.h>
Daniel Veillardd6d7f7b2000-10-25 19:56:55 +000061#include <libxml/xmlerror.h>
Daniel Veillard9e8bfae2000-11-06 16:43:11 +000062#ifdef LIBXML_XINCLUDE_ENABLED
63#include <libxml/xinclude.h>
64#endif
Daniel Veillard81418e32001-05-22 15:08:55 +000065#ifdef LIBXML_CATALOG_ENABLED
66#include <libxml/catalog.h>
67#endif
Daniel Veillardce8b83b2000-04-05 18:38:42 +000068
69#ifdef LIBXML_DEBUG_ENABLED
70static int debug = 0;
71static int shell = 0;
72static int debugent = 0;
73#endif
74static int copy = 0;
75static int recovery = 0;
76static int noent = 0;
77static int noout = 0;
78static int nowrap = 0;
79static int valid = 0;
80static int postvalid = 0;
Daniel Veillardcd429612000-10-11 15:57:05 +000081static char * dtdvalid = NULL;
Daniel Veillardce8b83b2000-04-05 18:38:42 +000082static int repeat = 0;
83static int insert = 0;
84static int compress = 0;
85static int html = 0;
86static int htmlout = 0;
87static int push = 0;
Daniel Veillard46e370e2000-07-21 20:32:03 +000088#ifdef HAVE_SYS_MMAN_H
89static int memory = 0;
90#endif
Daniel Veillardce8b83b2000-04-05 18:38:42 +000091static int noblanks = 0;
Daniel Veillard5e873c42000-04-12 13:27:38 +000092static int testIO = 0;
Daniel Veillardbe803962000-06-28 23:40:59 +000093static char *encoding = NULL;
Daniel Veillard9e8bfae2000-11-06 16:43:11 +000094#ifdef LIBXML_XINCLUDE_ENABLED
95static int xinclude = 0;
96#endif
Daniel Veillardf7cd4812001-02-23 18:44:52 +000097static int progresult = 0;
Daniel Veillard48b2f892001-02-25 16:11:03 +000098static int timing = 0;
Daniel Veillardd2f3ec72001-04-11 07:50:02 +000099static int generate = 0;
Daniel Veillard48b2f892001-02-25 16:11:03 +0000100static struct timeval begin, end;
Daniel Veillardce8b83b2000-04-05 18:38:42 +0000101
Daniel Veillardce6e98d2000-11-25 09:54:49 +0000102
103#ifdef VMS
104extern int xmlDoValidityCheckingDefaultVal;
105#define xmlDoValidityCheckingDefaultValue xmlDoValidityCheckingDefaultVal
106#else
Daniel Veillardce8b83b2000-04-05 18:38:42 +0000107extern int xmlDoValidityCheckingDefaultValue;
Daniel Veillardce6e98d2000-11-25 09:54:49 +0000108#endif
Daniel Veillardce8b83b2000-04-05 18:38:42 +0000109extern int xmlGetWarningsDefaultValue;
110
111/************************************************************************
112 * *
113 * HTML ouput *
114 * *
115 ************************************************************************/
116char buffer[50000];
117
Daniel Veillard56a4cb82001-03-24 17:00:36 +0000118static void
Daniel Veillardce8b83b2000-04-05 18:38:42 +0000119xmlHTMLEncodeSend(void) {
120 char *result;
121
122 result = (char *) xmlEncodeEntitiesReentrant(NULL, BAD_CAST buffer);
123 if (result) {
Daniel Veillardd6d7f7b2000-10-25 19:56:55 +0000124 xmlGenericError(xmlGenericErrorContext, "%s", result);
Daniel Veillardce8b83b2000-04-05 18:38:42 +0000125 xmlFree(result);
126 }
127 buffer[0] = 0;
128}
129
130/**
131 * xmlHTMLPrintFileInfo:
132 * @input: an xmlParserInputPtr input
133 *
134 * Displays the associated file and line informations for the current input
135 */
136
Daniel Veillard56a4cb82001-03-24 17:00:36 +0000137static void
Daniel Veillardce8b83b2000-04-05 18:38:42 +0000138xmlHTMLPrintFileInfo(xmlParserInputPtr input) {
Daniel Veillardd6d7f7b2000-10-25 19:56:55 +0000139 xmlGenericError(xmlGenericErrorContext, "<p>");
Daniel Veillardce8b83b2000-04-05 18:38:42 +0000140 if (input != NULL) {
141 if (input->filename) {
142 sprintf(&buffer[strlen(buffer)], "%s:%d: ", input->filename,
143 input->line);
144 } else {
145 sprintf(&buffer[strlen(buffer)], "Entity: line %d: ", input->line);
146 }
147 }
148 xmlHTMLEncodeSend();
149}
150
151/**
152 * xmlHTMLPrintFileContext:
153 * @input: an xmlParserInputPtr input
154 *
155 * Displays current context within the input content for error tracking
156 */
157
Daniel Veillard56a4cb82001-03-24 17:00:36 +0000158static void
Daniel Veillardce8b83b2000-04-05 18:38:42 +0000159xmlHTMLPrintFileContext(xmlParserInputPtr input) {
160 const xmlChar *cur, *base;
161 int n;
162
163 if (input == NULL) return;
Daniel Veillardd6d7f7b2000-10-25 19:56:55 +0000164 xmlGenericError(xmlGenericErrorContext, "<pre>\n");
Daniel Veillardce8b83b2000-04-05 18:38:42 +0000165 cur = input->cur;
166 base = input->base;
167 while ((cur > base) && ((*cur == '\n') || (*cur == '\r'))) {
168 cur--;
169 }
170 n = 0;
171 while ((n++ < 80) && (cur > base) && (*cur != '\n') && (*cur != '\r'))
172 cur--;
173 if ((*cur == '\n') || (*cur == '\r')) cur++;
174 base = cur;
175 n = 0;
176 while ((*cur != 0) && (*cur != '\n') && (*cur != '\r') && (n < 79)) {
177 sprintf(&buffer[strlen(buffer)], "%c", (unsigned char) *cur++);
178 n++;
179 }
180 sprintf(&buffer[strlen(buffer)], "\n");
181 cur = input->cur;
182 while ((*cur == '\n') || (*cur == '\r'))
183 cur--;
184 n = 0;
185 while ((cur != base) && (n++ < 80)) {
186 sprintf(&buffer[strlen(buffer)], " ");
187 base++;
188 }
189 sprintf(&buffer[strlen(buffer)],"^\n");
190 xmlHTMLEncodeSend();
Daniel Veillardd6d7f7b2000-10-25 19:56:55 +0000191 xmlGenericError(xmlGenericErrorContext, "</pre>");
Daniel Veillardce8b83b2000-04-05 18:38:42 +0000192}
193
194/**
195 * xmlHTMLError:
196 * @ctx: an XML parser context
197 * @msg: the message to display/transmit
198 * @...: extra parameters for the message display
199 *
200 * Display and format an error messages, gives file, line, position and
201 * extra parameters.
202 */
Daniel Veillard56a4cb82001-03-24 17:00:36 +0000203static void
Daniel Veillardce8b83b2000-04-05 18:38:42 +0000204xmlHTMLError(void *ctx, const char *msg, ...)
205{
206 xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
207 xmlParserInputPtr input;
208 xmlParserInputPtr cur = NULL;
209 va_list args;
210
211 buffer[0] = 0;
212 input = ctxt->input;
213 if ((input != NULL) && (input->filename == NULL) && (ctxt->inputNr > 1)) {
214 cur = input;
215 input = ctxt->inputTab[ctxt->inputNr - 2];
216 }
217
218 xmlHTMLPrintFileInfo(input);
219
Daniel Veillardd6d7f7b2000-10-25 19:56:55 +0000220 xmlGenericError(xmlGenericErrorContext, "<b>error</b>: ");
Daniel Veillardce8b83b2000-04-05 18:38:42 +0000221 va_start(args, msg);
222 vsprintf(&buffer[strlen(buffer)], msg, args);
223 va_end(args);
224 xmlHTMLEncodeSend();
Daniel Veillardd6d7f7b2000-10-25 19:56:55 +0000225 xmlGenericError(xmlGenericErrorContext, "</p>\n");
Daniel Veillardce8b83b2000-04-05 18:38:42 +0000226
227 xmlHTMLPrintFileContext(input);
228 xmlHTMLEncodeSend();
229}
230
231/**
232 * xmlHTMLWarning:
233 * @ctx: an XML parser context
234 * @msg: the message to display/transmit
235 * @...: extra parameters for the message display
236 *
237 * Display and format a warning messages, gives file, line, position and
238 * extra parameters.
239 */
Daniel Veillard56a4cb82001-03-24 17:00:36 +0000240static void
Daniel Veillardce8b83b2000-04-05 18:38:42 +0000241xmlHTMLWarning(void *ctx, const char *msg, ...)
242{
243 xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
244 xmlParserInputPtr input;
245 xmlParserInputPtr cur = NULL;
246 va_list args;
247
248 buffer[0] = 0;
249 input = ctxt->input;
250 if ((input != NULL) && (input->filename == NULL) && (ctxt->inputNr > 1)) {
251 cur = input;
252 input = ctxt->inputTab[ctxt->inputNr - 2];
253 }
254
255
256 xmlHTMLPrintFileInfo(input);
257
Daniel Veillardd6d7f7b2000-10-25 19:56:55 +0000258 xmlGenericError(xmlGenericErrorContext, "<b>warning</b>: ");
Daniel Veillardce8b83b2000-04-05 18:38:42 +0000259 va_start(args, msg);
260 vsprintf(&buffer[strlen(buffer)], msg, args);
261 va_end(args);
262 xmlHTMLEncodeSend();
Daniel Veillardd6d7f7b2000-10-25 19:56:55 +0000263 xmlGenericError(xmlGenericErrorContext, "</p>\n");
Daniel Veillardce8b83b2000-04-05 18:38:42 +0000264
265 xmlHTMLPrintFileContext(input);
266 xmlHTMLEncodeSend();
267}
268
269/**
270 * xmlHTMLValidityError:
271 * @ctx: an XML parser context
272 * @msg: the message to display/transmit
273 * @...: extra parameters for the message display
274 *
275 * Display and format an validity error messages, gives file,
276 * line, position and extra parameters.
277 */
Daniel Veillard56a4cb82001-03-24 17:00:36 +0000278static void
Daniel Veillardce8b83b2000-04-05 18:38:42 +0000279xmlHTMLValidityError(void *ctx, const char *msg, ...)
280{
281 xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
282 xmlParserInputPtr input;
283 va_list args;
284
285 buffer[0] = 0;
286 input = ctxt->input;
287 if ((input->filename == NULL) && (ctxt->inputNr > 1))
288 input = ctxt->inputTab[ctxt->inputNr - 2];
289
290 xmlHTMLPrintFileInfo(input);
291
Daniel Veillardd6d7f7b2000-10-25 19:56:55 +0000292 xmlGenericError(xmlGenericErrorContext, "<b>validity error</b>: ");
Daniel Veillardce8b83b2000-04-05 18:38:42 +0000293 va_start(args, msg);
294 vsprintf(&buffer[strlen(buffer)], msg, args);
295 va_end(args);
296 xmlHTMLEncodeSend();
Daniel Veillardd6d7f7b2000-10-25 19:56:55 +0000297 xmlGenericError(xmlGenericErrorContext, "</p>\n");
Daniel Veillardce8b83b2000-04-05 18:38:42 +0000298
299 xmlHTMLPrintFileContext(input);
300 xmlHTMLEncodeSend();
301}
302
303/**
304 * xmlHTMLValidityWarning:
305 * @ctx: an XML parser context
306 * @msg: the message to display/transmit
307 * @...: extra parameters for the message display
308 *
309 * Display and format a validity warning messages, gives file, line,
310 * position and extra parameters.
311 */
Daniel Veillard56a4cb82001-03-24 17:00:36 +0000312static void
Daniel Veillardce8b83b2000-04-05 18:38:42 +0000313xmlHTMLValidityWarning(void *ctx, const char *msg, ...)
314{
315 xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
316 xmlParserInputPtr input;
317 va_list args;
318
319 buffer[0] = 0;
320 input = ctxt->input;
321 if ((input->filename == NULL) && (ctxt->inputNr > 1))
322 input = ctxt->inputTab[ctxt->inputNr - 2];
323
324 xmlHTMLPrintFileInfo(input);
325
Daniel Veillardd6d7f7b2000-10-25 19:56:55 +0000326 xmlGenericError(xmlGenericErrorContext, "<b>validity warning</b>: ");
Daniel Veillardce8b83b2000-04-05 18:38:42 +0000327 va_start(args, msg);
328 vsprintf(&buffer[strlen(buffer)], msg, args);
329 va_end(args);
330 xmlHTMLEncodeSend();
Daniel Veillardd6d7f7b2000-10-25 19:56:55 +0000331 xmlGenericError(xmlGenericErrorContext, "</p>\n");
Daniel Veillardce8b83b2000-04-05 18:38:42 +0000332
333 xmlHTMLPrintFileContext(input);
334 xmlHTMLEncodeSend();
335}
336
337/************************************************************************
338 * *
339 * Shell Interface *
340 * *
341 ************************************************************************/
342/**
343 * xmlShellReadline:
344 * @prompt: the prompt value
345 *
346 * Read a string
347 *
348 * Returns a pointer to it or NULL on EOF the caller is expected to
349 * free the returned string.
350 */
Daniel Veillard56a4cb82001-03-24 17:00:36 +0000351static char *
Daniel Veillardce8b83b2000-04-05 18:38:42 +0000352xmlShellReadline(char *prompt) {
353#ifdef HAVE_LIBREADLINE
354 char *line_read;
355
356 /* Get a line from the user. */
357 line_read = readline (prompt);
358
359 /* If the line has any text in it, save it on the history. */
360 if (line_read && *line_read)
361 add_history (line_read);
362
363 return (line_read);
364#else
365 char line_read[501];
366
367 if (prompt != NULL)
368 fprintf(stdout, "%s", prompt);
369 if (!fgets(line_read, 500, stdin))
370 return(NULL);
371 line_read[500] = 0;
372 return(strdup(line_read));
373#endif
374}
375
376/************************************************************************
377 * *
Daniel Veillard5e873c42000-04-12 13:27:38 +0000378 * I/O Interfaces *
379 * *
380 ************************************************************************/
381
Daniel Veillard56a4cb82001-03-24 17:00:36 +0000382static int myRead(FILE *f, char * buf, int len) {
383 return(fread(buf, 1, len, f));
Daniel Veillard5e873c42000-04-12 13:27:38 +0000384}
Daniel Veillard56a4cb82001-03-24 17:00:36 +0000385static void myClose(FILE *f) {
Daniel Veillard4a6845d2001-01-03 13:32:39 +0000386 if (f != stdin) {
Daniel Veillard5e873c42000-04-12 13:27:38 +0000387 fclose(f);
Daniel Veillard4a6845d2001-01-03 13:32:39 +0000388 }
Daniel Veillard5e873c42000-04-12 13:27:38 +0000389}
390
391/************************************************************************
392 * *
Daniel Veillardce8b83b2000-04-05 18:38:42 +0000393 * Test processing *
394 * *
395 ************************************************************************/
Daniel Veillard56a4cb82001-03-24 17:00:36 +0000396static void parseAndPrintFile(char *filename) {
Daniel Veillardce8b83b2000-04-05 18:38:42 +0000397 xmlDocPtr doc = NULL, tmp;
398
Daniel Veillard48b2f892001-02-25 16:11:03 +0000399 if ((timing) && (!repeat))
400 gettimeofday(&begin, NULL);
401
402
Daniel Veillardd2f3ec72001-04-11 07:50:02 +0000403 if (filename == NULL) {
404 if (generate) {
405 xmlNodePtr n;
406
407 doc = xmlNewDoc(BAD_CAST "1.0");
408 n = xmlNewNode(NULL, BAD_CAST "info");
409 xmlNodeSetContent(n, BAD_CAST "abc");
410 xmlDocSetRootElement(doc, n);
411 }
412 }
Daniel Veillardce8b83b2000-04-05 18:38:42 +0000413#ifdef LIBXML_HTML_ENABLED
Daniel Veillardd2f3ec72001-04-11 07:50:02 +0000414 else if (html) {
Daniel Veillardce8b83b2000-04-05 18:38:42 +0000415 doc = htmlParseFile(filename, NULL);
Daniel Veillardd2f3ec72001-04-11 07:50:02 +0000416 }
Daniel Veillardce8b83b2000-04-05 18:38:42 +0000417#endif /* LIBXML_HTML_ENABLED */
Daniel Veillardd2f3ec72001-04-11 07:50:02 +0000418 else {
Daniel Veillardce8b83b2000-04-05 18:38:42 +0000419 /*
420 * build an XML tree from a string;
421 */
422 if (push) {
423 FILE *f;
424
Daniel Veillard4a6845d2001-01-03 13:32:39 +0000425 /* '-' Usually means stdin -<sven@zen.org> */
426 if ((filename[0] == '-') && (filename[1] == 0)) {
427 f = stdin;
428 } else {
429 f = fopen(filename, "r");
430 }
Daniel Veillardce8b83b2000-04-05 18:38:42 +0000431 if (f != NULL) {
Daniel Veillarde715dd22000-08-29 18:29:38 +0000432 int ret;
Daniel Veillardce8b83b2000-04-05 18:38:42 +0000433 int res, size = 3;
434 char chars[1024];
435 xmlParserCtxtPtr ctxt;
436
437 if (repeat)
438 size = 1024;
439 res = fread(chars, 1, 4, f);
440 if (res > 0) {
441 ctxt = xmlCreatePushParserCtxt(NULL, NULL,
442 chars, res, filename);
443 while ((res = fread(chars, 1, size, f)) > 0) {
444 xmlParseChunk(ctxt, chars, res, 0);
445 }
446 xmlParseChunk(ctxt, chars, 0, 1);
447 doc = ctxt->myDoc;
Daniel Veillarde715dd22000-08-29 18:29:38 +0000448 ret = ctxt->wellFormed;
Daniel Veillardce8b83b2000-04-05 18:38:42 +0000449 xmlFreeParserCtxt(ctxt);
Daniel Veillarde715dd22000-08-29 18:29:38 +0000450 if (!ret) {
451 xmlFreeDoc(doc);
452 doc = NULL;
453 }
Daniel Veillardce8b83b2000-04-05 18:38:42 +0000454 }
455 }
Daniel Veillard5e873c42000-04-12 13:27:38 +0000456 } else if (testIO) {
457 int ret;
458 FILE *f;
459
Daniel Veillard4a6845d2001-01-03 13:32:39 +0000460 /* '-' Usually means stdin -<sven@zen.org> */
461 if ((filename[0] == '-') && (filename[1] == 0)) {
462 f = stdin;
463 } else {
464 f = fopen(filename, "r");
465 }
Daniel Veillard5e873c42000-04-12 13:27:38 +0000466 if (f != NULL) {
467 xmlParserCtxtPtr ctxt;
468
469 ctxt = xmlCreateIOParserCtxt(NULL, NULL,
470 (xmlInputReadCallback) myRead,
471 (xmlInputCloseCallback) myClose,
472 f, XML_CHAR_ENCODING_NONE);
473 xmlParseDocument(ctxt);
474
475 ret = ctxt->wellFormed;
476 doc = ctxt->myDoc;
477 xmlFreeParserCtxt(ctxt);
478 if (!ret) {
479 xmlFreeDoc(doc);
480 doc = NULL;
481 }
482 }
Daniel Veillardce8b83b2000-04-05 18:38:42 +0000483 } else if (recovery) {
484 doc = xmlRecoverFile(filename);
485 } else if (htmlout) {
486 int ret;
487 xmlParserCtxtPtr ctxt;
488 xmlSAXHandler silent, *old;
489
490 ctxt = xmlCreateFileParserCtxt(filename);
Daniel Veillard88a172f2000-08-04 18:23:10 +0000491
492 if (ctxt == NULL) {
493 /* If xmlCreateFileParseCtxt() return NULL something
494 strange happened so we don't want to do anything. Do
495 we want to print an error message here?
496 <sven@zen.org> */
Daniel Veillard7ebb1ee2000-08-04 18:24:45 +0000497 doc = NULL;
Daniel Veillard88a172f2000-08-04 18:23:10 +0000498 } else {
499 memcpy(&silent, ctxt->sax, sizeof(silent));
500 old = ctxt->sax;
501 silent.error = xmlHTMLError;
502 if (xmlGetWarningsDefaultValue)
Daniel Veillardce8b83b2000-04-05 18:38:42 +0000503 silent.warning = xmlHTMLWarning;
Daniel Veillard88a172f2000-08-04 18:23:10 +0000504 else
Daniel Veillardce8b83b2000-04-05 18:38:42 +0000505 silent.warning = NULL;
Daniel Veillard88a172f2000-08-04 18:23:10 +0000506 silent.fatalError = xmlHTMLError;
507 ctxt->sax = &silent;
508 ctxt->vctxt.error = xmlHTMLValidityError;
509 if (xmlGetWarningsDefaultValue)
Daniel Veillardce8b83b2000-04-05 18:38:42 +0000510 ctxt->vctxt.warning = xmlHTMLValidityWarning;
Daniel Veillard88a172f2000-08-04 18:23:10 +0000511 else
Daniel Veillardce8b83b2000-04-05 18:38:42 +0000512 ctxt->vctxt.warning = NULL;
513
Daniel Veillard88a172f2000-08-04 18:23:10 +0000514 xmlParseDocument(ctxt);
Daniel Veillardce8b83b2000-04-05 18:38:42 +0000515
Daniel Veillard88a172f2000-08-04 18:23:10 +0000516 ret = ctxt->wellFormed;
517 doc = ctxt->myDoc;
518 ctxt->sax = old;
519 xmlFreeParserCtxt(ctxt);
520 if (!ret) {
Daniel Veillardce8b83b2000-04-05 18:38:42 +0000521 xmlFreeDoc(doc);
522 doc = NULL;
Daniel Veillard88a172f2000-08-04 18:23:10 +0000523 }
Daniel Veillardce8b83b2000-04-05 18:38:42 +0000524 }
Daniel Veillard46e370e2000-07-21 20:32:03 +0000525#ifdef HAVE_SYS_MMAN_H
526 } else if (memory) {
527 int fd;
528 struct stat info;
529 const char *base;
530 if (stat(filename, &info) < 0)
531 return;
532 if ((fd = open(filename, O_RDONLY)) < 0)
533 return;
534 base = mmap(NULL, info.st_size, PROT_READ, MAP_SHARED, fd, 0) ;
Daniel Veillard29579362000-08-14 17:57:48 +0000535 if (base == (void *) MAP_FAILED)
Daniel Veillard46e370e2000-07-21 20:32:03 +0000536 return;
537
538 doc = xmlParseMemory((char *) base, info.st_size);
539 munmap((char *) base, info.st_size);
540#endif
Daniel Veillardce8b83b2000-04-05 18:38:42 +0000541 } else
542 doc = xmlParseFile(filename);
Daniel Veillardce8b83b2000-04-05 18:38:42 +0000543 }
Daniel Veillardce8b83b2000-04-05 18:38:42 +0000544
Daniel Veillard88a172f2000-08-04 18:23:10 +0000545 /*
546 * If we don't have a document we might as well give up. Do we
547 * want an error message here? <sven@zen.org> */
Daniel Veillard9e8bfae2000-11-06 16:43:11 +0000548 if (doc == NULL) {
Daniel Veillardf7cd4812001-02-23 18:44:52 +0000549 progresult = 1;
Daniel Veillard88a172f2000-08-04 18:23:10 +0000550 return;
Daniel Veillard9e8bfae2000-11-06 16:43:11 +0000551 }
552
Daniel Veillard48b2f892001-02-25 16:11:03 +0000553 if ((timing) && (!repeat)) {
554 long msec;
555 gettimeofday(&end, NULL);
556 msec = end.tv_sec - begin.tv_sec;
557 msec *= 1000;
558 msec += (end.tv_usec - begin.tv_usec) / 1000;
559 fprintf(stderr, "Parsing took %ld ms\n", msec);
560 }
561
Daniel Veillard9e8bfae2000-11-06 16:43:11 +0000562#ifdef LIBXML_XINCLUDE_ENABLED
Daniel Veillard48b2f892001-02-25 16:11:03 +0000563 if (xinclude) {
564 if ((timing) && (!repeat)) {
565 gettimeofday(&begin, NULL);
566 }
Daniel Veillard9e8bfae2000-11-06 16:43:11 +0000567 xmlXIncludeProcess(doc);
Daniel Veillard48b2f892001-02-25 16:11:03 +0000568 if ((timing) && (!repeat)) {
569 long msec;
570 gettimeofday(&end, NULL);
571 msec = end.tv_sec - begin.tv_sec;
572 msec *= 1000;
573 msec += (end.tv_usec - begin.tv_usec) / 1000;
574 fprintf(stderr, "Xinclude processing took %ld ms\n", msec);
575 }
576 }
Daniel Veillard9e8bfae2000-11-06 16:43:11 +0000577#endif
Daniel Veillard88a172f2000-08-04 18:23:10 +0000578
Daniel Veillardce8b83b2000-04-05 18:38:42 +0000579#ifdef LIBXML_DEBUG_ENABLED
580 /*
581 * shell interraction
582 */
583 if (shell)
584 xmlShell(doc, filename, xmlShellReadline, stdout);
585#endif
586
587 /*
588 * test intermediate copy if needed.
589 */
590 if (copy) {
591 tmp = doc;
592 doc = xmlCopyDoc(doc, 1);
593 xmlFreeDoc(tmp);
594 }
595
596 if ((insert) && (!html)) {
597 const xmlChar* list[256];
598 int nb, i;
599 xmlNodePtr node;
600
601 if (doc->children != NULL) {
602 node = doc->children;
603 while ((node != NULL) && (node->last == NULL)) node = node->next;
604 if (node != NULL) {
605 nb = xmlValidGetValidElements(node->last, NULL, list, 256);
606 if (nb < 0) {
607 printf("could not get valid list of elements\n");
608 } else if (nb == 0) {
609 printf("No element can be indersted under root\n");
610 } else {
611 printf("%d element types can be indersted under root:\n",
612 nb);
613 for (i = 0;i < nb;i++) {
614 printf("%s\n", list[i]);
615 }
616 }
617 }
618 }
619 }else if (noout == 0) {
620 /*
621 * print it.
622 */
623#ifdef LIBXML_DEBUG_ENABLED
624 if (!debug) {
625#endif
Daniel Veillard48b2f892001-02-25 16:11:03 +0000626 if ((timing) && (!repeat)) {
627 gettimeofday(&begin, NULL);
628 }
Daniel Veillard3b2c2612001-04-04 00:09:00 +0000629#ifdef HAVE_SYS_MMAN_H
Daniel Veillarda6d8eb62000-12-27 10:46:47 +0000630 if (memory) {
631 xmlChar *result;
632 int len;
633
634 if (encoding != NULL) {
635 xmlDocDumpMemoryEnc(doc, &result, &len, encoding);
636 } else {
637 xmlDocDumpMemory(doc, &result, &len);
638 }
639 if (result == NULL) {
640 fprintf(stderr, "Failed to save\n");
641 } else {
642 write(1, result, len);
643 xmlFree(result);
644 }
Daniel Veillard3b2c2612001-04-04 00:09:00 +0000645 } else
646#endif /* HAVE_SYS_MMAN_H */
647 if (compress)
Daniel Veillardce8b83b2000-04-05 18:38:42 +0000648 xmlSaveFile("-", doc);
Daniel Veillardbe803962000-06-28 23:40:59 +0000649 else if (encoding != NULL)
650 xmlSaveFileEnc("-", doc, encoding);
Daniel Veillardce8b83b2000-04-05 18:38:42 +0000651 else
652 xmlDocDump(stdout, doc);
Daniel Veillard48b2f892001-02-25 16:11:03 +0000653 if ((timing) && (!repeat)) {
654 long msec;
655 gettimeofday(&end, NULL);
656 msec = end.tv_sec - begin.tv_sec;
657 msec *= 1000;
658 msec += (end.tv_usec - begin.tv_usec) / 1000;
659 fprintf(stderr, "Saving took %ld ms\n", msec);
660 }
Daniel Veillardce8b83b2000-04-05 18:38:42 +0000661#ifdef LIBXML_DEBUG_ENABLED
Daniel Veillarda6d8eb62000-12-27 10:46:47 +0000662 } else {
Daniel Veillardce8b83b2000-04-05 18:38:42 +0000663 xmlDebugDumpDocument(stdout, doc);
Daniel Veillarda6d8eb62000-12-27 10:46:47 +0000664 }
Daniel Veillardce8b83b2000-04-05 18:38:42 +0000665#endif
666 }
667
668 /*
669 * A posteriori validation test
670 */
Daniel Veillardcd429612000-10-11 15:57:05 +0000671 if (dtdvalid != NULL) {
672 xmlDtdPtr dtd;
673
Daniel Veillard48b2f892001-02-25 16:11:03 +0000674 if ((timing) && (!repeat)) {
675 gettimeofday(&begin, NULL);
676 }
Daniel Veillardcd429612000-10-11 15:57:05 +0000677 dtd = xmlParseDTD(NULL, (const xmlChar *)dtdvalid);
Daniel Veillard48b2f892001-02-25 16:11:03 +0000678 if ((timing) && (!repeat)) {
679 long msec;
680 gettimeofday(&end, NULL);
681 msec = end.tv_sec - begin.tv_sec;
682 msec *= 1000;
683 msec += (end.tv_usec - begin.tv_usec) / 1000;
684 fprintf(stderr, "Parsing DTD took %ld ms\n", msec);
685 }
Daniel Veillardcd429612000-10-11 15:57:05 +0000686 if (dtd == NULL) {
Daniel Veillardd6d7f7b2000-10-25 19:56:55 +0000687 xmlGenericError(xmlGenericErrorContext,
688 "Could not parse DTD %s\n", dtdvalid);
Daniel Veillardf7cd4812001-02-23 18:44:52 +0000689 progresult = 2;
Daniel Veillardcd429612000-10-11 15:57:05 +0000690 } else {
691 xmlValidCtxt cvp;
Daniel Veillard48b2f892001-02-25 16:11:03 +0000692 if ((timing) && (!repeat)) {
693 gettimeofday(&begin, NULL);
694 }
Daniel Veillardcd429612000-10-11 15:57:05 +0000695 cvp.userData = (void *) stderr; cvp.error = (xmlValidityErrorFunc) fprintf; cvp.warning = (xmlValidityWarningFunc) fprintf;
696 if (!xmlValidateDtd(&cvp, doc, dtd)) {
Daniel Veillardd6d7f7b2000-10-25 19:56:55 +0000697 xmlGenericError(xmlGenericErrorContext,
698 "Document %s does not validate against %s\n",
Daniel Veillardcd429612000-10-11 15:57:05 +0000699 filename, dtdvalid);
Daniel Veillardf7cd4812001-02-23 18:44:52 +0000700 progresult = 3;
Daniel Veillardcd429612000-10-11 15:57:05 +0000701 }
Daniel Veillard48b2f892001-02-25 16:11:03 +0000702 if ((timing) && (!repeat)) {
703 long msec;
704 gettimeofday(&end, NULL);
705 msec = end.tv_sec - begin.tv_sec;
706 msec *= 1000;
707 msec += (end.tv_usec - begin.tv_usec) / 1000;
708 fprintf(stderr, "Validating against DTD took %ld ms\n", msec);
709 }
Daniel Veillardcd429612000-10-11 15:57:05 +0000710 xmlFreeDtd(dtd);
711 }
712 } else if (postvalid) {
Daniel Veillardce8b83b2000-04-05 18:38:42 +0000713 xmlValidCtxt cvp;
Daniel Veillard48b2f892001-02-25 16:11:03 +0000714 if ((timing) && (!repeat)) {
715 gettimeofday(&begin, NULL);
716 }
Daniel Veillardce8b83b2000-04-05 18:38:42 +0000717 cvp.userData = (void *) stderr; cvp.error = (xmlValidityErrorFunc) fprintf; cvp.warning = (xmlValidityWarningFunc) fprintf;
Daniel Veillardcd429612000-10-11 15:57:05 +0000718 if (!xmlValidateDocument(&cvp, doc)) {
Daniel Veillardd6d7f7b2000-10-25 19:56:55 +0000719 xmlGenericError(xmlGenericErrorContext,
720 "Document %s does not validate\n", filename);
Daniel Veillardf7cd4812001-02-23 18:44:52 +0000721 progresult = 3;
Daniel Veillardcd429612000-10-11 15:57:05 +0000722 }
Daniel Veillard48b2f892001-02-25 16:11:03 +0000723 if ((timing) && (!repeat)) {
724 long msec;
725 gettimeofday(&end, NULL);
726 msec = end.tv_sec - begin.tv_sec;
727 msec *= 1000;
728 msec += (end.tv_usec - begin.tv_usec) / 1000;
729 fprintf(stderr, "Validating took %ld ms\n", msec);
730 }
Daniel Veillardce8b83b2000-04-05 18:38:42 +0000731 }
732
733#ifdef LIBXML_DEBUG_ENABLED
734 if ((debugent) && (!html))
Daniel Veillardf0cc7cc2000-08-26 21:40:43 +0000735 xmlDebugDumpEntities(stderr, doc);
Daniel Veillardce8b83b2000-04-05 18:38:42 +0000736#endif
737
738 /*
739 * free it.
740 */
Daniel Veillard48b2f892001-02-25 16:11:03 +0000741 if ((timing) && (!repeat)) {
742 gettimeofday(&begin, NULL);
743 }
Daniel Veillardce8b83b2000-04-05 18:38:42 +0000744 xmlFreeDoc(doc);
Daniel Veillard48b2f892001-02-25 16:11:03 +0000745 if ((timing) && (!repeat)) {
746 long msec;
747 gettimeofday(&end, NULL);
748 msec = end.tv_sec - begin.tv_sec;
749 msec *= 1000;
750 msec += (end.tv_usec - begin.tv_usec) / 1000;
751 fprintf(stderr, "Freeing took %ld ms\n", msec);
752 }
Daniel Veillardce8b83b2000-04-05 18:38:42 +0000753}
754
Daniel Veillard4a6845d2001-01-03 13:32:39 +0000755int
756main(int argc, char **argv) {
Daniel Veillardce8b83b2000-04-05 18:38:42 +0000757 int i, count;
758 int files = 0;
759
Daniel Veillardbe803962000-06-28 23:40:59 +0000760 LIBXML_TEST_VERSION
Daniel Veillardce8b83b2000-04-05 18:38:42 +0000761 for (i = 1; i < argc ; i++) {
762#ifdef LIBXML_DEBUG_ENABLED
763 if ((!strcmp(argv[i], "-debug")) || (!strcmp(argv[i], "--debug")))
764 debug++;
Daniel Veillardce8b83b2000-04-05 18:38:42 +0000765 else if ((!strcmp(argv[i], "-shell")) ||
766 (!strcmp(argv[i], "--shell"))) {
767 shell++;
768 noout = 1;
769 } else
770#endif
771 if ((!strcmp(argv[i], "-copy")) || (!strcmp(argv[i], "--copy")))
772 copy++;
773 else if ((!strcmp(argv[i], "-recover")) ||
774 (!strcmp(argv[i], "--recover")))
775 recovery++;
776 else if ((!strcmp(argv[i], "-noent")) ||
777 (!strcmp(argv[i], "--noent")))
778 noent++;
Daniel Veillard4ec885a2001-06-17 10:31:07 +0000779 else if ((!strcmp(argv[i], "-version")) ||
780 (!strcmp(argv[i], "--version")))
781 fprintf(stderr, "xmllint: using libxml version %s\n",
782 xmlParserVersion);
Daniel Veillardce8b83b2000-04-05 18:38:42 +0000783 else if ((!strcmp(argv[i], "-noout")) ||
784 (!strcmp(argv[i], "--noout")))
785 noout++;
786 else if ((!strcmp(argv[i], "-htmlout")) ||
787 (!strcmp(argv[i], "--htmlout")))
788 htmlout++;
789#ifdef LIBXML_HTML_ENABLED
790 else if ((!strcmp(argv[i], "-html")) ||
791 (!strcmp(argv[i], "--html"))) {
792 html++;
793 }
794#endif /* LIBXML_HTML_ENABLED */
795 else if ((!strcmp(argv[i], "-nowrap")) ||
796 (!strcmp(argv[i], "--nowrap")))
797 nowrap++;
798 else if ((!strcmp(argv[i], "-valid")) ||
799 (!strcmp(argv[i], "--valid")))
800 valid++;
801 else if ((!strcmp(argv[i], "-postvalid")) ||
802 (!strcmp(argv[i], "--postvalid")))
803 postvalid++;
Daniel Veillardcd429612000-10-11 15:57:05 +0000804 else if ((!strcmp(argv[i], "-dtdvalid")) ||
805 (!strcmp(argv[i], "--dtdvalid"))) {
806 i++;
807 dtdvalid = argv[i];
808 }
Daniel Veillardce8b83b2000-04-05 18:38:42 +0000809 else if ((!strcmp(argv[i], "-insert")) ||
810 (!strcmp(argv[i], "--insert")))
811 insert++;
Daniel Veillard48b2f892001-02-25 16:11:03 +0000812 else if ((!strcmp(argv[i], "-timing")) ||
813 (!strcmp(argv[i], "--timing")))
814 timing++;
Daniel Veillardd2f3ec72001-04-11 07:50:02 +0000815 else if ((!strcmp(argv[i], "-auto")) ||
816 (!strcmp(argv[i], "--auto")))
817 generate++;
Daniel Veillardce8b83b2000-04-05 18:38:42 +0000818 else if ((!strcmp(argv[i], "-repeat")) ||
819 (!strcmp(argv[i], "--repeat")))
820 repeat++;
821 else if ((!strcmp(argv[i], "-push")) ||
822 (!strcmp(argv[i], "--push")))
823 push++;
Daniel Veillard46e370e2000-07-21 20:32:03 +0000824#ifdef HAVE_SYS_MMAN_H
825 else if ((!strcmp(argv[i], "-memory")) ||
826 (!strcmp(argv[i], "--memory")))
827 memory++;
828#endif
Daniel Veillard5e873c42000-04-12 13:27:38 +0000829 else if ((!strcmp(argv[i], "-testIO")) ||
830 (!strcmp(argv[i], "--testIO")))
831 testIO++;
Daniel Veillard9e8bfae2000-11-06 16:43:11 +0000832#ifdef LIBXML_XINCLUDE_ENABLED
833 else if ((!strcmp(argv[i], "-xinclude")) ||
834 (!strcmp(argv[i], "--xinclude")))
835 xinclude++;
836#endif
Daniel Veillardce8b83b2000-04-05 18:38:42 +0000837 else if ((!strcmp(argv[i], "-compress")) ||
838 (!strcmp(argv[i], "--compress"))) {
839 compress++;
840 xmlSetCompressMode(9);
841 }
842 else if ((!strcmp(argv[i], "-nowarning")) ||
843 (!strcmp(argv[i], "--nowarning"))) {
844 xmlGetWarningsDefaultValue = 0;
Daniel Veillardf0cc7cc2000-08-26 21:40:43 +0000845 xmlPedanticParserDefault(0);
Daniel Veillardce8b83b2000-04-05 18:38:42 +0000846 }
Daniel Veillardf0cc7cc2000-08-26 21:40:43 +0000847 else if ((!strcmp(argv[i], "-pedantic")) ||
848 (!strcmp(argv[i], "--pedantic"))) {
849 xmlGetWarningsDefaultValue = 1;
850 xmlPedanticParserDefault(1);
851 }
Daniel Veillard64c20ed2000-09-22 16:07:02 +0000852#ifdef LIBXML_DEBUG_ENABLED
Daniel Veillardf0cc7cc2000-08-26 21:40:43 +0000853 else if ((!strcmp(argv[i], "-debugent")) ||
854 (!strcmp(argv[i], "--debugent"))) {
855 debugent++;
856 xmlParserDebugEntities = 1;
857 }
Daniel Veillard64c20ed2000-09-22 16:07:02 +0000858#endif
Daniel Veillard81418e32001-05-22 15:08:55 +0000859#ifdef LIBXML_CATALOG_ENABLED
860 else if ((!strcmp(argv[i], "-catalogs")) ||
861 (!strcmp(argv[i], "--catalogs"))) {
862 const char *catalogs;
863
864 catalogs = getenv("SGML_CATALOG_FILES");
865 if (catalogs == NULL) {
866 fprintf(stderr, "Variable $SGML_CATALOG_FILES not set\n");
867 } else {
868 xmlLoadCatalogs(catalogs);
869 }
870 }
871#endif
Daniel Veillardbe803962000-06-28 23:40:59 +0000872 else if ((!strcmp(argv[i], "-encode")) ||
873 (!strcmp(argv[i], "--encode"))) {
874 i++;
875 encoding = argv[i];
Daniel Veillardf0cc7cc2000-08-26 21:40:43 +0000876 /*
877 * OK it's for testing purposes
878 */
879 xmlAddEncodingAlias("UTF-8", "DVEnc");
Daniel Veillardbe803962000-06-28 23:40:59 +0000880 }
Daniel Veillardce8b83b2000-04-05 18:38:42 +0000881 else if ((!strcmp(argv[i], "-noblanks")) ||
882 (!strcmp(argv[i], "--noblanks"))) {
883 noblanks++;
884 xmlKeepBlanksDefault(0);
885 }
886 }
887 if (noent != 0) xmlSubstituteEntitiesDefault(1);
888 if (valid != 0) xmlDoValidityCheckingDefaultValue = 1;
889 if ((htmlout) && (!nowrap)) {
Daniel Veillardd6d7f7b2000-10-25 19:56:55 +0000890 xmlGenericError(xmlGenericErrorContext,
Daniel Veillardce8b83b2000-04-05 18:38:42 +0000891 "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\"\n");
Daniel Veillardd6d7f7b2000-10-25 19:56:55 +0000892 xmlGenericError(xmlGenericErrorContext,
893 "\t\"http://www.w3.org/TR/REC-html40/loose.dtd\">\n");
894 xmlGenericError(xmlGenericErrorContext,
Daniel Veillardce8b83b2000-04-05 18:38:42 +0000895 "<html><head><title>%s output</title></head>\n",
896 argv[0]);
Daniel Veillardd6d7f7b2000-10-25 19:56:55 +0000897 xmlGenericError(xmlGenericErrorContext,
Daniel Veillardce8b83b2000-04-05 18:38:42 +0000898 "<body bgcolor=\"#ffffff\"><h1 align=\"center\">%s output</h1>\n",
899 argv[0]);
900 }
901 for (i = 1; i < argc ; i++) {
Daniel Veillardbe803962000-06-28 23:40:59 +0000902 if ((!strcmp(argv[i], "-encode")) ||
903 (!strcmp(argv[i], "--encode"))) {
904 i++;
905 continue;
906 }
Daniel Veillardcd429612000-10-11 15:57:05 +0000907 if ((!strcmp(argv[i], "-dtdvalid")) ||
908 (!strcmp(argv[i], "--dtdvalid"))) {
909 i++;
910 continue;
911 }
Daniel Veillard48b2f892001-02-25 16:11:03 +0000912 if ((timing) && (repeat))
913 gettimeofday(&begin, NULL);
Daniel Veillard4a6845d2001-01-03 13:32:39 +0000914 /* Remember file names. "-" means stding. <sven@zen.org> */
915 if ((argv[i][0] != '-') || (strcmp(argv[i], "-") == 0)) {
Daniel Veillardce8b83b2000-04-05 18:38:42 +0000916 if (repeat) {
917 for (count = 0;count < 100 * repeat;count++)
918 parseAndPrintFile(argv[i]);
919 } else
920 parseAndPrintFile(argv[i]);
921 files ++;
922 }
Daniel Veillard48b2f892001-02-25 16:11:03 +0000923 if ((timing) && (repeat)) {
924 long msec;
925 gettimeofday(&end, NULL);
926 msec = end.tv_sec - begin.tv_sec;
927 msec *= 1000;
928 msec += (end.tv_usec - begin.tv_usec) / 1000;
929 fprintf(stderr, "100 iteration took %ld ms\n", msec);
930 }
Daniel Veillardce8b83b2000-04-05 18:38:42 +0000931 }
Daniel Veillardd2f3ec72001-04-11 07:50:02 +0000932 if (generate)
933 parseAndPrintFile(NULL);
Daniel Veillardce8b83b2000-04-05 18:38:42 +0000934 if ((htmlout) && (!nowrap)) {
Daniel Veillardd6d7f7b2000-10-25 19:56:55 +0000935 xmlGenericError(xmlGenericErrorContext, "</body></html>\n");
Daniel Veillardce8b83b2000-04-05 18:38:42 +0000936 }
Daniel Veillardd2f3ec72001-04-11 07:50:02 +0000937 if ((files == 0) && (!generate)) {
Daniel Veillard48b2f892001-02-25 16:11:03 +0000938 printf("Usage : %s [options] XMLfiles ...\n",
Daniel Veillardce8b83b2000-04-05 18:38:42 +0000939 argv[0]);
940 printf("\tParse the XML files and output the result of the parsing\n");
Daniel Veillard4ec885a2001-06-17 10:31:07 +0000941 printf("\t--version : display the version of the XML library used\n");
Daniel Veillardce8b83b2000-04-05 18:38:42 +0000942#ifdef LIBXML_DEBUG_ENABLED
943 printf("\t--debug : dump a debug tree of the in-memory document\n");
944 printf("\t--shell : run a navigating shell\n");
945 printf("\t--debugent : debug the entities defined in the document\n");
946#endif
947 printf("\t--copy : used to test the internal copy implementation\n");
948 printf("\t--recover : output what was parsable on broken XML documents\n");
949 printf("\t--noent : substitute entity references by their value\n");
950 printf("\t--noout : don't output the result tree\n");
951 printf("\t--htmlout : output results as HTML\n");
952 printf("\t--nowarp : do not put HTML doc wrapper\n");
953 printf("\t--valid : validate the document in addition to std well-formed check\n");
954 printf("\t--postvalid : do a posteriori validation, i.e after parsing\n");
Daniel Veillardcd429612000-10-11 15:57:05 +0000955 printf("\t--dtdvalid URL : do a posteriori validation against a given DTD\n");
Daniel Veillard48b2f892001-02-25 16:11:03 +0000956 printf("\t--timing : print some timings\n");
Daniel Veillardce8b83b2000-04-05 18:38:42 +0000957 printf("\t--repeat : repeat 100 times, for timing or profiling\n");
958 printf("\t--insert : ad-hoc test for valid insertions\n");
959 printf("\t--compress : turn on gzip compression of output\n");
960#ifdef LIBXML_HTML_ENABLED
961 printf("\t--html : use the HTML parser\n");
962#endif
963 printf("\t--push : use the push mode of the parser\n");
Daniel Veillard46e370e2000-07-21 20:32:03 +0000964#ifdef HAVE_SYS_MMAN_H
965 printf("\t--memory : parse from memory\n");
966#endif
Daniel Veillardce8b83b2000-04-05 18:38:42 +0000967 printf("\t--nowarning : do not emit warnings from parser/validator\n");
968 printf("\t--noblanks : drop (ignorable?) blanks spaces\n");
Daniel Veillard5e873c42000-04-12 13:27:38 +0000969 printf("\t--testIO : test user I/O support\n");
Daniel Veillard32bc74e2000-07-14 14:49:25 +0000970 printf("\t--encode encoding : output in the given encoding\n");
Daniel Veillard81418e32001-05-22 15:08:55 +0000971#ifdef LIBXML_CATALOG_ENABLED
972 printf("\t--catalogs : use the catalogs from $SGML_CATALOG_FILES\n");
973#endif
Daniel Veillardd2f3ec72001-04-11 07:50:02 +0000974 printf("\t--auto : generate a small doc on the fly\n");
Daniel Veillard9e8bfae2000-11-06 16:43:11 +0000975#ifdef LIBXML_XINCLUDE_ENABLED
976 printf("\t--xinclude : do XInclude processing\n");
977#endif
Daniel Veillardce8b83b2000-04-05 18:38:42 +0000978 }
979 xmlCleanupParser();
980 xmlMemoryDump();
981
Daniel Veillardf7cd4812001-02-23 18:44:52 +0000982 return(progresult);
Daniel Veillardce8b83b2000-04-05 18:38:42 +0000983}
Daniel Veillard88a172f2000-08-04 18:23:10 +0000984