blob: 0a742a272c29c4eda176e55bcd145fabe832e10d [file] [log] [blame]
Daniel Veillard5099ae81999-04-21 20:12:07 +00001/*
Daniel Veillardcbaf3992001-12-31 16:16:02 +00002 * testSAX.c : a small tester program for parsing using the SAX API.
Daniel Veillard5099ae81999-04-21 20:12:07 +00003 *
4 * See Copyright for the status of this software.
5 *
Daniel Veillardc5d64342001-06-24 12:13:24 +00006 * daniel@veillard.com
Daniel Veillard5099ae81999-04-21 20:12:07 +00007 */
8
Bjorn Reese70a9da52001-04-21 16:57:29 +00009#include "libxml.h"
10
Daniel Veillard7f7d1111999-09-22 09:46:25 +000011#include <string.h>
12#include <stdarg.h>
13
14#ifdef HAVE_SYS_TYPES_H
Daniel Veillard5099ae81999-04-21 20:12:07 +000015#include <sys/types.h>
Daniel Veillard7f7d1111999-09-22 09:46:25 +000016#endif
Daniel Veillard5099ae81999-04-21 20:12:07 +000017#ifdef HAVE_SYS_STAT_H
18#include <sys/stat.h>
19#endif
20#ifdef HAVE_FCNTL_H
21#include <fcntl.h>
22#endif
23#ifdef HAVE_UNISTD_H
24#include <unistd.h>
25#endif
Daniel Veillard7f7d1111999-09-22 09:46:25 +000026#ifdef HAVE_STDLIB_H
Daniel Veillard5099ae81999-04-21 20:12:07 +000027#include <stdlib.h>
Daniel Veillard7f7d1111999-09-22 09:46:25 +000028#endif
Daniel Veillard7a66ee61999-09-26 11:31:02 +000029#ifdef HAVE_STRING_H
30#include <string.h>
31#endif
Daniel Veillard7f7d1111999-09-22 09:46:25 +000032
Daniel Veillard5099ae81999-04-21 20:12:07 +000033
Daniel Veillardd0463562001-10-13 09:15:48 +000034#include <libxml/globals.h>
Daniel Veillardb71379b2000-10-09 12:30:39 +000035#include <libxml/xmlerror.h>
Daniel Veillard361d8452000-04-03 19:48:13 +000036#include <libxml/parser.h>
37#include <libxml/parserInternals.h> /* only for xmlNewInputFromFile() */
38#include <libxml/tree.h>
39#include <libxml/debugXML.h>
40#include <libxml/xmlmemory.h>
Daniel Veillard5099ae81999-04-21 20:12:07 +000041
42static int debug = 0;
43static int copy = 0;
44static int recovery = 0;
Daniel Veillarddbfd6411999-12-28 16:35:14 +000045static int push = 0;
Daniel Veillard5e873c42000-04-12 13:27:38 +000046static int speed = 0;
Daniel Veillard5997aca2002-03-18 18:36:20 +000047static int noent = 0;
Daniel Veillarde50f3b52002-03-20 19:24:21 +000048static int quiet = 0;
Daniel Veillard0fb18932003-09-07 09:14:37 +000049static int nonull = 0;
50static int sax2 = 0;
Daniel Veillarde50f3b52002-03-20 19:24:21 +000051static int callbacks = 0;
Daniel Veillard5099ae81999-04-21 20:12:07 +000052
53xmlSAXHandler emptySAXHandlerStruct = {
54 NULL, /* internalSubset */
55 NULL, /* isStandalone */
56 NULL, /* hasInternalSubset */
57 NULL, /* hasExternalSubset */
58 NULL, /* resolveEntity */
59 NULL, /* getEntity */
60 NULL, /* entityDecl */
61 NULL, /* notationDecl */
62 NULL, /* attributeDecl */
63 NULL, /* elementDecl */
64 NULL, /* unparsedEntityDecl */
65 NULL, /* setDocumentLocator */
66 NULL, /* startDocument */
67 NULL, /* endDocument */
68 NULL, /* startElement */
69 NULL, /* endElement */
70 NULL, /* reference */
71 NULL, /* characters */
72 NULL, /* ignorableWhitespace */
73 NULL, /* processingInstruction */
74 NULL, /* comment */
75 NULL, /* xmlParserWarning */
76 NULL, /* xmlParserError */
77 NULL, /* xmlParserError */
Daniel Veillardb05deb71999-08-10 19:04:08 +000078 NULL, /* getParameterEntity */
Daniel Veillardcf461992000-03-14 18:30:20 +000079 NULL, /* cdataBlock; */
Daniel Veillard0fb18932003-09-07 09:14:37 +000080 NULL, /* externalSubset; */
81 1,
82 NULL,
83 NULL, /* startElementNs */
Daniel Veillard07cb8222003-09-10 10:51:05 +000084 NULL /* endElementNs */
Daniel Veillard5099ae81999-04-21 20:12:07 +000085};
86
87xmlSAXHandlerPtr emptySAXHandler = &emptySAXHandlerStruct;
Daniel Veillard011b63c1999-06-02 17:44:04 +000088extern xmlSAXHandlerPtr debugSAXHandler;
Daniel Veillard5099ae81999-04-21 20:12:07 +000089
Daniel Veillard5099ae81999-04-21 20:12:07 +000090/************************************************************************
91 * *
92 * Debug Handlers *
93 * *
94 ************************************************************************/
95
96/**
97 * isStandaloneDebug:
98 * @ctxt: An XML parser context
99 *
100 * Is this document tagged standalone ?
101 *
102 * Returns 1 if true
103 */
Daniel Veillard56a4cb82001-03-24 17:00:36 +0000104static int
Daniel Veillardc86a4fa2001-03-26 16:28:29 +0000105isStandaloneDebug(void *ctx ATTRIBUTE_UNUSED)
Daniel Veillard5099ae81999-04-21 20:12:07 +0000106{
Daniel Veillarde50f3b52002-03-20 19:24:21 +0000107 callbacks++;
108 if (quiet)
109 return(0);
Daniel Veillard27d88741999-05-29 11:51:49 +0000110 fprintf(stdout, "SAX.isStandalone()\n");
Daniel Veillard5099ae81999-04-21 20:12:07 +0000111 return(0);
112}
113
114/**
115 * hasInternalSubsetDebug:
116 * @ctxt: An XML parser context
117 *
118 * Does this document has an internal subset
119 *
120 * Returns 1 if true
121 */
Daniel Veillard56a4cb82001-03-24 17:00:36 +0000122static int
Daniel Veillardc86a4fa2001-03-26 16:28:29 +0000123hasInternalSubsetDebug(void *ctx ATTRIBUTE_UNUSED)
Daniel Veillard5099ae81999-04-21 20:12:07 +0000124{
Daniel Veillarde50f3b52002-03-20 19:24:21 +0000125 callbacks++;
126 if (quiet)
127 return(0);
Daniel Veillard27d88741999-05-29 11:51:49 +0000128 fprintf(stdout, "SAX.hasInternalSubset()\n");
Daniel Veillard5099ae81999-04-21 20:12:07 +0000129 return(0);
130}
131
132/**
133 * hasExternalSubsetDebug:
134 * @ctxt: An XML parser context
135 *
136 * Does this document has an external subset
137 *
138 * Returns 1 if true
139 */
Daniel Veillard56a4cb82001-03-24 17:00:36 +0000140static int
Daniel Veillardc86a4fa2001-03-26 16:28:29 +0000141hasExternalSubsetDebug(void *ctx ATTRIBUTE_UNUSED)
Daniel Veillard5099ae81999-04-21 20:12:07 +0000142{
Daniel Veillarde50f3b52002-03-20 19:24:21 +0000143 callbacks++;
144 if (quiet)
145 return(0);
Daniel Veillard27d88741999-05-29 11:51:49 +0000146 fprintf(stdout, "SAX.hasExternalSubset()\n");
Daniel Veillard5099ae81999-04-21 20:12:07 +0000147 return(0);
148}
149
150/**
Daniel Veillard06047432000-04-24 11:33:38 +0000151 * internalSubsetDebug:
Daniel Veillard5099ae81999-04-21 20:12:07 +0000152 * @ctxt: An XML parser context
153 *
154 * Does this document has an internal subset
155 */
Daniel Veillard56a4cb82001-03-24 17:00:36 +0000156static void
Daniel Veillardc86a4fa2001-03-26 16:28:29 +0000157internalSubsetDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *name,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000158 const xmlChar *ExternalID, const xmlChar *SystemID)
Daniel Veillard5099ae81999-04-21 20:12:07 +0000159{
Daniel Veillarde50f3b52002-03-20 19:24:21 +0000160 callbacks++;
161 if (quiet)
162 return;
Daniel Veillard808a3f12000-08-17 13:50:51 +0000163 fprintf(stdout, "SAX.internalSubset(%s,", name);
164 if (ExternalID == NULL)
165 fprintf(stdout, " ,");
166 else
167 fprintf(stdout, " %s,", ExternalID);
168 if (SystemID == NULL)
169 fprintf(stdout, " )\n");
170 else
171 fprintf(stdout, " %s)\n", SystemID);
Daniel Veillard5099ae81999-04-21 20:12:07 +0000172}
173
174/**
Daniel Veillard56a4cb82001-03-24 17:00:36 +0000175 * externalSubsetDebug:
176 * @ctxt: An XML parser context
177 *
178 * Does this document has an external subset
179 */
180static void
Daniel Veillardc86a4fa2001-03-26 16:28:29 +0000181externalSubsetDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *name,
Daniel Veillard56a4cb82001-03-24 17:00:36 +0000182 const xmlChar *ExternalID, const xmlChar *SystemID)
183{
Daniel Veillarde50f3b52002-03-20 19:24:21 +0000184 callbacks++;
185 if (quiet)
186 return;
Daniel Veillard56a4cb82001-03-24 17:00:36 +0000187 fprintf(stdout, "SAX.externalSubset(%s,", name);
188 if (ExternalID == NULL)
189 fprintf(stdout, " ,");
190 else
191 fprintf(stdout, " %s,", ExternalID);
192 if (SystemID == NULL)
193 fprintf(stdout, " )\n");
194 else
195 fprintf(stdout, " %s)\n", SystemID);
196}
197
198/**
Daniel Veillard5099ae81999-04-21 20:12:07 +0000199 * resolveEntityDebug:
200 * @ctxt: An XML parser context
201 * @publicId: The public ID of the entity
202 * @systemId: The system ID of the entity
203 *
204 * Special entity resolver, better left to the parser, it has
205 * more context than the application layer.
206 * The default behaviour is to NOT resolve the entities, in that case
207 * the ENTITY_REF nodes are built in the structure (and the parameter
208 * values).
209 *
210 * Returns the xmlParserInputPtr if inlined or NULL for DOM behaviour.
211 */
Daniel Veillard56a4cb82001-03-24 17:00:36 +0000212static xmlParserInputPtr
Daniel Veillardc86a4fa2001-03-26 16:28:29 +0000213resolveEntityDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *publicId, const xmlChar *systemId)
Daniel Veillard5099ae81999-04-21 20:12:07 +0000214{
Daniel Veillarde50f3b52002-03-20 19:24:21 +0000215 callbacks++;
216 if (quiet)
217 return(NULL);
Daniel Veillard7a66ee61999-09-26 11:31:02 +0000218 /* xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx; */
Daniel Veillardb96e6431999-08-29 21:02:19 +0000219
Daniel Veillard14fff061999-06-22 21:49:07 +0000220
221 fprintf(stdout, "SAX.resolveEntity(");
222 if (publicId != NULL)
223 fprintf(stdout, "%s", (char *)publicId);
224 else
225 fprintf(stdout, " ");
226 if (systemId != NULL)
227 fprintf(stdout, ", %s)\n", (char *)systemId);
228 else
229 fprintf(stdout, ", )\n");
Daniel Veillard7a66ee61999-09-26 11:31:02 +0000230/*********
Daniel Veillard011b63c1999-06-02 17:44:04 +0000231 if (systemId != NULL) {
Daniel Veillardb96e6431999-08-29 21:02:19 +0000232 return(xmlNewInputFromFile(ctxt, (char *) systemId));
Daniel Veillard011b63c1999-06-02 17:44:04 +0000233 }
Daniel Veillard7a66ee61999-09-26 11:31:02 +0000234 *********/
Daniel Veillard5099ae81999-04-21 20:12:07 +0000235 return(NULL);
236}
237
238/**
239 * getEntityDebug:
240 * @ctxt: An XML parser context
241 * @name: The entity name
242 *
243 * Get an entity by name
244 *
245 * Returns the xmlParserInputPtr if inlined or NULL for DOM behaviour.
246 */
Daniel Veillard56a4cb82001-03-24 17:00:36 +0000247static xmlEntityPtr
Daniel Veillardc86a4fa2001-03-26 16:28:29 +0000248getEntityDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *name)
Daniel Veillard5099ae81999-04-21 20:12:07 +0000249{
Daniel Veillarde50f3b52002-03-20 19:24:21 +0000250 callbacks++;
251 if (quiet)
252 return(NULL);
Daniel Veillard27d88741999-05-29 11:51:49 +0000253 fprintf(stdout, "SAX.getEntity(%s)\n", name);
Daniel Veillard5099ae81999-04-21 20:12:07 +0000254 return(NULL);
255}
256
Daniel Veillardb05deb71999-08-10 19:04:08 +0000257/**
258 * getParameterEntityDebug:
259 * @ctxt: An XML parser context
260 * @name: The entity name
261 *
262 * Get a parameter entity by name
263 *
264 * Returns the xmlParserInputPtr
265 */
Daniel Veillard56a4cb82001-03-24 17:00:36 +0000266static xmlEntityPtr
Daniel Veillardc86a4fa2001-03-26 16:28:29 +0000267getParameterEntityDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *name)
Daniel Veillardb05deb71999-08-10 19:04:08 +0000268{
Daniel Veillarde50f3b52002-03-20 19:24:21 +0000269 callbacks++;
270 if (quiet)
271 return(NULL);
Daniel Veillardb05deb71999-08-10 19:04:08 +0000272 fprintf(stdout, "SAX.getParameterEntity(%s)\n", name);
273 return(NULL);
274}
275
Daniel Veillard5099ae81999-04-21 20:12:07 +0000276
277/**
278 * entityDeclDebug:
279 * @ctxt: An XML parser context
280 * @name: the entity name
281 * @type: the entity type
282 * @publicId: The public ID of the entity
283 * @systemId: The system ID of the entity
284 * @content: the entity value (without processing).
285 *
286 * An entity definition has been parsed
287 */
Daniel Veillard56a4cb82001-03-24 17:00:36 +0000288static void
Daniel Veillardc86a4fa2001-03-26 16:28:29 +0000289entityDeclDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *name, int type,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000290 const xmlChar *publicId, const xmlChar *systemId, xmlChar *content)
Daniel Veillard5099ae81999-04-21 20:12:07 +0000291{
Daniel Veillarde50f3b52002-03-20 19:24:21 +0000292 callbacks++;
293 if (quiet)
294 return;
Daniel Veillard27d88741999-05-29 11:51:49 +0000295 fprintf(stdout, "SAX.entityDecl(%s, %d, %s, %s, %s)\n",
Daniel Veillard5099ae81999-04-21 20:12:07 +0000296 name, type, publicId, systemId, content);
297}
298
299/**
300 * attributeDeclDebug:
301 * @ctxt: An XML parser context
302 * @name: the attribute name
303 * @type: the attribute type
304 *
305 * An attribute definition has been parsed
306 */
Daniel Veillard56a4cb82001-03-24 17:00:36 +0000307static void
Daniel Veillard07cb8222003-09-10 10:51:05 +0000308attributeDeclDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar * elem,
309 const xmlChar * name, int type, int def,
310 const xmlChar * defaultValue, xmlEnumerationPtr tree)
Daniel Veillard5099ae81999-04-21 20:12:07 +0000311{
Daniel Veillarde50f3b52002-03-20 19:24:21 +0000312 callbacks++;
313 if (quiet)
Daniel Veillard07cb8222003-09-10 10:51:05 +0000314 return;
Daniel Veillard7e99c632000-10-06 12:59:53 +0000315 if (defaultValue == NULL)
Daniel Veillard07cb8222003-09-10 10:51:05 +0000316 fprintf(stdout, "SAX.attributeDecl(%s, %s, %d, %d, NULL, ...)\n",
317 elem, name, type, def);
Daniel Veillard7e99c632000-10-06 12:59:53 +0000318 else
Daniel Veillard07cb8222003-09-10 10:51:05 +0000319 fprintf(stdout, "SAX.attributeDecl(%s, %s, %d, %d, %s, ...)\n",
320 elem, name, type, def, defaultValue);
321 xmlFreeEnumeration(tree);
Daniel Veillard5099ae81999-04-21 20:12:07 +0000322}
323
324/**
325 * elementDeclDebug:
326 * @ctxt: An XML parser context
327 * @name: the element name
328 * @type: the element type
329 * @content: the element value (without processing).
330 *
331 * An element definition has been parsed
332 */
Daniel Veillard56a4cb82001-03-24 17:00:36 +0000333static void
Daniel Veillardc86a4fa2001-03-26 16:28:29 +0000334elementDeclDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *name, int type,
335 xmlElementContentPtr content ATTRIBUTE_UNUSED)
Daniel Veillard5099ae81999-04-21 20:12:07 +0000336{
Daniel Veillarde50f3b52002-03-20 19:24:21 +0000337 callbacks++;
338 if (quiet)
339 return;
Daniel Veillard27d88741999-05-29 11:51:49 +0000340 fprintf(stdout, "SAX.elementDecl(%s, %d, ...)\n",
Daniel Veillard5099ae81999-04-21 20:12:07 +0000341 name, type);
342}
343
344/**
345 * notationDeclDebug:
346 * @ctxt: An XML parser context
347 * @name: The name of the notation
348 * @publicId: The public ID of the entity
349 * @systemId: The system ID of the entity
350 *
351 * What to do when a notation declaration has been parsed.
Daniel Veillard5099ae81999-04-21 20:12:07 +0000352 */
Daniel Veillard56a4cb82001-03-24 17:00:36 +0000353static void
Daniel Veillardc86a4fa2001-03-26 16:28:29 +0000354notationDeclDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *name,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000355 const xmlChar *publicId, const xmlChar *systemId)
Daniel Veillard5099ae81999-04-21 20:12:07 +0000356{
Daniel Veillarde50f3b52002-03-20 19:24:21 +0000357 callbacks++;
358 if (quiet)
359 return;
Daniel Veillard27d88741999-05-29 11:51:49 +0000360 fprintf(stdout, "SAX.notationDecl(%s, %s, %s)\n",
Daniel Veillard5099ae81999-04-21 20:12:07 +0000361 (char *) name, (char *) publicId, (char *) systemId);
362}
363
364/**
365 * unparsedEntityDeclDebug:
366 * @ctxt: An XML parser context
367 * @name: The name of the entity
368 * @publicId: The public ID of the entity
369 * @systemId: The system ID of the entity
370 * @notationName: the name of the notation
371 *
372 * What to do when an unparsed entity declaration is parsed
Daniel Veillard5099ae81999-04-21 20:12:07 +0000373 */
Daniel Veillard56a4cb82001-03-24 17:00:36 +0000374static void
Daniel Veillardc86a4fa2001-03-26 16:28:29 +0000375unparsedEntityDeclDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *name,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000376 const xmlChar *publicId, const xmlChar *systemId,
377 const xmlChar *notationName)
Daniel Veillard5099ae81999-04-21 20:12:07 +0000378{
Daniel Veillarde50f3b52002-03-20 19:24:21 +0000379 callbacks++;
380 if (quiet)
381 return;
Daniel Veillard27d88741999-05-29 11:51:49 +0000382 fprintf(stdout, "SAX.unparsedEntityDecl(%s, %s, %s, %s)\n",
Daniel Veillard5099ae81999-04-21 20:12:07 +0000383 (char *) name, (char *) publicId, (char *) systemId,
384 (char *) notationName);
385}
386
387/**
388 * setDocumentLocatorDebug:
389 * @ctxt: An XML parser context
390 * @loc: A SAX Locator
391 *
392 * Receive the document locator at startup, actually xmlDefaultSAXLocator
393 * Everything is available on the context, so this is useless in our case.
394 */
Daniel Veillard56a4cb82001-03-24 17:00:36 +0000395static void
Daniel Veillardc86a4fa2001-03-26 16:28:29 +0000396setDocumentLocatorDebug(void *ctx ATTRIBUTE_UNUSED, xmlSAXLocatorPtr loc ATTRIBUTE_UNUSED)
Daniel Veillard5099ae81999-04-21 20:12:07 +0000397{
Daniel Veillarde50f3b52002-03-20 19:24:21 +0000398 callbacks++;
399 if (quiet)
400 return;
Daniel Veillard27d88741999-05-29 11:51:49 +0000401 fprintf(stdout, "SAX.setDocumentLocator()\n");
Daniel Veillard5099ae81999-04-21 20:12:07 +0000402}
403
404/**
405 * startDocumentDebug:
406 * @ctxt: An XML parser context
407 *
408 * called when the document start being processed.
409 */
Daniel Veillard56a4cb82001-03-24 17:00:36 +0000410static void
Daniel Veillardc86a4fa2001-03-26 16:28:29 +0000411startDocumentDebug(void *ctx ATTRIBUTE_UNUSED)
Daniel Veillard5099ae81999-04-21 20:12:07 +0000412{
Daniel Veillarde50f3b52002-03-20 19:24:21 +0000413 callbacks++;
414 if (quiet)
415 return;
Daniel Veillard27d88741999-05-29 11:51:49 +0000416 fprintf(stdout, "SAX.startDocument()\n");
Daniel Veillard5099ae81999-04-21 20:12:07 +0000417}
418
419/**
420 * endDocumentDebug:
421 * @ctxt: An XML parser context
422 *
423 * called when the document end has been detected.
424 */
Daniel Veillard56a4cb82001-03-24 17:00:36 +0000425static void
Daniel Veillardc86a4fa2001-03-26 16:28:29 +0000426endDocumentDebug(void *ctx ATTRIBUTE_UNUSED)
Daniel Veillard5099ae81999-04-21 20:12:07 +0000427{
Daniel Veillarde50f3b52002-03-20 19:24:21 +0000428 callbacks++;
429 if (quiet)
430 return;
Daniel Veillard27d88741999-05-29 11:51:49 +0000431 fprintf(stdout, "SAX.endDocument()\n");
Daniel Veillard5099ae81999-04-21 20:12:07 +0000432}
433
434/**
435 * startElementDebug:
436 * @ctxt: An XML parser context
437 * @name: The element name
438 *
439 * called when an opening tag has been processed.
Daniel Veillard5099ae81999-04-21 20:12:07 +0000440 */
Daniel Veillard56a4cb82001-03-24 17:00:36 +0000441static void
Daniel Veillardc86a4fa2001-03-26 16:28:29 +0000442startElementDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *name, const xmlChar **atts)
Daniel Veillard5099ae81999-04-21 20:12:07 +0000443{
444 int i;
445
Daniel Veillarde50f3b52002-03-20 19:24:21 +0000446 callbacks++;
447 if (quiet)
448 return;
Daniel Veillard27d88741999-05-29 11:51:49 +0000449 fprintf(stdout, "SAX.startElement(%s", (char *) name);
Daniel Veillard5099ae81999-04-21 20:12:07 +0000450 if (atts != NULL) {
451 for (i = 0;(atts[i] != NULL);i++) {
Daniel Veillard27d88741999-05-29 11:51:49 +0000452 fprintf(stdout, ", %s='", atts[i++]);
Daniel Veillard808a3f12000-08-17 13:50:51 +0000453 if (atts[i] != NULL)
454 fprintf(stdout, "%s'", atts[i]);
Daniel Veillard5099ae81999-04-21 20:12:07 +0000455 }
456 }
Daniel Veillard27d88741999-05-29 11:51:49 +0000457 fprintf(stdout, ")\n");
Daniel Veillard5099ae81999-04-21 20:12:07 +0000458}
459
460/**
461 * endElementDebug:
462 * @ctxt: An XML parser context
463 * @name: The element name
464 *
465 * called when the end of an element has been detected.
466 */
Daniel Veillard56a4cb82001-03-24 17:00:36 +0000467static void
Daniel Veillardc86a4fa2001-03-26 16:28:29 +0000468endElementDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *name)
Daniel Veillard5099ae81999-04-21 20:12:07 +0000469{
Daniel Veillarde50f3b52002-03-20 19:24:21 +0000470 callbacks++;
471 if (quiet)
472 return;
Daniel Veillard27d88741999-05-29 11:51:49 +0000473 fprintf(stdout, "SAX.endElement(%s)\n", (char *) name);
Daniel Veillard5099ae81999-04-21 20:12:07 +0000474}
475
476/**
477 * charactersDebug:
478 * @ctxt: An XML parser context
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000479 * @ch: a xmlChar string
480 * @len: the number of xmlChar
Daniel Veillard5099ae81999-04-21 20:12:07 +0000481 *
482 * receiving some chars from the parser.
483 * Question: how much at a time ???
484 */
Daniel Veillard56a4cb82001-03-24 17:00:36 +0000485static void
Daniel Veillardc86a4fa2001-03-26 16:28:29 +0000486charactersDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *ch, int len)
Daniel Veillard5099ae81999-04-21 20:12:07 +0000487{
Daniel Veillard87b95392000-08-12 21:12:04 +0000488 char output[40];
Daniel Veillarde2d034d1999-07-27 19:52:06 +0000489 int i;
490
Daniel Veillarde50f3b52002-03-20 19:24:21 +0000491 callbacks++;
492 if (quiet)
493 return;
Daniel Veillard87b95392000-08-12 21:12:04 +0000494 for (i = 0;(i<len) && (i < 30);i++)
495 output[i] = ch[i];
496 output[i] = 0;
497
498 fprintf(stdout, "SAX.characters(%s, %d)\n", output, len);
Daniel Veillard5099ae81999-04-21 20:12:07 +0000499}
500
501/**
502 * referenceDebug:
503 * @ctxt: An XML parser context
504 * @name: The entity name
505 *
506 * called when an entity reference is detected.
507 */
Daniel Veillard56a4cb82001-03-24 17:00:36 +0000508static void
Daniel Veillardc86a4fa2001-03-26 16:28:29 +0000509referenceDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *name)
Daniel Veillard5099ae81999-04-21 20:12:07 +0000510{
Daniel Veillarde50f3b52002-03-20 19:24:21 +0000511 callbacks++;
512 if (quiet)
513 return;
Daniel Veillard27d88741999-05-29 11:51:49 +0000514 fprintf(stdout, "SAX.reference(%s)\n", name);
Daniel Veillard5099ae81999-04-21 20:12:07 +0000515}
516
517/**
518 * ignorableWhitespaceDebug:
519 * @ctxt: An XML parser context
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000520 * @ch: a xmlChar string
Daniel Veillard5099ae81999-04-21 20:12:07 +0000521 * @start: the first char in the string
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000522 * @len: the number of xmlChar
Daniel Veillard5099ae81999-04-21 20:12:07 +0000523 *
524 * receiving some ignorable whitespaces from the parser.
525 * Question: how much at a time ???
526 */
Daniel Veillard56a4cb82001-03-24 17:00:36 +0000527static void
Daniel Veillardc86a4fa2001-03-26 16:28:29 +0000528ignorableWhitespaceDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *ch, int len)
Daniel Veillard5099ae81999-04-21 20:12:07 +0000529{
Daniel Veillard87b95392000-08-12 21:12:04 +0000530 char output[40];
531 int i;
532
Daniel Veillarde50f3b52002-03-20 19:24:21 +0000533 callbacks++;
534 if (quiet)
535 return;
Daniel Veillard87b95392000-08-12 21:12:04 +0000536 for (i = 0;(i<len) && (i < 30);i++)
537 output[i] = ch[i];
538 output[i] = 0;
539 fprintf(stdout, "SAX.ignorableWhitespace(%s, %d)\n", output, len);
Daniel Veillard5099ae81999-04-21 20:12:07 +0000540}
541
542/**
543 * processingInstructionDebug:
544 * @ctxt: An XML parser context
545 * @target: the target name
546 * @data: the PI data's
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000547 * @len: the number of xmlChar
Daniel Veillard5099ae81999-04-21 20:12:07 +0000548 *
549 * A processing instruction has been parsed.
550 */
Daniel Veillard56a4cb82001-03-24 17:00:36 +0000551static void
Daniel Veillardc86a4fa2001-03-26 16:28:29 +0000552processingInstructionDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *target,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000553 const xmlChar *data)
Daniel Veillard5099ae81999-04-21 20:12:07 +0000554{
Daniel Veillarde50f3b52002-03-20 19:24:21 +0000555 callbacks++;
556 if (quiet)
557 return;
Daniel Veillard27d88741999-05-29 11:51:49 +0000558 fprintf(stdout, "SAX.processingInstruction(%s, %s)\n",
Daniel Veillard5099ae81999-04-21 20:12:07 +0000559 (char *) target, (char *) data);
560}
561
562/**
Daniel Veillardcf461992000-03-14 18:30:20 +0000563 * cdataBlockDebug:
564 * @ctx: the user data (XML parser context)
565 * @value: The pcdata content
566 * @len: the block length
567 *
568 * called when a pcdata block has been parsed
569 */
Daniel Veillard56a4cb82001-03-24 17:00:36 +0000570static void
Daniel Veillardc86a4fa2001-03-26 16:28:29 +0000571cdataBlockDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *value, int len)
Daniel Veillardcf461992000-03-14 18:30:20 +0000572{
Daniel Veillarde50f3b52002-03-20 19:24:21 +0000573 callbacks++;
574 if (quiet)
575 return;
Daniel Veillard39915622000-10-15 10:06:55 +0000576 fprintf(stdout, "SAX.pcdata(%.20s, %d)\n",
Daniel Veillardcf461992000-03-14 18:30:20 +0000577 (char *) value, len);
578}
579
580/**
Daniel Veillard5099ae81999-04-21 20:12:07 +0000581 * commentDebug:
582 * @ctxt: An XML parser context
583 * @value: the comment content
584 *
585 * A comment has been parsed.
586 */
Daniel Veillard56a4cb82001-03-24 17:00:36 +0000587static void
Daniel Veillardc86a4fa2001-03-26 16:28:29 +0000588commentDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *value)
Daniel Veillard5099ae81999-04-21 20:12:07 +0000589{
Daniel Veillarde50f3b52002-03-20 19:24:21 +0000590 callbacks++;
591 if (quiet)
592 return;
Daniel Veillard27d88741999-05-29 11:51:49 +0000593 fprintf(stdout, "SAX.comment(%s)\n", value);
Daniel Veillard5099ae81999-04-21 20:12:07 +0000594}
595
596/**
597 * warningDebug:
598 * @ctxt: An XML parser context
599 * @msg: the message to display/transmit
600 * @...: extra parameters for the message display
601 *
602 * Display and format a warning messages, gives file, line, position and
603 * extra parameters.
604 */
Daniel Veillard56a4cb82001-03-24 17:00:36 +0000605static void
Daniel Veillardc86a4fa2001-03-26 16:28:29 +0000606warningDebug(void *ctx ATTRIBUTE_UNUSED, const char *msg, ...)
Daniel Veillard5099ae81999-04-21 20:12:07 +0000607{
608 va_list args;
609
Daniel Veillarde50f3b52002-03-20 19:24:21 +0000610 callbacks++;
611 if (quiet)
612 return;
Daniel Veillard5099ae81999-04-21 20:12:07 +0000613 va_start(args, msg);
Daniel Veillard27d88741999-05-29 11:51:49 +0000614 fprintf(stdout, "SAX.warning: ");
615 vfprintf(stdout, msg, args);
Daniel Veillard5099ae81999-04-21 20:12:07 +0000616 va_end(args);
617}
618
619/**
620 * errorDebug:
621 * @ctxt: An XML parser context
622 * @msg: the message to display/transmit
623 * @...: extra parameters for the message display
624 *
625 * Display and format a error messages, gives file, line, position and
626 * extra parameters.
627 */
Daniel Veillard56a4cb82001-03-24 17:00:36 +0000628static void
Daniel Veillardc86a4fa2001-03-26 16:28:29 +0000629errorDebug(void *ctx ATTRIBUTE_UNUSED, const char *msg, ...)
Daniel Veillard5099ae81999-04-21 20:12:07 +0000630{
631 va_list args;
632
Daniel Veillarde50f3b52002-03-20 19:24:21 +0000633 callbacks++;
634 if (quiet)
635 return;
Daniel Veillard5099ae81999-04-21 20:12:07 +0000636 va_start(args, msg);
Daniel Veillard27d88741999-05-29 11:51:49 +0000637 fprintf(stdout, "SAX.error: ");
638 vfprintf(stdout, msg, args);
Daniel Veillard5099ae81999-04-21 20:12:07 +0000639 va_end(args);
640}
641
642/**
643 * fatalErrorDebug:
644 * @ctxt: An XML parser context
645 * @msg: the message to display/transmit
646 * @...: extra parameters for the message display
647 *
648 * Display and format a fatalError messages, gives file, line, position and
649 * extra parameters.
650 */
Daniel Veillard56a4cb82001-03-24 17:00:36 +0000651static void
Daniel Veillardc86a4fa2001-03-26 16:28:29 +0000652fatalErrorDebug(void *ctx ATTRIBUTE_UNUSED, const char *msg, ...)
Daniel Veillard5099ae81999-04-21 20:12:07 +0000653{
654 va_list args;
655
Daniel Veillarde50f3b52002-03-20 19:24:21 +0000656 callbacks++;
657 if (quiet)
658 return;
Daniel Veillard5099ae81999-04-21 20:12:07 +0000659 va_start(args, msg);
Daniel Veillard27d88741999-05-29 11:51:49 +0000660 fprintf(stdout, "SAX.fatalError: ");
661 vfprintf(stdout, msg, args);
Daniel Veillard5099ae81999-04-21 20:12:07 +0000662 va_end(args);
663}
664
665xmlSAXHandler debugSAXHandlerStruct = {
666 internalSubsetDebug,
667 isStandaloneDebug,
668 hasInternalSubsetDebug,
669 hasExternalSubsetDebug,
670 resolveEntityDebug,
671 getEntityDebug,
672 entityDeclDebug,
673 notationDeclDebug,
674 attributeDeclDebug,
675 elementDeclDebug,
676 unparsedEntityDeclDebug,
677 setDocumentLocatorDebug,
678 startDocumentDebug,
679 endDocumentDebug,
680 startElementDebug,
681 endElementDebug,
682 referenceDebug,
683 charactersDebug,
684 ignorableWhitespaceDebug,
685 processingInstructionDebug,
686 commentDebug,
687 warningDebug,
688 errorDebug,
689 fatalErrorDebug,
Daniel Veillardb05deb71999-08-10 19:04:08 +0000690 getParameterEntityDebug,
Daniel Veillard56a4cb82001-03-24 17:00:36 +0000691 cdataBlockDebug,
Daniel Veillardd0463562001-10-13 09:15:48 +0000692 externalSubsetDebug,
Daniel Veillard0fb18932003-09-07 09:14:37 +0000693 1,
694 NULL,
695 NULL,
Daniel Veillard0fb18932003-09-07 09:14:37 +0000696 NULL
Daniel Veillard5099ae81999-04-21 20:12:07 +0000697};
698
699xmlSAXHandlerPtr debugSAXHandler = &debugSAXHandlerStruct;
700
Daniel Veillard0fb18932003-09-07 09:14:37 +0000701/*
702 * SAX2 specific callbacks
703 */
704/**
Daniel Veillard07cb8222003-09-10 10:51:05 +0000705 * startElementNsDebug:
Daniel Veillard0fb18932003-09-07 09:14:37 +0000706 * @ctxt: An XML parser context
707 * @name: The element name
708 *
709 * called when an opening tag has been processed.
710 */
711static void
712startElementNsDebug(void *ctx ATTRIBUTE_UNUSED,
713 const xmlChar *localname,
714 const xmlChar *prefix,
715 const xmlChar *URI,
716 int nb_namespaces,
717 const xmlChar **namespaces,
Daniel Veillard07cb8222003-09-10 10:51:05 +0000718 int nb_attributes,
719 int nb_defaulted,
720 const xmlChar **attributes)
Daniel Veillard0fb18932003-09-07 09:14:37 +0000721{
722 int i;
723
724 callbacks++;
725 if (quiet)
726 return;
727 fprintf(stdout, "SAX.startElementNs(%s", (char *) localname);
728 if (prefix == NULL)
729 fprintf(stdout, ", NULL");
730 else
731 fprintf(stdout, ", %s", (char *) prefix);
732 if (URI == NULL)
733 fprintf(stdout, ", NULL");
734 else
735 fprintf(stdout, ", '%s'", (char *) URI);
736 fprintf(stdout, ", %d", nb_namespaces);
737
738 if (namespaces != NULL) {
739 for (i = 0;i < nb_namespaces * 2;i++) {
740 fprintf(stdout, ", xmlns");
741 if (namespaces[i] != NULL)
742 fprintf(stdout, ":%s", namespaces[i]);
743 i++;
744 fprintf(stdout, "='%s'", namespaces[i]);
745 }
746 }
Daniel Veillard07cb8222003-09-10 10:51:05 +0000747 fprintf(stdout, ", %d, %d", nb_attributes, nb_defaulted);
748 if (attributes != NULL) {
749 for (i = 0;i < nb_attributes;i += 5) {
750 if (attributes[i + 1] != NULL)
751 fprintf(stdout, ", %s:%s='", attributes[i + 1], attributes[i]);
752 else
753 fprintf(stdout, ", %s='", attributes[i]);
754 fprintf(stdout, "%.4s...', %d", attributes[i + 3],
755 attributes[i + 4] - attributes[i + 3]);
756 }
757 }
758 fprintf(stdout, ")\n");
Daniel Veillard0fb18932003-09-07 09:14:37 +0000759}
760
761/**
762 * endElementDebug:
763 * @ctxt: An XML parser context
764 * @name: The element name
765 *
766 * called when the end of an element has been detected.
767 */
768static void
769endElementNsDebug(void *ctx ATTRIBUTE_UNUSED,
770 const xmlChar *localname,
771 const xmlChar *prefix,
772 const xmlChar *URI)
773{
774 callbacks++;
775 if (quiet)
776 return;
777 fprintf(stdout, "SAX.endElementNs(%s", (char *) localname);
778 if (prefix == NULL)
779 fprintf(stdout, ", NULL");
780 else
781 fprintf(stdout, ", %s", (char *) prefix);
782 if (URI == NULL)
783 fprintf(stdout, ", NULL)\n");
784 else
785 fprintf(stdout, ", '%s')\n", (char *) URI);
786}
787
Daniel Veillard0fb18932003-09-07 09:14:37 +0000788xmlSAXHandler debugSAX2HandlerStruct = {
789 internalSubsetDebug,
790 isStandaloneDebug,
791 hasInternalSubsetDebug,
792 hasExternalSubsetDebug,
793 resolveEntityDebug,
794 getEntityDebug,
795 entityDeclDebug,
796 notationDeclDebug,
797 attributeDeclDebug,
798 elementDeclDebug,
799 unparsedEntityDeclDebug,
800 setDocumentLocatorDebug,
801 startDocumentDebug,
802 endDocumentDebug,
803 NULL,
804 NULL,
805 referenceDebug,
806 charactersDebug,
807 ignorableWhitespaceDebug,
808 processingInstructionDebug,
809 commentDebug,
810 warningDebug,
811 errorDebug,
812 fatalErrorDebug,
813 getParameterEntityDebug,
814 cdataBlockDebug,
815 externalSubsetDebug,
Daniel Veillard07cb8222003-09-10 10:51:05 +0000816 XML_SAX2_MAGIC,
Daniel Veillard0fb18932003-09-07 09:14:37 +0000817 NULL,
818 startElementNsDebug,
Daniel Veillard07cb8222003-09-10 10:51:05 +0000819 endElementNsDebug
Daniel Veillard0fb18932003-09-07 09:14:37 +0000820};
821
822xmlSAXHandlerPtr debugSAX2Handler = &debugSAX2HandlerStruct;
823
Daniel Veillard5099ae81999-04-21 20:12:07 +0000824/************************************************************************
825 * *
826 * Debug *
827 * *
828 ************************************************************************/
829
Daniel Veillard56a4cb82001-03-24 17:00:36 +0000830static void
831parseAndPrintFile(char *filename) {
Daniel Veillard7a66ee61999-09-26 11:31:02 +0000832 int res;
Daniel Veillard5099ae81999-04-21 20:12:07 +0000833
Daniel Veillarddbfd6411999-12-28 16:35:14 +0000834 if (push) {
835 FILE *f;
Daniel Veillard5099ae81999-04-21 20:12:07 +0000836
Daniel Veillard0fb18932003-09-07 09:14:37 +0000837 if ((!quiet) && (!nonull)) {
838 /*
839 * Empty callbacks for checking
840 */
841 f = fopen(filename, "r");
842 if (f != NULL) {
843 int ret;
844 char chars[10];
845 xmlParserCtxtPtr ctxt;
Daniel Veillarddbfd6411999-12-28 16:35:14 +0000846
Daniel Veillard0fb18932003-09-07 09:14:37 +0000847 ret = fread(chars, 1, 4, f);
848 if (ret > 0) {
849 ctxt = xmlCreatePushParserCtxt(emptySAXHandler, NULL,
850 chars, ret, filename);
851 while ((ret = fread(chars, 1, 3, f)) > 0) {
852 xmlParseChunk(ctxt, chars, ret, 0);
853 }
854 xmlParseChunk(ctxt, chars, 0, 1);
855 xmlFreeParserCtxt(ctxt);
Daniel Veillarddbfd6411999-12-28 16:35:14 +0000856 }
Daniel Veillard0fb18932003-09-07 09:14:37 +0000857 fclose(f);
858 } else {
859 xmlGenericError(xmlGenericErrorContext,
860 "Cannot read file %s\n", filename);
Daniel Veillarddbfd6411999-12-28 16:35:14 +0000861 }
Daniel Veillarddbfd6411999-12-28 16:35:14 +0000862 }
863 /*
864 * Debug callback
865 */
866 f = fopen(filename, "r");
867 if (f != NULL) {
Daniel Veillard56a4cb82001-03-24 17:00:36 +0000868 int ret;
Daniel Veillarddbfd6411999-12-28 16:35:14 +0000869 char chars[10];
870 xmlParserCtxtPtr ctxt;
871
Daniel Veillard56a4cb82001-03-24 17:00:36 +0000872 ret = fread(chars, 1, 4, f);
873 if (ret > 0) {
Daniel Veillard0fb18932003-09-07 09:14:37 +0000874 if (sax2)
875 ctxt = xmlCreatePushParserCtxt(debugSAX2Handler, NULL,
876 chars, ret, filename);
877 else
878 ctxt = xmlCreatePushParserCtxt(debugSAXHandler, NULL,
879 chars, ret, filename);
Daniel Veillard56a4cb82001-03-24 17:00:36 +0000880 while ((ret = fread(chars, 1, 3, f)) > 0) {
881 xmlParseChunk(ctxt, chars, ret, 0);
Daniel Veillarddbfd6411999-12-28 16:35:14 +0000882 }
Daniel Veillard56a4cb82001-03-24 17:00:36 +0000883 ret = xmlParseChunk(ctxt, chars, 0, 1);
Daniel Veillarddbfd6411999-12-28 16:35:14 +0000884 xmlFreeParserCtxt(ctxt);
Daniel Veillard56a4cb82001-03-24 17:00:36 +0000885 if (ret != 0) {
Daniel Veillarddbfd6411999-12-28 16:35:14 +0000886 fprintf(stdout,
Daniel Veillard56a4cb82001-03-24 17:00:36 +0000887 "xmlSAXUserParseFile returned error %d\n", ret);
Daniel Veillarddbfd6411999-12-28 16:35:14 +0000888 }
889 }
890 fclose(f);
891 }
892 } else {
Daniel Veillard5e873c42000-04-12 13:27:38 +0000893 if (!speed) {
894 /*
895 * Empty callbacks for checking
896 */
Daniel Veillard0fb18932003-09-07 09:14:37 +0000897 if ((!quiet) && (!nonull)) {
Daniel Veillarde50f3b52002-03-20 19:24:21 +0000898 res = xmlSAXUserParseFile(emptySAXHandler, NULL, filename);
899 if (res != 0) {
900 fprintf(stdout, "xmlSAXUserParseFile returned error %d\n", res);
901 }
Daniel Veillard5e873c42000-04-12 13:27:38 +0000902 }
Daniel Veillarddbfd6411999-12-28 16:35:14 +0000903
Daniel Veillard5e873c42000-04-12 13:27:38 +0000904 /*
905 * Debug callback
906 */
Daniel Veillarde50f3b52002-03-20 19:24:21 +0000907 callbacks = 0;
Daniel Veillard0fb18932003-09-07 09:14:37 +0000908 if (sax2)
909 res = xmlSAXUserParseFile(debugSAX2Handler, NULL, filename);
910 else
911 res = xmlSAXUserParseFile(debugSAXHandler, NULL, filename);
Daniel Veillard5e873c42000-04-12 13:27:38 +0000912 if (res != 0) {
913 fprintf(stdout, "xmlSAXUserParseFile returned error %d\n", res);
914 }
Daniel Veillarde50f3b52002-03-20 19:24:21 +0000915 if (quiet)
916 fprintf(stdout, "%d callbacks generated\n", callbacks);
Daniel Veillard5e873c42000-04-12 13:27:38 +0000917 } else {
918 /*
919 * test 100x the SAX parse
920 */
921 int i;
922
923 for (i = 0; i<100;i++)
924 res = xmlSAXUserParseFile(emptySAXHandler, NULL, filename);
925 if (res != 0) {
926 fprintf(stdout, "xmlSAXUserParseFile returned error %d\n", res);
927 }
Daniel Veillarddbfd6411999-12-28 16:35:14 +0000928 }
Daniel Veillard5099ae81999-04-21 20:12:07 +0000929 }
930}
931
Daniel Veillard5099ae81999-04-21 20:12:07 +0000932
933int main(int argc, char **argv) {
934 int i;
935 int files = 0;
936
937 for (i = 1; i < argc ; i++) {
938 if ((!strcmp(argv[i], "-debug")) || (!strcmp(argv[i], "--debug")))
939 debug++;
940 else if ((!strcmp(argv[i], "-copy")) || (!strcmp(argv[i], "--copy")))
941 copy++;
942 else if ((!strcmp(argv[i], "-recover")) ||
943 (!strcmp(argv[i], "--recover")))
944 recovery++;
Daniel Veillarddbfd6411999-12-28 16:35:14 +0000945 else if ((!strcmp(argv[i], "-push")) ||
946 (!strcmp(argv[i], "--push")))
947 push++;
Daniel Veillard5e873c42000-04-12 13:27:38 +0000948 else if ((!strcmp(argv[i], "-speed")) ||
949 (!strcmp(argv[i], "--speed")))
950 speed++;
Daniel Veillard5997aca2002-03-18 18:36:20 +0000951 else if ((!strcmp(argv[i], "-noent")) ||
952 (!strcmp(argv[i], "--noent")))
953 noent++;
Daniel Veillarde50f3b52002-03-20 19:24:21 +0000954 else if ((!strcmp(argv[i], "-quiet")) ||
955 (!strcmp(argv[i], "--quiet")))
956 quiet++;
Daniel Veillard0fb18932003-09-07 09:14:37 +0000957 else if ((!strcmp(argv[i], "-sax2")) ||
958 (!strcmp(argv[i], "--sax2")))
959 sax2++;
960 else if ((!strcmp(argv[i], "-nonull")) ||
961 (!strcmp(argv[i], "--nonull")))
962 nonull++;
Daniel Veillard5099ae81999-04-21 20:12:07 +0000963 }
Daniel Veillard5997aca2002-03-18 18:36:20 +0000964 if (noent != 0) xmlSubstituteEntitiesDefault(1);
Daniel Veillard5099ae81999-04-21 20:12:07 +0000965 for (i = 1; i < argc ; i++) {
966 if (argv[i][0] != '-') {
967 parseAndPrintFile(argv[i]);
968 files ++;
969 }
970 }
Daniel Veillardf5c2c871999-12-01 09:51:45 +0000971 xmlCleanupParser();
972 xmlMemoryDump();
Daniel Veillard5099ae81999-04-21 20:12:07 +0000973
974 return(0);
975}