OLD | NEW |
1 /* | 1 /* |
2 * xmllint.c : a small tester program for XML input. | 2 * xmllint.c : a small tester program for XML input. |
3 * | 3 * |
4 * See Copyright for the status of this software. | 4 * See Copyright for the status of this software. |
5 * | 5 * |
6 * daniel@veillard.com | 6 * daniel@veillard.com |
7 */ | 7 */ |
8 | 8 |
9 #include "libxml.h" | 9 #include "libxml.h" |
10 | 10 |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 #ifdef LIBXML_OUTPUT_ENABLED | 101 #ifdef LIBXML_OUTPUT_ENABLED |
102 #include <libxml/xmlsave.h> | 102 #include <libxml/xmlsave.h> |
103 #endif | 103 #endif |
104 | 104 |
105 #ifndef XML_XML_DEFAULT_CATALOG | 105 #ifndef XML_XML_DEFAULT_CATALOG |
106 #define XML_XML_DEFAULT_CATALOG "file:///etc/xml/catalog" | 106 #define XML_XML_DEFAULT_CATALOG "file:///etc/xml/catalog" |
107 #endif | 107 #endif |
108 | 108 |
109 typedef enum { | 109 typedef enum { |
110 XMLLINT_RETURN_OK = 0, /* No error */ | 110 XMLLINT_RETURN_OK = 0, /* No error */ |
111 XMLLINT_ERR_UNCLASS,» /* Unclassified */ | 111 XMLLINT_ERR_UNCLASS = 1,» /* Unclassified */ |
112 XMLLINT_ERR_DTD,» » /* Error in DTD */ | 112 XMLLINT_ERR_DTD = 2,» /* Error in DTD */ |
113 XMLLINT_ERR_VALID,» » /* Validation error */ | 113 XMLLINT_ERR_VALID = 3,» /* Validation error */ |
114 XMLLINT_ERR_RDFILE,»» /* CtxtReadFile error */ | 114 XMLLINT_ERR_RDFILE = 4,» /* CtxtReadFile error */ |
115 XMLLINT_ERR_SCHEMACOMP,» /* Schema compilation */ | 115 XMLLINT_ERR_SCHEMACOMP = 5,»/* Schema compilation */ |
116 XMLLINT_ERR_OUT,» » /* Error writing output */ | 116 XMLLINT_ERR_OUT = 6,» /* Error writing output */ |
117 XMLLINT_ERR_SCHEMAPAT,» /* Error in schema pattern */ | 117 XMLLINT_ERR_SCHEMAPAT = 7,» /* Error in schema pattern */ |
118 XMLLINT_ERR_RDREGIS,» /* Error in Reader registration */ | 118 XMLLINT_ERR_RDREGIS = 8,» /* Error in Reader registration */ |
119 XMLLINT_ERR_MEM» » /* Out of memory error */ | 119 XMLLINT_ERR_MEM = 9,» /* Out of memory error */ |
| 120 XMLLINT_ERR_XPATH = 10» /* XPath evaluation error */ |
120 } xmllintReturnCode; | 121 } xmllintReturnCode; |
121 #ifdef LIBXML_DEBUG_ENABLED | 122 #ifdef LIBXML_DEBUG_ENABLED |
122 static int shell = 0; | 123 static int shell = 0; |
123 static int debugent = 0; | 124 static int debugent = 0; |
124 #endif | 125 #endif |
125 static int debug = 0; | 126 static int debug = 0; |
126 static int maxmem = 0; | 127 static int maxmem = 0; |
127 #ifdef LIBXML_TREE_ENABLED | 128 #ifdef LIBXML_TREE_ENABLED |
128 static int copy = 0; | 129 static int copy = 0; |
129 #endif /* LIBXML_TREE_ENABLED */ | 130 #endif /* LIBXML_TREE_ENABLED */ |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 static xmllintReturnCode progresult = XMLLINT_RETURN_OK; | 178 static xmllintReturnCode progresult = XMLLINT_RETURN_OK; |
178 static int timing = 0; | 179 static int timing = 0; |
179 static int generate = 0; | 180 static int generate = 0; |
180 static int dropdtd = 0; | 181 static int dropdtd = 0; |
181 #ifdef LIBXML_CATALOG_ENABLED | 182 #ifdef LIBXML_CATALOG_ENABLED |
182 static int catalogs = 0; | 183 static int catalogs = 0; |
183 static int nocatalogs = 0; | 184 static int nocatalogs = 0; |
184 #endif | 185 #endif |
185 #ifdef LIBXML_C14N_ENABLED | 186 #ifdef LIBXML_C14N_ENABLED |
186 static int canonical = 0; | 187 static int canonical = 0; |
| 188 static int canonical_11 = 0; |
187 static int exc_canonical = 0; | 189 static int exc_canonical = 0; |
188 #endif | 190 #endif |
189 #ifdef LIBXML_READER_ENABLED | 191 #ifdef LIBXML_READER_ENABLED |
190 static int stream = 0; | 192 static int stream = 0; |
191 static int walker = 0; | 193 static int walker = 0; |
192 #endif /* LIBXML_READER_ENABLED */ | 194 #endif /* LIBXML_READER_ENABLED */ |
193 static int chkregister = 0; | 195 static int chkregister = 0; |
194 static int nbregister = 0; | 196 static int nbregister = 0; |
195 #ifdef LIBXML_SAX1_ENABLED | 197 #ifdef LIBXML_SAX1_ENABLED |
196 static int sax1 = 0; | 198 static int sax1 = 0; |
197 #endif /* LIBXML_SAX1_ENABLED */ | 199 #endif /* LIBXML_SAX1_ENABLED */ |
198 #ifdef LIBXML_PATTERN_ENABLED | 200 #ifdef LIBXML_PATTERN_ENABLED |
199 static const char *pattern = NULL; | 201 static const char *pattern = NULL; |
200 static xmlPatternPtr patternc = NULL; | 202 static xmlPatternPtr patternc = NULL; |
201 static xmlStreamCtxtPtr patstream = NULL; | 203 static xmlStreamCtxtPtr patstream = NULL; |
202 #endif | 204 #endif |
| 205 #ifdef LIBXML_XPATH_ENABLED |
| 206 static const char *xpathquery = NULL; |
| 207 #endif |
203 static int options = XML_PARSE_COMPACT; | 208 static int options = XML_PARSE_COMPACT; |
204 static int sax = 0; | 209 static int sax = 0; |
| 210 static int oldxml10 = 0; |
205 | 211 |
206 /************************************************************************ | 212 /************************************************************************ |
207 * * | 213 * * |
208 * Entity loading control and customization. * | 214 * Entity loading control and customization. * |
209 * * | 215 * * |
210 ************************************************************************/ | 216 ************************************************************************/ |
211 #define MAX_PATHS 64 | 217 #define MAX_PATHS 64 |
212 #ifdef _WIN32 | 218 #ifdef _WIN32 |
213 # define PATH_SEPARATOR ';' | 219 # define PATH_SEPARATOR ';' |
214 #else | 220 #else |
(...skipping 24 matching lines...) Expand all Loading... |
239 paths[nbpaths] = xmlStrndup(path, cur - path); | 245 paths[nbpaths] = xmlStrndup(path, cur - path); |
240 if (paths[nbpaths] != NULL) | 246 if (paths[nbpaths] != NULL) |
241 nbpaths++; | 247 nbpaths++; |
242 path = cur; | 248 path = cur; |
243 } | 249 } |
244 } | 250 } |
245 } | 251 } |
246 | 252 |
247 static xmlExternalEntityLoader defaultEntityLoader = NULL; | 253 static xmlExternalEntityLoader defaultEntityLoader = NULL; |
248 | 254 |
249 static xmlParserInputPtr | 255 static xmlParserInputPtr |
250 xmllintExternalEntityLoader(const char *URL, const char *ID, | 256 xmllintExternalEntityLoader(const char *URL, const char *ID, |
251 xmlParserCtxtPtr ctxt) { | 257 xmlParserCtxtPtr ctxt) { |
252 xmlParserInputPtr ret; | 258 xmlParserInputPtr ret; |
253 warningSAXFunc warning = NULL; | 259 warningSAXFunc warning = NULL; |
254 errorSAXFunc err = NULL; | 260 errorSAXFunc err = NULL; |
255 | 261 |
256 int i; | 262 int i; |
257 const char *lastsegment = URL; | 263 const char *lastsegment = URL; |
258 const char *iter = URL; | 264 const char *iter = URL; |
259 | 265 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
297 newURL = xmlStrcat(newURL, (const xmlChar *) lastsegment); | 303 newURL = xmlStrcat(newURL, (const xmlChar *) lastsegment); |
298 if (newURL != NULL) { | 304 if (newURL != NULL) { |
299 ret = defaultEntityLoader((const char *)newURL, ID, ctxt); | 305 ret = defaultEntityLoader((const char *)newURL, ID, ctxt); |
300 if (ret != NULL) { | 306 if (ret != NULL) { |
301 if (warning != NULL) | 307 if (warning != NULL) |
302 ctxt->sax->warning = warning; | 308 ctxt->sax->warning = warning; |
303 if (err != NULL) | 309 if (err != NULL) |
304 ctxt->sax->error = err; | 310 ctxt->sax->error = err; |
305 if (load_trace) { | 311 if (load_trace) { |
306 fprintf \ | 312 fprintf \ |
307 » » » (stderr, | 313 » » » (stderr, |
308 » » » "Loaded URL=\"%s\" ID=\"%s\"\n", | 314 » » » "Loaded URL=\"%s\" ID=\"%s\"\n", |
309 newURL, | 315 newURL, |
310 » » » ID ? ID : "(null)"); | 316 » » » ID ? ID : "(null)"); |
311 } | 317 } |
312 xmlFree(newURL); | 318 xmlFree(newURL); |
313 return(ret); | 319 return(ret); |
314 } | 320 } |
315 xmlFree(newURL); | 321 xmlFree(newURL); |
316 } | 322 } |
317 } | 323 } |
318 if (err != NULL) | 324 if (err != NULL) |
319 ctxt->sax->error = err; | 325 ctxt->sax->error = err; |
320 if (warning != NULL) { | 326 if (warning != NULL) { |
321 ctxt->sax->warning = warning; | 327 ctxt->sax->warning = warning; |
322 if (URL != NULL) | 328 if (URL != NULL) |
323 warning(ctxt, "failed to load external entity \"%s\"\n", URL); | 329 warning(ctxt, "failed to load external entity \"%s\"\n", URL); |
324 else if (ID != NULL) | 330 else if (ID != NULL) |
325 warning(ctxt, "failed to load external entity \"%s\"\n", ID); | 331 warning(ctxt, "failed to load external entity \"%s\"\n", ID); |
326 } | 332 } |
327 return(NULL); | 333 return(NULL); |
328 } | 334 } |
329 /************************************************************************ | 335 /************************************************************************ |
330 * » » » » » » » » » * | 336 *» » » » » » » » » * |
331 * Memory allocation consumption debugging * | 337 * Memory allocation consumption debugging * |
332 * » » » » » » » » » * | 338 *» » » » » » » » » * |
333 ************************************************************************/ | 339 ************************************************************************/ |
334 | 340 |
335 static void | 341 static void |
336 OOM(void) | 342 OOM(void) |
337 { | 343 { |
338 fprintf(stderr, "Ran out of memory needs > %d bytes\n", maxmem); | 344 fprintf(stderr, "Ran out of memory needs > %d bytes\n", maxmem); |
339 progresult = XMLLINT_ERR_MEM; | 345 progresult = XMLLINT_ERR_MEM; |
340 } | 346 } |
341 | 347 |
342 static void | 348 static void |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
383 if (ret != NULL) { | 389 if (ret != NULL) { |
384 if (xmlMemUsed() > maxmem) { | 390 if (xmlMemUsed() > maxmem) { |
385 OOM(); | 391 OOM(); |
386 xmlFree(ret); | 392 xmlFree(ret); |
387 return (NULL); | 393 return (NULL); |
388 } | 394 } |
389 } | 395 } |
390 return (ret); | 396 return (ret); |
391 } | 397 } |
392 /************************************************************************ | 398 /************************************************************************ |
393 * » » » » » » » » » * | 399 *» » » » » » » » » * |
394 * Internal timing routines to remove the necessity to have * | 400 * Internal timing routines to remove the necessity to have * |
395 * unix-specific function calls. * | 401 * unix-specific function calls. * |
396 * » » » » » » » » » * | 402 *» » » » » » » » » * |
397 ************************************************************************/ | 403 ************************************************************************/ |
398 | 404 |
399 #ifndef HAVE_GETTIMEOFDAY | 405 #ifndef HAVE_GETTIMEOFDAY |
400 #ifdef HAVE_SYS_TIMEB_H | 406 #ifdef HAVE_SYS_TIMEB_H |
401 #ifdef HAVE_SYS_TIME_H | 407 #ifdef HAVE_SYS_TIME_H |
402 #ifdef HAVE_FTIME | 408 #ifdef HAVE_FTIME |
403 | 409 |
404 static int | 410 static int |
405 my_gettimeofday(struct timeval *tvp, void *tzp) | 411 my_gettimeofday(struct timeval *tvp, void *tzp) |
406 { | 412 { |
407 struct timeb timebuffer; | 413 struct timeb timebuffer; |
408 | 414 |
409 ftime(&timebuffer); | 415 ftime(&timebuffer); |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
515 va_end(ap); | 521 va_end(ap); |
516 fprintf(stderr, " was not timed\n", msec); | 522 fprintf(stderr, " was not timed\n", msec); |
517 #else | 523 #else |
518 /* We don't have gettimeofday, time or stdarg.h, what crazy world is | 524 /* We don't have gettimeofday, time or stdarg.h, what crazy world is |
519 * this ?! | 525 * this ?! |
520 */ | 526 */ |
521 #endif | 527 #endif |
522 } | 528 } |
523 #endif | 529 #endif |
524 /************************************************************************ | 530 /************************************************************************ |
525 * » » » » » » » » » * | 531 *» » » » » » » » » * |
526 * » » » HTML ouput» » » » » * | 532 *» » » HTML ouput» » » » » * |
527 * » » » » » » » » » * | 533 *» » » » » » » » » * |
528 ************************************************************************/ | 534 ************************************************************************/ |
529 static char buffer[50000]; | 535 static char buffer[50000]; |
530 | 536 |
531 static void | 537 static void |
532 xmlHTMLEncodeSend(void) { | 538 xmlHTMLEncodeSend(void) { |
533 char *result; | 539 char *result; |
534 | 540 |
535 result = (char *) xmlEncodeEntitiesReentrant(NULL, BAD_CAST buffer); | 541 result = (char *) xmlEncodeEntitiesReentrant(NULL, BAD_CAST buffer); |
536 if (result) { | 542 if (result) { |
537 xmlGenericError(xmlGenericErrorContext, "%s", result); | 543 xmlGenericError(xmlGenericErrorContext, "%s", result); |
538 xmlFree(result); | 544 xmlFree(result); |
539 } | 545 } |
540 buffer[0] = 0; | 546 buffer[0] = 0; |
541 } | 547 } |
542 | 548 |
543 /** | 549 /** |
544 * xmlHTMLPrintFileInfo: | 550 * xmlHTMLPrintFileInfo: |
545 * @input: an xmlParserInputPtr input | 551 * @input: an xmlParserInputPtr input |
546 * | 552 * |
547 * Displays the associated file and line informations for the current input | 553 * Displays the associated file and line informations for the current input |
548 */ | 554 */ |
549 | 555 |
550 static void | 556 static void |
551 xmlHTMLPrintFileInfo(xmlParserInputPtr input) { | 557 xmlHTMLPrintFileInfo(xmlParserInputPtr input) { |
552 int len; | 558 int len; |
553 xmlGenericError(xmlGenericErrorContext, "<p>"); | 559 xmlGenericError(xmlGenericErrorContext, "<p>"); |
554 | 560 |
555 len = strlen(buffer); | 561 len = strlen(buffer); |
556 if (input != NULL) { | 562 if (input != NULL) { |
557 if (input->filename) { | 563 if (input->filename) { |
558 snprintf(&buffer[len], sizeof(buffer) - len, "%s:%d: ", input->filen
ame, | 564 snprintf(&buffer[len], sizeof(buffer) - len, "%s:%d: ", input->filen
ame, |
559 input->line); | 565 input->line); |
560 } else { | 566 } else { |
561 snprintf(&buffer[len], sizeof(buffer) - len, "Entity: line %d: ", in
put->line); | 567 snprintf(&buffer[len], sizeof(buffer) - len, "Entity: line %d: ", in
put->line); |
562 } | 568 } |
563 } | 569 } |
564 xmlHTMLEncodeSend(); | 570 xmlHTMLEncodeSend(); |
565 } | 571 } |
566 | 572 |
567 /** | 573 /** |
568 * xmlHTMLPrintFileContext: | 574 * xmlHTMLPrintFileContext: |
569 * @input: an xmlParserInputPtr input | 575 * @input: an xmlParserInputPtr input |
570 * | 576 * |
571 * Displays current context within the input content for error tracking | 577 * Displays current context within the input content for error tracking |
572 */ | 578 */ |
573 | 579 |
574 static void | 580 static void |
575 xmlHTMLPrintFileContext(xmlParserInputPtr input) { | 581 xmlHTMLPrintFileContext(xmlParserInputPtr input) { |
576 const xmlChar *cur, *base; | 582 const xmlChar *cur, *base; |
577 int len; | 583 int len; |
578 int n; | 584 int n; |
579 | 585 |
580 if (input == NULL) return; | 586 if (input == NULL) return; |
581 xmlGenericError(xmlGenericErrorContext, "<pre>\n"); | 587 xmlGenericError(xmlGenericErrorContext, "<pre>\n"); |
582 cur = input->cur; | 588 cur = input->cur; |
583 base = input->base; | 589 base = input->base; |
584 while ((cur > base) && ((*cur == '\n') || (*cur == '\r'))) { | 590 while ((cur > base) && ((*cur == '\n') || (*cur == '\r'))) { |
585 cur--; | 591 cur--; |
586 } | 592 } |
587 n = 0; | 593 n = 0; |
588 while ((n++ < 80) && (cur > base) && (*cur != '\n') && (*cur != '\r')) | 594 while ((n++ < 80) && (cur > base) && (*cur != '\n') && (*cur != '\r')) |
589 cur--; | 595 cur--; |
590 if ((*cur == '\n') || (*cur == '\r')) cur++; | 596 if ((*cur == '\n') || (*cur == '\r')) cur++; |
591 base = cur; | 597 base = cur; |
592 n = 0; | 598 n = 0; |
593 while ((*cur != 0) && (*cur != '\n') && (*cur != '\r') && (n < 79)) { | 599 while ((*cur != 0) && (*cur != '\n') && (*cur != '\r') && (n < 79)) { |
594 len = strlen(buffer); | 600 len = strlen(buffer); |
595 snprintf(&buffer[len], sizeof(buffer) - len, "%c", | 601 snprintf(&buffer[len], sizeof(buffer) - len, "%c", |
596 (unsigned char) *cur++); | 602 (unsigned char) *cur++); |
597 n++; | 603 n++; |
598 } | 604 } |
599 len = strlen(buffer); | 605 len = strlen(buffer); |
600 snprintf(&buffer[len], sizeof(buffer) - len, "\n"); | 606 snprintf(&buffer[len], sizeof(buffer) - len, "\n"); |
601 cur = input->cur; | 607 cur = input->cur; |
602 while ((*cur == '\n') || (*cur == '\r')) | 608 while ((*cur == '\n') || (*cur == '\r')) |
603 cur--; | 609 cur--; |
604 n = 0; | 610 n = 0; |
605 while ((cur != base) && (n++ < 80)) { | 611 while ((cur != base) && (n++ < 80)) { |
606 len = strlen(buffer); | 612 len = strlen(buffer); |
607 snprintf(&buffer[len], sizeof(buffer) - len, " "); | 613 snprintf(&buffer[len], sizeof(buffer) - len, " "); |
608 base++; | 614 base++; |
609 } | 615 } |
610 len = strlen(buffer); | 616 len = strlen(buffer); |
611 snprintf(&buffer[len], sizeof(buffer) - len, "^\n"); | 617 snprintf(&buffer[len], sizeof(buffer) - len, "^\n"); |
612 xmlHTMLEncodeSend(); | 618 xmlHTMLEncodeSend(); |
613 xmlGenericError(xmlGenericErrorContext, "</pre>"); | 619 xmlGenericError(xmlGenericErrorContext, "</pre>"); |
614 } | 620 } |
615 | 621 |
616 /** | 622 /** |
617 * xmlHTMLError: | 623 * xmlHTMLError: |
618 * @ctx: an XML parser context | 624 * @ctx: an XML parser context |
619 * @msg: the message to display/transmit | 625 * @msg: the message to display/transmit |
620 * @...: extra parameters for the message display | 626 * @...: extra parameters for the message display |
621 * | 627 * |
622 * Display and format an error messages, gives file, line, position and | 628 * Display and format an error messages, gives file, line, position and |
623 * extra parameters. | 629 * extra parameters. |
624 */ | 630 */ |
625 static void XMLCDECL | 631 static void XMLCDECL |
626 xmlHTMLError(void *ctx, const char *msg, ...) | 632 xmlHTMLError(void *ctx, const char *msg, ...) |
627 { | 633 { |
628 xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx; | 634 xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx; |
629 xmlParserInputPtr input; | 635 xmlParserInputPtr input; |
630 va_list args; | 636 va_list args; |
631 int len; | 637 int len; |
632 | 638 |
633 buffer[0] = 0; | 639 buffer[0] = 0; |
634 input = ctxt->input; | 640 input = ctxt->input; |
635 if ((input != NULL) && (input->filename == NULL) && (ctxt->inputNr > 1)) { | 641 if ((input != NULL) && (input->filename == NULL) && (ctxt->inputNr > 1)) { |
636 input = ctxt->inputTab[ctxt->inputNr - 2]; | 642 input = ctxt->inputTab[ctxt->inputNr - 2]; |
637 } | 643 } |
638 | 644 |
639 xmlHTMLPrintFileInfo(input); | 645 xmlHTMLPrintFileInfo(input); |
640 | 646 |
641 xmlGenericError(xmlGenericErrorContext, "<b>error</b>: "); | 647 xmlGenericError(xmlGenericErrorContext, "<b>error</b>: "); |
642 va_start(args, msg); | 648 va_start(args, msg); |
643 len = strlen(buffer); | 649 len = strlen(buffer); |
644 vsnprintf(&buffer[len], sizeof(buffer) - len, msg, args); | 650 vsnprintf(&buffer[len], sizeof(buffer) - len, msg, args); |
645 va_end(args); | 651 va_end(args); |
646 xmlHTMLEncodeSend(); | 652 xmlHTMLEncodeSend(); |
647 xmlGenericError(xmlGenericErrorContext, "</p>\n"); | 653 xmlGenericError(xmlGenericErrorContext, "</p>\n"); |
648 | 654 |
649 xmlHTMLPrintFileContext(input); | 655 xmlHTMLPrintFileContext(input); |
650 xmlHTMLEncodeSend(); | 656 xmlHTMLEncodeSend(); |
651 } | 657 } |
652 | 658 |
653 /** | 659 /** |
654 * xmlHTMLWarning: | 660 * xmlHTMLWarning: |
655 * @ctx: an XML parser context | 661 * @ctx: an XML parser context |
656 * @msg: the message to display/transmit | 662 * @msg: the message to display/transmit |
657 * @...: extra parameters for the message display | 663 * @...: extra parameters for the message display |
658 * | 664 * |
659 * Display and format a warning messages, gives file, line, position and | 665 * Display and format a warning messages, gives file, line, position and |
660 * extra parameters. | 666 * extra parameters. |
661 */ | 667 */ |
662 static void XMLCDECL | 668 static void XMLCDECL |
663 xmlHTMLWarning(void *ctx, const char *msg, ...) | 669 xmlHTMLWarning(void *ctx, const char *msg, ...) |
664 { | 670 { |
665 xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx; | 671 xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx; |
666 xmlParserInputPtr input; | 672 xmlParserInputPtr input; |
667 va_list args; | 673 va_list args; |
668 int len; | 674 int len; |
669 | 675 |
670 buffer[0] = 0; | 676 buffer[0] = 0; |
671 input = ctxt->input; | 677 input = ctxt->input; |
672 if ((input != NULL) && (input->filename == NULL) && (ctxt->inputNr > 1)) { | 678 if ((input != NULL) && (input->filename == NULL) && (ctxt->inputNr > 1)) { |
673 input = ctxt->inputTab[ctxt->inputNr - 2]; | 679 input = ctxt->inputTab[ctxt->inputNr - 2]; |
674 } | 680 } |
675 | 681 |
676 | 682 |
677 xmlHTMLPrintFileInfo(input); | 683 xmlHTMLPrintFileInfo(input); |
678 | 684 |
679 xmlGenericError(xmlGenericErrorContext, "<b>warning</b>: "); | 685 xmlGenericError(xmlGenericErrorContext, "<b>warning</b>: "); |
680 va_start(args, msg); | 686 va_start(args, msg); |
681 len = strlen(buffer); | 687 len = strlen(buffer); |
682 vsnprintf(&buffer[len], sizeof(buffer) - len, msg, args); | 688 vsnprintf(&buffer[len], sizeof(buffer) - len, msg, args); |
683 va_end(args); | 689 va_end(args); |
684 xmlHTMLEncodeSend(); | 690 xmlHTMLEncodeSend(); |
685 xmlGenericError(xmlGenericErrorContext, "</p>\n"); | 691 xmlGenericError(xmlGenericErrorContext, "</p>\n"); |
686 | 692 |
687 xmlHTMLPrintFileContext(input); | 693 xmlHTMLPrintFileContext(input); |
688 xmlHTMLEncodeSend(); | 694 xmlHTMLEncodeSend(); |
689 } | 695 } |
690 | 696 |
691 /** | 697 /** |
692 * xmlHTMLValidityError: | 698 * xmlHTMLValidityError: |
693 * @ctx: an XML parser context | 699 * @ctx: an XML parser context |
694 * @msg: the message to display/transmit | 700 * @msg: the message to display/transmit |
695 * @...: extra parameters for the message display | 701 * @...: extra parameters for the message display |
696 * | 702 * |
697 * Display and format an validity error messages, gives file, | 703 * Display and format an validity error messages, gives file, |
698 * line, position and extra parameters. | 704 * line, position and extra parameters. |
699 */ | 705 */ |
700 static void XMLCDECL | 706 static void XMLCDECL |
701 xmlHTMLValidityError(void *ctx, const char *msg, ...) | 707 xmlHTMLValidityError(void *ctx, const char *msg, ...) |
702 { | 708 { |
703 xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx; | 709 xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx; |
704 xmlParserInputPtr input; | 710 xmlParserInputPtr input; |
705 va_list args; | 711 va_list args; |
706 int len; | 712 int len; |
707 | 713 |
708 buffer[0] = 0; | 714 buffer[0] = 0; |
709 input = ctxt->input; | 715 input = ctxt->input; |
710 if ((input->filename == NULL) && (ctxt->inputNr > 1)) | 716 if ((input->filename == NULL) && (ctxt->inputNr > 1)) |
711 input = ctxt->inputTab[ctxt->inputNr - 2]; | 717 input = ctxt->inputTab[ctxt->inputNr - 2]; |
712 | 718 |
713 xmlHTMLPrintFileInfo(input); | 719 xmlHTMLPrintFileInfo(input); |
714 | 720 |
715 xmlGenericError(xmlGenericErrorContext, "<b>validity error</b>: "); | 721 xmlGenericError(xmlGenericErrorContext, "<b>validity error</b>: "); |
716 len = strlen(buffer); | 722 len = strlen(buffer); |
717 va_start(args, msg); | 723 va_start(args, msg); |
718 vsnprintf(&buffer[len], sizeof(buffer) - len, msg, args); | 724 vsnprintf(&buffer[len], sizeof(buffer) - len, msg, args); |
719 va_end(args); | 725 va_end(args); |
720 xmlHTMLEncodeSend(); | 726 xmlHTMLEncodeSend(); |
721 xmlGenericError(xmlGenericErrorContext, "</p>\n"); | 727 xmlGenericError(xmlGenericErrorContext, "</p>\n"); |
722 | 728 |
723 xmlHTMLPrintFileContext(input); | 729 xmlHTMLPrintFileContext(input); |
724 xmlHTMLEncodeSend(); | 730 xmlHTMLEncodeSend(); |
725 progresult = XMLLINT_ERR_VALID; | 731 progresult = XMLLINT_ERR_VALID; |
726 } | 732 } |
727 | 733 |
728 /** | 734 /** |
729 * xmlHTMLValidityWarning: | 735 * xmlHTMLValidityWarning: |
730 * @ctx: an XML parser context | 736 * @ctx: an XML parser context |
731 * @msg: the message to display/transmit | 737 * @msg: the message to display/transmit |
732 * @...: extra parameters for the message display | 738 * @...: extra parameters for the message display |
733 * | 739 * |
734 * Display and format a validity warning messages, gives file, line, | 740 * Display and format a validity warning messages, gives file, line, |
735 * position and extra parameters. | 741 * position and extra parameters. |
736 */ | 742 */ |
737 static void XMLCDECL | 743 static void XMLCDECL |
738 xmlHTMLValidityWarning(void *ctx, const char *msg, ...) | 744 xmlHTMLValidityWarning(void *ctx, const char *msg, ...) |
739 { | 745 { |
740 xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx; | 746 xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx; |
741 xmlParserInputPtr input; | 747 xmlParserInputPtr input; |
742 va_list args; | 748 va_list args; |
743 int len; | 749 int len; |
744 | 750 |
745 buffer[0] = 0; | 751 buffer[0] = 0; |
746 input = ctxt->input; | 752 input = ctxt->input; |
747 if ((input->filename == NULL) && (ctxt->inputNr > 1)) | 753 if ((input->filename == NULL) && (ctxt->inputNr > 1)) |
748 input = ctxt->inputTab[ctxt->inputNr - 2]; | 754 input = ctxt->inputTab[ctxt->inputNr - 2]; |
749 | 755 |
750 xmlHTMLPrintFileInfo(input); | 756 xmlHTMLPrintFileInfo(input); |
751 | 757 |
752 xmlGenericError(xmlGenericErrorContext, "<b>validity warning</b>: "); | 758 xmlGenericError(xmlGenericErrorContext, "<b>validity warning</b>: "); |
753 va_start(args, msg); | 759 va_start(args, msg); |
754 len = strlen(buffer); | 760 len = strlen(buffer); |
755 vsnprintf(&buffer[len], sizeof(buffer) - len, msg, args); | 761 vsnprintf(&buffer[len], sizeof(buffer) - len, msg, args); |
756 va_end(args); | 762 va_end(args); |
757 xmlHTMLEncodeSend(); | 763 xmlHTMLEncodeSend(); |
758 xmlGenericError(xmlGenericErrorContext, "</p>\n"); | 764 xmlGenericError(xmlGenericErrorContext, "</p>\n"); |
759 | 765 |
760 xmlHTMLPrintFileContext(input); | 766 xmlHTMLPrintFileContext(input); |
761 xmlHTMLEncodeSend(); | 767 xmlHTMLEncodeSend(); |
762 } | 768 } |
763 | 769 |
764 /************************************************************************ | 770 /************************************************************************ |
765 * » » » » » » » » » * | 771 *» » » » » » » » » * |
766 * » » » Shell Interface»» » » » * | 772 *» » » Shell Interface»» » » » * |
767 * » » » » » » » » » * | 773 *» » » » » » » » » * |
768 ************************************************************************/ | 774 ************************************************************************/ |
769 #ifdef LIBXML_DEBUG_ENABLED | 775 #ifdef LIBXML_DEBUG_ENABLED |
770 #ifdef LIBXML_XPATH_ENABLED | 776 #ifdef LIBXML_XPATH_ENABLED |
771 /** | 777 /** |
772 * xmlShellReadline: | 778 * xmlShellReadline: |
773 * @prompt: the prompt value | 779 * @prompt: the prompt value |
774 * | 780 * |
775 * Read a string | 781 * Read a string |
776 * | 782 * |
777 * Returns a pointer to it or NULL on EOF the caller is expected to | 783 * Returns a pointer to it or NULL on EOF the caller is expected to |
778 * free the returned string. | 784 * free the returned string. |
779 */ | 785 */ |
780 static char * | 786 static char * |
781 xmlShellReadline(char *prompt) { | 787 xmlShellReadline(char *prompt) { |
782 #ifdef HAVE_LIBREADLINE | 788 #ifdef HAVE_LIBREADLINE |
783 char *line_read; | 789 char *line_read; |
784 | 790 |
785 /* Get a line from the user. */ | 791 /* Get a line from the user. */ |
786 line_read = readline (prompt); | 792 line_read = readline (prompt); |
(...skipping 18 matching lines...) Expand all Loading... |
805 if (ret != NULL) { | 811 if (ret != NULL) { |
806 memcpy (ret, line_read, len + 1); | 812 memcpy (ret, line_read, len + 1); |
807 } | 813 } |
808 return(ret); | 814 return(ret); |
809 #endif | 815 #endif |
810 } | 816 } |
811 #endif /* LIBXML_XPATH_ENABLED */ | 817 #endif /* LIBXML_XPATH_ENABLED */ |
812 #endif /* LIBXML_DEBUG_ENABLED */ | 818 #endif /* LIBXML_DEBUG_ENABLED */ |
813 | 819 |
814 /************************************************************************ | 820 /************************************************************************ |
815 * » » » » » » » » » * | 821 *» » » » » » » » » * |
816 * » » » I/O Interfaces» » » » » * | 822 *» » » I/O Interfaces» » » » » * |
817 * » » » » » » » » » * | 823 *» » » » » » » » » * |
818 ************************************************************************/ | 824 ************************************************************************/ |
819 | 825 |
820 static int myRead(FILE *f, char * buf, int len) { | 826 static int myRead(FILE *f, char * buf, int len) { |
821 return(fread(buf, 1, len, f)); | 827 return(fread(buf, 1, len, f)); |
822 } | 828 } |
823 static void myClose(FILE *f) { | 829 static void myClose(FILE *f) { |
824 if (f != stdin) { | 830 if (f != stdin) { |
825 fclose(f); | 831 fclose(f); |
826 } | 832 } |
827 } | 833 } |
828 | 834 |
829 /************************************************************************ | 835 /************************************************************************ |
830 * * | 836 * * |
831 *» » » SAX based tests»» » » » * | 837 *» » » SAX based tests»» » » » * |
832 * * | 838 * * |
833 ************************************************************************/ | 839 ************************************************************************/ |
834 | 840 |
835 /* | 841 /* |
836 * empty SAX block | 842 * empty SAX block |
837 */ | 843 */ |
838 static xmlSAXHandler emptySAXHandlerStruct = { | 844 static xmlSAXHandler emptySAXHandlerStruct = { |
839 NULL, /* internalSubset */ | 845 NULL, /* internalSubset */ |
840 NULL, /* isStandalone */ | 846 NULL, /* isStandalone */ |
841 NULL, /* hasInternalSubset */ | 847 NULL, /* hasInternalSubset */ |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
991 * Returns the xmlParserInputPtr if inlined or NULL for DOM behaviour. | 997 * Returns the xmlParserInputPtr if inlined or NULL for DOM behaviour. |
992 */ | 998 */ |
993 static xmlParserInputPtr | 999 static xmlParserInputPtr |
994 resolveEntityDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *publicId, const xm
lChar *systemId) | 1000 resolveEntityDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *publicId, const xm
lChar *systemId) |
995 { | 1001 { |
996 callbacks++; | 1002 callbacks++; |
997 if (noout) | 1003 if (noout) |
998 return(NULL); | 1004 return(NULL); |
999 /* xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx; */ | 1005 /* xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx; */ |
1000 | 1006 |
1001 | 1007 |
1002 fprintf(stdout, "SAX.resolveEntity("); | 1008 fprintf(stdout, "SAX.resolveEntity("); |
1003 if (publicId != NULL) | 1009 if (publicId != NULL) |
1004 fprintf(stdout, "%s", (char *)publicId); | 1010 fprintf(stdout, "%s", (char *)publicId); |
1005 else | 1011 else |
1006 fprintf(stdout, " "); | 1012 fprintf(stdout, " "); |
1007 if (systemId != NULL) | 1013 if (systemId != NULL) |
1008 fprintf(stdout, ", %s)\n", (char *)systemId); | 1014 fprintf(stdout, ", %s)\n", (char *)systemId); |
1009 else | 1015 else |
1010 fprintf(stdout, ", )\n"); | 1016 fprintf(stdout, ", )\n"); |
1011 return(NULL); | 1017 return(NULL); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1046 if (noout) | 1052 if (noout) |
1047 return(NULL); | 1053 return(NULL); |
1048 fprintf(stdout, "SAX.getParameterEntity(%s)\n", name); | 1054 fprintf(stdout, "SAX.getParameterEntity(%s)\n", name); |
1049 return(NULL); | 1055 return(NULL); |
1050 } | 1056 } |
1051 | 1057 |
1052 | 1058 |
1053 /** | 1059 /** |
1054 * entityDeclDebug: | 1060 * entityDeclDebug: |
1055 * @ctxt: An XML parser context | 1061 * @ctxt: An XML parser context |
1056 * @name: the entity name | 1062 * @name: the entity name |
1057 * @type: the entity type | 1063 * @type: the entity type |
1058 * @publicId: The public ID of the entity | 1064 * @publicId: The public ID of the entity |
1059 * @systemId: The system ID of the entity | 1065 * @systemId: The system ID of the entity |
1060 * @content: the entity value (without processing). | 1066 * @content: the entity value (without processing). |
1061 * | 1067 * |
1062 * An entity definition has been parsed | 1068 * An entity definition has been parsed |
1063 */ | 1069 */ |
1064 static void | 1070 static void |
1065 entityDeclDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *name, int type, | 1071 entityDeclDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *name, int type, |
1066 const xmlChar *publicId, const xmlChar *systemId, xmlChar *content) | 1072 const xmlChar *publicId, const xmlChar *systemId, xmlChar *content) |
1067 { | 1073 { |
1068 const xmlChar *nullstr = BAD_CAST "(null)"; | 1074 const xmlChar *nullstr = BAD_CAST "(null)"; |
1069 /* not all libraries handle printing null pointers nicely */ | 1075 /* not all libraries handle printing null pointers nicely */ |
1070 if (publicId == NULL) | 1076 if (publicId == NULL) |
1071 publicId = nullstr; | 1077 publicId = nullstr; |
1072 if (systemId == NULL) | 1078 if (systemId == NULL) |
1073 systemId = nullstr; | 1079 systemId = nullstr; |
1074 if (content == NULL) | 1080 if (content == NULL) |
1075 content = (xmlChar *)nullstr; | 1081 content = (xmlChar *)nullstr; |
1076 callbacks++; | 1082 callbacks++; |
1077 if (noout) | 1083 if (noout) |
1078 return; | 1084 return; |
1079 fprintf(stdout, "SAX.entityDecl(%s, %d, %s, %s, %s)\n", | 1085 fprintf(stdout, "SAX.entityDecl(%s, %d, %s, %s, %s)\n", |
1080 name, type, publicId, systemId, content); | 1086 name, type, publicId, systemId, content); |
1081 } | 1087 } |
1082 | 1088 |
1083 /** | 1089 /** |
1084 * attributeDeclDebug: | 1090 * attributeDeclDebug: |
1085 * @ctxt: An XML parser context | 1091 * @ctxt: An XML parser context |
1086 * @name: the attribute name | 1092 * @name: the attribute name |
1087 * @type: the attribute type | 1093 * @type: the attribute type |
1088 * | 1094 * |
1089 * An attribute definition has been parsed | 1095 * An attribute definition has been parsed |
1090 */ | 1096 */ |
1091 static void | 1097 static void |
1092 attributeDeclDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar * elem, | 1098 attributeDeclDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar * elem, |
1093 const xmlChar * name, int type, int def, | 1099 const xmlChar * name, int type, int def, |
1094 const xmlChar * defaultValue, xmlEnumerationPtr tree) | 1100 const xmlChar * defaultValue, xmlEnumerationPtr tree) |
1095 { | 1101 { |
1096 callbacks++; | 1102 callbacks++; |
1097 if (noout) | 1103 if (noout) |
1098 return; | 1104 return; |
1099 if (defaultValue == NULL) | 1105 if (defaultValue == NULL) |
1100 fprintf(stdout, "SAX.attributeDecl(%s, %s, %d, %d, NULL, ...)\n", | 1106 fprintf(stdout, "SAX.attributeDecl(%s, %s, %d, %d, NULL, ...)\n", |
1101 elem, name, type, def); | 1107 elem, name, type, def); |
1102 else | 1108 else |
1103 fprintf(stdout, "SAX.attributeDecl(%s, %s, %d, %d, %s, ...)\n", | 1109 fprintf(stdout, "SAX.attributeDecl(%s, %s, %d, %d, %s, ...)\n", |
1104 elem, name, type, def, defaultValue); | 1110 elem, name, type, def, defaultValue); |
1105 xmlFreeEnumeration(tree); | 1111 xmlFreeEnumeration(tree); |
1106 } | 1112 } |
1107 | 1113 |
1108 /** | 1114 /** |
1109 * elementDeclDebug: | 1115 * elementDeclDebug: |
1110 * @ctxt: An XML parser context | 1116 * @ctxt: An XML parser context |
1111 * @name: the element name | 1117 * @name: the element name |
1112 * @type: the element type | 1118 * @type: the element type |
1113 * @content: the element value (without processing). | 1119 * @content: the element value (without processing). |
1114 * | 1120 * |
1115 * An element definition has been parsed | 1121 * An element definition has been parsed |
1116 */ | 1122 */ |
1117 static void | 1123 static void |
1118 elementDeclDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *name, int type, | 1124 elementDeclDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *name, int type, |
1119 xmlElementContentPtr content ATTRIBUTE_UNUSED) | 1125 xmlElementContentPtr content ATTRIBUTE_UNUSED) |
1120 { | 1126 { |
1121 callbacks++; | 1127 callbacks++; |
1122 if (noout) | 1128 if (noout) |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1288 out[i] = 0; | 1294 out[i] = 0; |
1289 | 1295 |
1290 fprintf(stdout, "SAX.characters(%s, %d)\n", out, len); | 1296 fprintf(stdout, "SAX.characters(%s, %d)\n", out, len); |
1291 } | 1297 } |
1292 | 1298 |
1293 /** | 1299 /** |
1294 * referenceDebug: | 1300 * referenceDebug: |
1295 * @ctxt: An XML parser context | 1301 * @ctxt: An XML parser context |
1296 * @name: The entity name | 1302 * @name: The entity name |
1297 * | 1303 * |
1298 * called when an entity reference is detected. | 1304 * called when an entity reference is detected. |
1299 */ | 1305 */ |
1300 static void | 1306 static void |
1301 referenceDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *name) | 1307 referenceDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *name) |
1302 { | 1308 { |
1303 callbacks++; | 1309 callbacks++; |
1304 if (noout) | 1310 if (noout) |
1305 return; | 1311 return; |
1306 fprintf(stdout, "SAX.reference(%s)\n", name); | 1312 fprintf(stdout, "SAX.reference(%s)\n", name); |
1307 } | 1313 } |
1308 | 1314 |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1524 fprintf(stdout, "SAX.startElementNs(%s", (char *) localname); | 1530 fprintf(stdout, "SAX.startElementNs(%s", (char *) localname); |
1525 if (prefix == NULL) | 1531 if (prefix == NULL) |
1526 fprintf(stdout, ", NULL"); | 1532 fprintf(stdout, ", NULL"); |
1527 else | 1533 else |
1528 fprintf(stdout, ", %s", (char *) prefix); | 1534 fprintf(stdout, ", %s", (char *) prefix); |
1529 if (URI == NULL) | 1535 if (URI == NULL) |
1530 fprintf(stdout, ", NULL"); | 1536 fprintf(stdout, ", NULL"); |
1531 else | 1537 else |
1532 fprintf(stdout, ", '%s'", (char *) URI); | 1538 fprintf(stdout, ", '%s'", (char *) URI); |
1533 fprintf(stdout, ", %d", nb_namespaces); | 1539 fprintf(stdout, ", %d", nb_namespaces); |
1534 | 1540 |
1535 if (namespaces != NULL) { | 1541 if (namespaces != NULL) { |
1536 for (i = 0;i < nb_namespaces * 2;i++) { | 1542 for (i = 0;i < nb_namespaces * 2;i++) { |
1537 fprintf(stdout, ", xmlns"); | 1543 fprintf(stdout, ", xmlns"); |
1538 if (namespaces[i] != NULL) | 1544 if (namespaces[i] != NULL) |
1539 fprintf(stdout, ":%s", namespaces[i]); | 1545 fprintf(stdout, ":%s", namespaces[i]); |
1540 i++; | 1546 i++; |
1541 fprintf(stdout, "='%s'", namespaces[i]); | 1547 fprintf(stdout, "='%s'", namespaces[i]); |
1542 } | 1548 } |
1543 } | 1549 } |
1544 fprintf(stdout, ", %d, %d", nb_attributes, nb_defaulted); | 1550 fprintf(stdout, ", %d, %d", nb_attributes, nb_defaulted); |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1687 } | 1693 } |
1688 old_sax = ctxt->sax; | 1694 old_sax = ctxt->sax; |
1689 ctxt->sax = handler; | 1695 ctxt->sax = handler; |
1690 ctxt->userData = (void *) user_data; | 1696 ctxt->userData = (void *) user_data; |
1691 inputStream = xmlNewIOInputStream(ctxt, buf, XML_CHAR_ENCODING_NONE); | 1697 inputStream = xmlNewIOInputStream(ctxt, buf, XML_CHAR_ENCODING_NONE); |
1692 if (inputStream == NULL) { | 1698 if (inputStream == NULL) { |
1693 xmlFreeParserInputBuffer(buf); | 1699 xmlFreeParserInputBuffer(buf); |
1694 goto error; | 1700 goto error; |
1695 } | 1701 } |
1696 inputPush(ctxt, inputStream); | 1702 inputPush(ctxt, inputStream); |
1697 » | 1703 |
1698 /* do the parsing */ | 1704 /* do the parsing */ |
1699 xmlParseDocument(ctxt); | 1705 xmlParseDocument(ctxt); |
1700 | 1706 |
1701 if (ctxt->myDoc != NULL) { | 1707 if (ctxt->myDoc != NULL) { |
1702 fprintf(stderr, "SAX generated a doc !\n"); | 1708 fprintf(stderr, "SAX generated a doc !\n"); |
1703 xmlFreeDoc(ctxt->myDoc); | 1709 xmlFreeDoc(ctxt->myDoc); |
1704 ctxt->myDoc = NULL; | 1710 ctxt->myDoc = NULL; |
1705 } | 1711 } |
1706 } | 1712 } |
1707 | 1713 |
1708 error: | 1714 error: |
1709 if (ctxt != NULL) { | 1715 if (ctxt != NULL) { |
1710 ctxt->sax = old_sax; | 1716 ctxt->sax = old_sax; |
1711 xmlFreeParserCtxt(ctxt); | 1717 xmlFreeParserCtxt(ctxt); |
1712 } | 1718 } |
1713 } | 1719 } |
1714 | 1720 |
1715 /************************************************************************ | 1721 /************************************************************************ |
1716 * » » » » » » » » » * | 1722 *» » » » » » » » » * |
1717 * » » » Stream Test processing» » » » * | 1723 *» » » Stream Test processing» » » » * |
1718 * » » » » » » » » » * | 1724 *» » » » » » » » » * |
1719 ************************************************************************/ | 1725 ************************************************************************/ |
1720 #ifdef LIBXML_READER_ENABLED | 1726 #ifdef LIBXML_READER_ENABLED |
1721 static void processNode(xmlTextReaderPtr reader) { | 1727 static void processNode(xmlTextReaderPtr reader) { |
1722 const xmlChar *name, *value; | 1728 const xmlChar *name, *value; |
1723 int type, empty; | 1729 int type, empty; |
1724 | 1730 |
1725 type = xmlTextReaderNodeType(reader); | 1731 type = xmlTextReaderNodeType(reader); |
1726 empty = xmlTextReaderIsEmptyElement(reader); | 1732 empty = xmlTextReaderIsEmptyElement(reader); |
1727 | 1733 |
1728 if (debug) { | 1734 if (debug) { |
1729 name = xmlTextReaderConstName(reader); | 1735 name = xmlTextReaderConstName(reader); |
1730 if (name == NULL) | 1736 if (name == NULL) |
1731 name = BAD_CAST "--"; | 1737 name = BAD_CAST "--"; |
1732 | 1738 |
1733 value = xmlTextReaderConstValue(reader); | 1739 value = xmlTextReaderConstValue(reader); |
1734 | 1740 |
1735 » | 1741 |
1736 » printf("%d %d %s %d %d", | 1742 » printf("%d %d %s %d %d", |
1737 xmlTextReaderDepth(reader), | 1743 xmlTextReaderDepth(reader), |
1738 type, | 1744 type, |
1739 name, | 1745 name, |
1740 empty, | 1746 empty, |
1741 xmlTextReaderHasValue(reader)); | 1747 xmlTextReaderHasValue(reader)); |
1742 if (value == NULL) | 1748 if (value == NULL) |
1743 printf("\n"); | 1749 printf("\n"); |
1744 else { | 1750 else { |
1745 printf(" %s\n", value); | 1751 printf(" %s\n", value); |
1746 } | 1752 } |
1747 } | 1753 } |
1748 #ifdef LIBXML_PATTERN_ENABLED | 1754 #ifdef LIBXML_PATTERN_ENABLED |
1749 if (patternc) { | 1755 if (patternc) { |
1750 xmlChar *path = NULL; | 1756 xmlChar *path = NULL; |
1751 int match = -1; | 1757 int match = -1; |
1752 » | 1758 |
1753 if (type == XML_READER_TYPE_ELEMENT) { | 1759 if (type == XML_READER_TYPE_ELEMENT) { |
1754 /* do the check only on element start */ | 1760 /* do the check only on element start */ |
1755 match = xmlPatternMatch(patternc, xmlTextReaderCurrentNode(reader)); | 1761 match = xmlPatternMatch(patternc, xmlTextReaderCurrentNode(reader)); |
1756 | 1762 |
1757 if (match) { | 1763 if (match) { |
| 1764 #if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_DEBUG_ENABLED) |
1758 path = xmlGetNodePath(xmlTextReaderCurrentNode(reader)); | 1765 path = xmlGetNodePath(xmlTextReaderCurrentNode(reader)); |
1759 printf("Node %s matches pattern %s\n", path, pattern); | 1766 printf("Node %s matches pattern %s\n", path, pattern); |
| 1767 #else |
| 1768 printf("Node %s matches pattern %s\n", |
| 1769 xmlTextReaderConstName(reader), pattern); |
| 1770 #endif |
1760 } | 1771 } |
1761 } | 1772 } |
1762 if (patstream != NULL) { | 1773 if (patstream != NULL) { |
1763 int ret; | 1774 int ret; |
1764 | 1775 |
1765 if (type == XML_READER_TYPE_ELEMENT) { | 1776 if (type == XML_READER_TYPE_ELEMENT) { |
1766 ret = xmlStreamPush(patstream, | 1777 ret = xmlStreamPush(patstream, |
1767 xmlTextReaderConstLocalName(reader), | 1778 xmlTextReaderConstLocalName(reader), |
1768 xmlTextReaderConstNamespaceUri(reader)); | 1779 xmlTextReaderConstNamespaceUri(reader)); |
1769 if (ret < 0) { | 1780 if (ret < 0) { |
1770 fprintf(stderr, "xmlStreamPush() failure\n"); | 1781 fprintf(stderr, "xmlStreamPush() failure\n"); |
1771 xmlFreeStreamCtxt(patstream); | 1782 xmlFreeStreamCtxt(patstream); |
1772 patstream = NULL; | 1783 patstream = NULL; |
1773 } else if (ret != match) { | 1784 } else if (ret != match) { |
| 1785 #if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_DEBUG_ENABLED) |
1774 if (path == NULL) { | 1786 if (path == NULL) { |
1775 path = xmlGetNodePath( | 1787 path = xmlGetNodePath( |
1776 xmlTextReaderCurrentNode(reader)); | 1788 xmlTextReaderCurrentNode(reader)); |
1777 } | 1789 } |
| 1790 #endif |
1778 fprintf(stderr, | 1791 fprintf(stderr, |
1779 "xmlPatternMatch and xmlStreamPush disagree\n"); | 1792 "xmlPatternMatch and xmlStreamPush disagree\n"); |
1780 » » fprintf(stderr, | 1793 if (path != NULL) |
1781 » » " pattern %s node %s\n", | 1794 fprintf(stderr, " pattern %s node %s\n", |
1782 » » » pattern, path); | 1795 pattern, path); |
| 1796 else |
| 1797 » » fprintf(stderr, " pattern %s node %s\n", |
| 1798 » » » pattern, xmlTextReaderConstName(reader)); |
1783 } | 1799 } |
1784 | |
1785 | 1800 |
1786 » } | 1801 » } |
1787 if ((type == XML_READER_TYPE_END_ELEMENT) || | 1802 if ((type == XML_READER_TYPE_END_ELEMENT) || |
1788 ((type == XML_READER_TYPE_ELEMENT) && (empty))) { | 1803 ((type == XML_READER_TYPE_ELEMENT) && (empty))) { |
1789 ret = xmlStreamPop(patstream); | 1804 ret = xmlStreamPop(patstream); |
1790 if (ret < 0) { | 1805 if (ret < 0) { |
1791 fprintf(stderr, "xmlStreamPop() failure\n"); | 1806 fprintf(stderr, "xmlStreamPop() failure\n"); |
1792 xmlFreeStreamCtxt(patstream); | 1807 xmlFreeStreamCtxt(patstream); |
1793 patstream = NULL; | 1808 patstream = NULL; |
1794 } | 1809 } |
1795 } | 1810 } |
1796 } | 1811 } |
1797 if (path != NULL) | 1812 if (path != NULL) |
1798 xmlFree(path); | 1813 xmlFree(path); |
1799 } | 1814 } |
1800 #endif | 1815 #endif |
1801 } | 1816 } |
1802 | 1817 |
1803 static void streamFile(char *filename) { | 1818 static void streamFile(char *filename) { |
1804 xmlTextReaderPtr reader; | 1819 xmlTextReaderPtr reader; |
1805 int ret; | 1820 int ret; |
1806 #ifdef HAVE_SYS_MMAN_H | 1821 #ifdef HAVE_SYS_MMAN_H |
1807 int fd = -1; | 1822 int fd = -1; |
1808 struct stat info; | 1823 struct stat info; |
1809 const char *base = NULL; | 1824 const char *base = NULL; |
1810 xmlParserInputBufferPtr input = NULL; | 1825 xmlParserInputBufferPtr input = NULL; |
1811 | 1826 |
1812 if (memory) { | 1827 if (memory) { |
1813 » if (stat(filename, &info) < 0) | 1828 » if (stat(filename, &info) < 0) |
1814 return; | 1829 return; |
1815 if ((fd = open(filename, O_RDONLY)) < 0) | 1830 if ((fd = open(filename, O_RDONLY)) < 0) |
1816 return; | 1831 return; |
1817 base = mmap(NULL, info.st_size, PROT_READ, MAP_SHARED, fd, 0) ; | 1832 base = mmap(NULL, info.st_size, PROT_READ, MAP_SHARED, fd, 0) ; |
1818 if (base == (void *) MAP_FAILED) | 1833 if (base == (void *) MAP_FAILED) |
1819 return; | 1834 return; |
1820 | 1835 |
1821 reader = xmlReaderForMemory(base, info.st_size, filename, | 1836 reader = xmlReaderForMemory(base, info.st_size, filename, |
1822 NULL, options); | 1837 NULL, options); |
1823 } else | 1838 } else |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1972 const xmlChar *namespaces[22]; | 1987 const xmlChar *namespaces[22]; |
1973 int i; | 1988 int i; |
1974 xmlNsPtr ns; | 1989 xmlNsPtr ns; |
1975 | 1990 |
1976 root = xmlDocGetRootElement(doc); | 1991 root = xmlDocGetRootElement(doc); |
1977 for (ns = root->nsDef, i = 0;ns != NULL && i < 20;ns=ns->next) { | 1992 for (ns = root->nsDef, i = 0;ns != NULL && i < 20;ns=ns->next) { |
1978 namespaces[i++] = ns->href; | 1993 namespaces[i++] = ns->href; |
1979 namespaces[i++] = ns->prefix; | 1994 namespaces[i++] = ns->prefix; |
1980 } | 1995 } |
1981 namespaces[i++] = NULL; | 1996 namespaces[i++] = NULL; |
1982 namespaces[i++] = NULL; | 1997 namespaces[i] = NULL; |
1983 | 1998 |
1984 if (pattern != NULL) { | 1999 if (pattern != NULL) { |
1985 patternc = xmlPatterncompile((const xmlChar *) pattern, doc->dict, | 2000 patternc = xmlPatterncompile((const xmlChar *) pattern, doc->dict, |
1986 0, &namespaces[0]); | 2001 0, &namespaces[0]); |
1987 if (patternc == NULL) { | 2002 if (patternc == NULL) { |
1988 xmlGenericError(xmlGenericErrorContext, | 2003 xmlGenericError(xmlGenericErrorContext, |
1989 "Pattern %s failed to compile\n", pattern); | 2004 "Pattern %s failed to compile\n", pattern); |
1990 progresult = XMLLINT_ERR_SCHEMAPAT; | 2005 progresult = XMLLINT_ERR_SCHEMAPAT; |
1991 pattern = NULL; | 2006 pattern = NULL; |
1992 } | 2007 } |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2032 } | 2047 } |
2033 #ifdef LIBXML_PATTERN_ENABLED | 2048 #ifdef LIBXML_PATTERN_ENABLED |
2034 if (patstream != NULL) { | 2049 if (patstream != NULL) { |
2035 xmlFreeStreamCtxt(patstream); | 2050 xmlFreeStreamCtxt(patstream); |
2036 patstream = NULL; | 2051 patstream = NULL; |
2037 } | 2052 } |
2038 #endif | 2053 #endif |
2039 } | 2054 } |
2040 #endif /* LIBXML_READER_ENABLED */ | 2055 #endif /* LIBXML_READER_ENABLED */ |
2041 | 2056 |
| 2057 #ifdef LIBXML_XPATH_ENABLED |
2042 /************************************************************************ | 2058 /************************************************************************ |
2043 * » » » » » » » » » * | 2059 *» » » » » » » » » * |
2044 * » » » Tree Test processing» » » » * | 2060 *» » » XPath Query * |
2045 * » » » » » » » » » * | 2061 *» » » » » » » » » * |
| 2062 ************************************************************************/ |
| 2063 |
| 2064 static void doXPathDump(xmlXPathObjectPtr cur) { |
| 2065 switch(cur->type) { |
| 2066 case XPATH_NODESET: { |
| 2067 int i; |
| 2068 xmlNodePtr node; |
| 2069 #ifdef LIBXML_OUTPUT_ENABLED |
| 2070 xmlSaveCtxtPtr ctxt; |
| 2071 |
| 2072 if (cur->nodesetval->nodeNr <= 0) { |
| 2073 fprintf(stderr, "XPath set is empty\n"); |
| 2074 progresult = XMLLINT_ERR_XPATH; |
| 2075 break; |
| 2076 } |
| 2077 ctxt = xmlSaveToFd(1, NULL, 0); |
| 2078 if (ctxt == NULL) { |
| 2079 fprintf(stderr, "Out of memory for XPath\n"); |
| 2080 progresult = XMLLINT_ERR_MEM; |
| 2081 return; |
| 2082 } |
| 2083 for (i = 0;i < cur->nodesetval->nodeNr;i++) { |
| 2084 node = cur->nodesetval->nodeTab[i]; |
| 2085 xmlSaveTree(ctxt, node); |
| 2086 } |
| 2087 xmlSaveClose(ctxt); |
| 2088 #else |
| 2089 printf("xpath returned %d nodes\n", cur->nodesetval->nodeNr); |
| 2090 #endif |
| 2091 » break; |
| 2092 } |
| 2093 case XPATH_BOOLEAN: |
| 2094 » if (cur->boolval) printf("true"); |
| 2095 » else printf("false"); |
| 2096 » break; |
| 2097 case XPATH_NUMBER: |
| 2098 » switch (xmlXPathIsInf(cur->floatval)) { |
| 2099 » case 1: |
| 2100 » » printf("Infinity"); |
| 2101 » » break; |
| 2102 » case -1: |
| 2103 » » printf("-Infinity"); |
| 2104 » » break; |
| 2105 » default: |
| 2106 » » if (xmlXPathIsNaN(cur->floatval)) { |
| 2107 » » printf("NaN"); |
| 2108 » » } else { |
| 2109 » » printf("%0g", cur->floatval); |
| 2110 » » } |
| 2111 » } |
| 2112 » break; |
| 2113 case XPATH_STRING: |
| 2114 » printf("%s", (const char *) cur->stringval); |
| 2115 » break; |
| 2116 case XPATH_UNDEFINED: |
| 2117 » fprintf(stderr, "XPath Object is uninitialized\n"); |
| 2118 progresult = XMLLINT_ERR_XPATH; |
| 2119 » break; |
| 2120 » default: |
| 2121 » fprintf(stderr, "XPath object of unexpected type\n"); |
| 2122 progresult = XMLLINT_ERR_XPATH; |
| 2123 » break; |
| 2124 } |
| 2125 } |
| 2126 |
| 2127 static void doXPathQuery(xmlDocPtr doc, const char *query) { |
| 2128 xmlXPathContextPtr ctxt; |
| 2129 xmlXPathObjectPtr res; |
| 2130 |
| 2131 ctxt = xmlXPathNewContext(doc); |
| 2132 if (ctxt == NULL) { |
| 2133 fprintf(stderr, "Out of memory for XPath\n"); |
| 2134 progresult = XMLLINT_ERR_MEM; |
| 2135 return; |
| 2136 } |
| 2137 ctxt->node = xmlDocGetRootElement(doc); |
| 2138 res = xmlXPathEval(BAD_CAST query, ctxt); |
| 2139 xmlXPathFreeContext(ctxt); |
| 2140 |
| 2141 if (res == NULL) { |
| 2142 fprintf(stderr, "XPath evaluation failure\n"); |
| 2143 progresult = XMLLINT_ERR_XPATH; |
| 2144 return; |
| 2145 } |
| 2146 doXPathDump(res); |
| 2147 xmlXPathFreeObject(res); |
| 2148 } |
| 2149 #endif /* LIBXML_XPATH_ENABLED */ |
| 2150 |
| 2151 /************************************************************************ |
| 2152 *» » » » » » » » » * |
| 2153 *» » » Tree Test processing» » » » * |
| 2154 *» » » » » » » » » * |
2046 ************************************************************************/ | 2155 ************************************************************************/ |
2047 static void parseAndPrintFile(char *filename, xmlParserCtxtPtr rectxt) { | 2156 static void parseAndPrintFile(char *filename, xmlParserCtxtPtr rectxt) { |
2048 xmlDocPtr doc = NULL; | 2157 xmlDocPtr doc = NULL; |
2049 #ifdef LIBXML_TREE_ENABLED | 2158 #ifdef LIBXML_TREE_ENABLED |
2050 xmlDocPtr tmp; | 2159 xmlDocPtr tmp; |
2051 #endif /* LIBXML_TREE_ENABLED */ | 2160 #endif /* LIBXML_TREE_ENABLED */ |
2052 | 2161 |
2053 if ((timing) && (!repeat)) | 2162 if ((timing) && (!repeat)) |
2054 startTimer(); | 2163 startTimer(); |
2055 | 2164 |
2056 | 2165 |
2057 #ifdef LIBXML_TREE_ENABLED | 2166 #ifdef LIBXML_TREE_ENABLED |
2058 if (filename == NULL) { | 2167 if (filename == NULL) { |
2059 if (generate) { | 2168 if (generate) { |
2060 xmlNodePtr n; | 2169 xmlNodePtr n; |
2061 | 2170 |
2062 doc = xmlNewDoc(BAD_CAST "1.0"); | 2171 doc = xmlNewDoc(BAD_CAST "1.0"); |
2063 n = xmlNewDocNode(doc, NULL, BAD_CAST "info", NULL); | 2172 n = xmlNewDocNode(doc, NULL, BAD_CAST "info", NULL); |
2064 xmlNodeSetContent(n, BAD_CAST "abc"); | 2173 xmlNodeSetContent(n, BAD_CAST "abc"); |
2065 xmlDocSetRootElement(doc, n); | 2174 xmlDocSetRootElement(doc, n); |
(...skipping 30 matching lines...) Expand all Loading... |
2096 } | 2205 } |
2097 fclose(f); | 2206 fclose(f); |
2098 } | 2207 } |
2099 } | 2208 } |
2100 #endif /* LIBXML_PUSH_ENABLED */ | 2209 #endif /* LIBXML_PUSH_ENABLED */ |
2101 #ifdef HAVE_SYS_MMAN_H | 2210 #ifdef HAVE_SYS_MMAN_H |
2102 else if ((html) && (memory)) { | 2211 else if ((html) && (memory)) { |
2103 int fd; | 2212 int fd; |
2104 struct stat info; | 2213 struct stat info; |
2105 const char *base; | 2214 const char *base; |
2106 » if (stat(filename, &info) < 0) | 2215 » if (stat(filename, &info) < 0) |
2107 return; | 2216 return; |
2108 if ((fd = open(filename, O_RDONLY)) < 0) | 2217 if ((fd = open(filename, O_RDONLY)) < 0) |
2109 return; | 2218 return; |
2110 base = mmap(NULL, info.st_size, PROT_READ, MAP_SHARED, fd, 0) ; | 2219 base = mmap(NULL, info.st_size, PROT_READ, MAP_SHARED, fd, 0) ; |
2111 if (base == (void *) MAP_FAILED) | 2220 if (base == (void *) MAP_FAILED) |
2112 return; | 2221 return; |
2113 | 2222 |
2114 doc = htmlReadMemory((char *) base, info.st_size, filename, | 2223 doc = htmlReadMemory((char *) base, info.st_size, filename, |
2115 NULL, options); | 2224 NULL, options); |
2116 » | 2225 |
2117 munmap((char *) base, info.st_size); | 2226 munmap((char *) base, info.st_size); |
2118 close(fd); | 2227 close(fd); |
2119 } | 2228 } |
2120 #endif | 2229 #endif |
2121 else if (html) { | 2230 else if (html) { |
2122 doc = htmlReadFile(filename, NULL, options); | 2231 doc = htmlReadFile(filename, NULL, options); |
2123 } | 2232 } |
2124 #endif /* LIBXML_HTML_ENABLED */ | 2233 #endif /* LIBXML_HTML_ENABLED */ |
2125 else { | 2234 else { |
2126 #ifdef LIBXML_PUSH_ENABLED | 2235 #ifdef LIBXML_PUSH_ENABLED |
(...skipping 30 matching lines...) Expand all Loading... |
2157 } | 2266 } |
2158 xmlParseChunk(ctxt, chars, 0, 1); | 2267 xmlParseChunk(ctxt, chars, 0, 1); |
2159 doc = ctxt->myDoc; | 2268 doc = ctxt->myDoc; |
2160 ret = ctxt->wellFormed; | 2269 ret = ctxt->wellFormed; |
2161 xmlFreeParserCtxt(ctxt); | 2270 xmlFreeParserCtxt(ctxt); |
2162 if (!ret) { | 2271 if (!ret) { |
2163 xmlFreeDoc(doc); | 2272 xmlFreeDoc(doc); |
2164 doc = NULL; | 2273 doc = NULL; |
2165 } | 2274 } |
2166 } | 2275 } |
| 2276 if (f != stdin) |
| 2277 fclose(f); |
2167 } | 2278 } |
2168 } else | 2279 } else |
2169 #endif /* LIBXML_PUSH_ENABLED */ | 2280 #endif /* LIBXML_PUSH_ENABLED */ |
2170 if (testIO) { | 2281 if (testIO) { |
2171 if ((filename[0] == '-') && (filename[1] == 0)) { | 2282 if ((filename[0] == '-') && (filename[1] == 0)) { |
2172 doc = xmlReadFd(0, NULL, NULL, options); | 2283 doc = xmlReadFd(0, NULL, NULL, options); |
2173 } else { | 2284 } else { |
2174 FILE *f; | 2285 FILE *f; |
2175 | 2286 |
2176 #if defined(_WIN32) || defined (__DJGPP__) && !defined (__CYGWIN__) | 2287 #if defined(_WIN32) || defined (__DJGPP__) && !defined (__CYGWIN__) |
(...skipping 14 matching lines...) Expand all Loading... |
2191 } else | 2302 } else |
2192 doc = NULL; | 2303 doc = NULL; |
2193 } | 2304 } |
2194 } else if (htmlout) { | 2305 } else if (htmlout) { |
2195 xmlParserCtxtPtr ctxt; | 2306 xmlParserCtxtPtr ctxt; |
2196 | 2307 |
2197 if (rectxt == NULL) | 2308 if (rectxt == NULL) |
2198 ctxt = xmlNewParserCtxt(); | 2309 ctxt = xmlNewParserCtxt(); |
2199 else | 2310 else |
2200 ctxt = rectxt; | 2311 ctxt = rectxt; |
2201 » if (ctxt == NULL) {» | 2312 » if (ctxt == NULL) { |
2202 doc = NULL; | 2313 doc = NULL; |
2203 } else { | 2314 } else { |
2204 ctxt->sax->error = xmlHTMLError; | 2315 ctxt->sax->error = xmlHTMLError; |
2205 ctxt->sax->warning = xmlHTMLWarning; | 2316 ctxt->sax->warning = xmlHTMLWarning; |
2206 ctxt->vctxt.error = xmlHTMLValidityError; | 2317 ctxt->vctxt.error = xmlHTMLValidityError; |
2207 ctxt->vctxt.warning = xmlHTMLValidityWarning; | 2318 ctxt->vctxt.warning = xmlHTMLValidityWarning; |
2208 | 2319 |
2209 doc = xmlCtxtReadFile(ctxt, filename, NULL, options); | 2320 doc = xmlCtxtReadFile(ctxt, filename, NULL, options); |
2210 | 2321 |
2211 if (rectxt == NULL) | 2322 if (rectxt == NULL) |
2212 xmlFreeParserCtxt(ctxt); | 2323 xmlFreeParserCtxt(ctxt); |
2213 } | 2324 } |
2214 #ifdef HAVE_SYS_MMAN_H | 2325 #ifdef HAVE_SYS_MMAN_H |
2215 } else if (memory) { | 2326 } else if (memory) { |
2216 int fd; | 2327 int fd; |
2217 struct stat info; | 2328 struct stat info; |
2218 const char *base; | 2329 const char *base; |
2219 » if (stat(filename, &info) < 0) | 2330 » if (stat(filename, &info) < 0) |
2220 return; | 2331 return; |
2221 if ((fd = open(filename, O_RDONLY)) < 0) | 2332 if ((fd = open(filename, O_RDONLY)) < 0) |
2222 return; | 2333 return; |
2223 base = mmap(NULL, info.st_size, PROT_READ, MAP_SHARED, fd, 0) ; | 2334 base = mmap(NULL, info.st_size, PROT_READ, MAP_SHARED, fd, 0) ; |
2224 if (base == (void *) MAP_FAILED) | 2335 if (base == (void *) MAP_FAILED) |
2225 return; | 2336 return; |
2226 | 2337 |
2227 if (rectxt == NULL) | 2338 if (rectxt == NULL) |
2228 doc = xmlReadMemory((char *) base, info.st_size, | 2339 doc = xmlReadMemory((char *) base, info.st_size, |
2229 filename, NULL, options); | 2340 filename, NULL, options); |
2230 else | 2341 else |
2231 doc = xmlCtxtReadMemory(rectxt, (char *) base, info.st_size, | 2342 doc = xmlCtxtReadMemory(rectxt, (char *) base, info.st_size, |
2232 filename, NULL, options); | 2343 filename, NULL, options); |
2233 » | 2344 |
2234 munmap((char *) base, info.st_size); | 2345 munmap((char *) base, info.st_size); |
2235 close(fd); | 2346 close(fd); |
2236 #endif | 2347 #endif |
2237 #ifdef LIBXML_VALID_ENABLED | 2348 #ifdef LIBXML_VALID_ENABLED |
2238 } else if (valid) { | 2349 } else if (valid) { |
2239 xmlParserCtxtPtr ctxt = NULL; | 2350 xmlParserCtxtPtr ctxt = NULL; |
2240 | 2351 |
2241 if (rectxt == NULL) | 2352 if (rectxt == NULL) |
2242 ctxt = xmlNewParserCtxt(); | 2353 ctxt = xmlNewParserCtxt(); |
2243 else | 2354 else |
2244 ctxt = rectxt; | 2355 ctxt = rectxt; |
2245 » if (ctxt == NULL) {» | 2356 » if (ctxt == NULL) { |
2246 doc = NULL; | 2357 doc = NULL; |
2247 } else { | 2358 } else { |
2248 doc = xmlCtxtReadFile(ctxt, filename, NULL, options); | 2359 doc = xmlCtxtReadFile(ctxt, filename, NULL, options); |
2249 | 2360 |
2250 if (ctxt->valid == 0) | 2361 if (ctxt->valid == 0) |
2251 progresult = XMLLINT_ERR_RDFILE; | 2362 progresult = XMLLINT_ERR_RDFILE; |
2252 if (rectxt == NULL) | 2363 if (rectxt == NULL) |
2253 xmlFreeParserCtxt(ctxt); | 2364 xmlFreeParserCtxt(ctxt); |
2254 } | 2365 } |
2255 #endif /* LIBXML_VALID_ENABLED */ | 2366 #endif /* LIBXML_VALID_ENABLED */ |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2298 startTimer(); | 2409 startTimer(); |
2299 } | 2410 } |
2300 if (xmlXIncludeProcessFlags(doc, options) < 0) | 2411 if (xmlXIncludeProcessFlags(doc, options) < 0) |
2301 progresult = XMLLINT_ERR_UNCLASS; | 2412 progresult = XMLLINT_ERR_UNCLASS; |
2302 if ((timing) && (!repeat)) { | 2413 if ((timing) && (!repeat)) { |
2303 endTimer("Xinclude processing"); | 2414 endTimer("Xinclude processing"); |
2304 } | 2415 } |
2305 } | 2416 } |
2306 #endif | 2417 #endif |
2307 | 2418 |
| 2419 #ifdef LIBXML_XPATH_ENABLED |
| 2420 if (xpathquery != NULL) { |
| 2421 doXPathQuery(doc, xpathquery); |
| 2422 } |
| 2423 #endif |
| 2424 |
2308 #ifdef LIBXML_DEBUG_ENABLED | 2425 #ifdef LIBXML_DEBUG_ENABLED |
2309 #ifdef LIBXML_XPATH_ENABLED | 2426 #ifdef LIBXML_XPATH_ENABLED |
2310 /* | 2427 /* |
2311 * shell interaction | 2428 * shell interaction |
2312 */ | 2429 */ |
2313 if (shell) { | 2430 if (shell) { |
2314 xmlXPathOrderDocElems(doc); | 2431 xmlXPathOrderDocElems(doc); |
2315 xmlShell(doc, filename, xmlShellReadline, stdout); | 2432 xmlShell(doc, filename, xmlShellReadline, stdout); |
2316 } | 2433 } |
2317 #endif | 2434 #endif |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2356 } else if (nb == 0) { | 2473 } else if (nb == 0) { |
2357 fprintf(stderr, "No element can be inserted under root\n"); | 2474 fprintf(stderr, "No element can be inserted under root\n"); |
2358 } else { | 2475 } else { |
2359 fprintf(stderr, "%d element types can be inserted under root
:\n", | 2476 fprintf(stderr, "%d element types can be inserted under root
:\n", |
2360 nb); | 2477 nb); |
2361 for (i = 0;i < nb;i++) { | 2478 for (i = 0;i < nb;i++) { |
2362 fprintf(stderr, "%s\n", (char *) list[i]); | 2479 fprintf(stderr, "%s\n", (char *) list[i]); |
2363 } | 2480 } |
2364 } | 2481 } |
2365 } | 2482 } |
2366 » } | 2483 » } |
2367 }else | 2484 }else |
2368 #endif /* LIBXML_VALID_ENABLED */ | 2485 #endif /* LIBXML_VALID_ENABLED */ |
2369 #ifdef LIBXML_READER_ENABLED | 2486 #ifdef LIBXML_READER_ENABLED |
2370 if (walker) { | 2487 if (walker) { |
2371 walkDoc(doc); | 2488 walkDoc(doc); |
2372 } | 2489 } |
2373 #endif /* LIBXML_READER_ENABLED */ | 2490 #endif /* LIBXML_READER_ENABLED */ |
2374 #ifdef LIBXML_OUTPUT_ENABLED | 2491 #ifdef LIBXML_OUTPUT_ENABLED |
2375 if (noout == 0) { | 2492 if (noout == 0) { |
2376 int ret; | 2493 int ret; |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2421 if ((timing) && (!repeat)) { | 2538 if ((timing) && (!repeat)) { |
2422 endTimer("Saving"); | 2539 endTimer("Saving"); |
2423 } | 2540 } |
2424 } else | 2541 } else |
2425 #endif | 2542 #endif |
2426 #ifdef LIBXML_C14N_ENABLED | 2543 #ifdef LIBXML_C14N_ENABLED |
2427 if (canonical) { | 2544 if (canonical) { |
2428 xmlChar *result = NULL; | 2545 xmlChar *result = NULL; |
2429 int size; | 2546 int size; |
2430 | 2547 |
2431 » » size = xmlC14NDocDumpMemory(doc, NULL, 0, NULL, 1, &result); | 2548 » » size = xmlC14NDocDumpMemory(doc, NULL, XML_C14N_1_0, NULL, 1, &r
esult); |
2432 if (size >= 0) { | 2549 if (size >= 0) { |
2433 write(1, result, size); | 2550 write(1, result, size); |
2434 xmlFree(result); | 2551 xmlFree(result); |
| 2552 } else { |
| 2553 fprintf(stderr, "Failed to canonicalize\n"); |
| 2554 progresult = XMLLINT_ERR_OUT; |
| 2555 } |
| 2556 } else if (canonical) { |
| 2557 xmlChar *result = NULL; |
| 2558 int size; |
| 2559 |
| 2560 size = xmlC14NDocDumpMemory(doc, NULL, XML_C14N_1_1, NULL, 1, &r
esult); |
| 2561 if (size >= 0) { |
| 2562 write(1, result, size); |
| 2563 xmlFree(result); |
2435 } else { | 2564 } else { |
2436 fprintf(stderr, "Failed to canonicalize\n"); | 2565 fprintf(stderr, "Failed to canonicalize\n"); |
2437 progresult = XMLLINT_ERR_OUT; | 2566 progresult = XMLLINT_ERR_OUT; |
2438 } | 2567 } |
2439 } else | 2568 } else |
2440 if (exc_canonical) { | 2569 if (exc_canonical) { |
2441 xmlChar *result = NULL; | 2570 xmlChar *result = NULL; |
2442 int size; | 2571 int size; |
2443 | 2572 |
2444 » » size = xmlC14NDocDumpMemory(doc, NULL, 1, NULL, 1, &result); | 2573 » » size = xmlC14NDocDumpMemory(doc, NULL, XML_C14N_EXCLUSIVE_1_0, N
ULL, 1, &result); |
2445 if (size >= 0) { | 2574 if (size >= 0) { |
2446 write(1, result, size); | 2575 write(1, result, size); |
2447 xmlFree(result); | 2576 xmlFree(result); |
2448 } else { | 2577 } else { |
2449 fprintf(stderr, "Failed to canonicalize\n"); | 2578 fprintf(stderr, "Failed to canonicalize\n"); |
2450 progresult = XMLLINT_ERR_OUT; | 2579 progresult = XMLLINT_ERR_OUT; |
2451 } | 2580 } |
2452 } else | 2581 } else |
2453 #endif | 2582 #endif |
2454 #ifdef HAVE_SYS_MMAN_H | 2583 #ifdef HAVE_SYS_MMAN_H |
2455 if (memory) { | 2584 if (memory) { |
2456 xmlChar *result; | 2585 xmlChar *result; |
2457 int len; | 2586 int len; |
2458 | 2587 |
2459 if (encoding != NULL) { | 2588 if (encoding != NULL) { |
2460 if ( format ) { | 2589 if ( format ) { |
2461 xmlDocDumpFormatMemoryEnc(doc, &result, &len, encoding,
1); | 2590 xmlDocDumpFormatMemoryEnc(doc, &result, &len, encoding,
1); |
2462 » » } else { | 2591 » » } else { |
2463 xmlDocDumpMemoryEnc(doc, &result, &len, encoding); | 2592 xmlDocDumpMemoryEnc(doc, &result, &len, encoding); |
2464 } | 2593 } |
2465 } else { | 2594 } else { |
2466 if (format) | 2595 if (format) |
2467 xmlDocDumpFormatMemory(doc, &result, &len, 1); | 2596 xmlDocDumpFormatMemory(doc, &result, &len, 1); |
2468 else | 2597 else |
2469 xmlDocDumpMemory(doc, &result, &len); | 2598 xmlDocDumpMemory(doc, &result, &len); |
2470 } | 2599 } |
2471 if (result == NULL) { | 2600 if (result == NULL) { |
2472 fprintf(stderr, "Failed to save\n"); | 2601 fprintf(stderr, "Failed to save\n"); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2520 progresult = XMLLINT_ERR_OUT; | 2649 progresult = XMLLINT_ERR_OUT; |
2521 } | 2650 } |
2522 } | 2651 } |
2523 } else { | 2652 } else { |
2524 xmlSaveCtxtPtr ctxt; | 2653 xmlSaveCtxtPtr ctxt; |
2525 int saveOpts = 0; | 2654 int saveOpts = 0; |
2526 | 2655 |
2527 if (format) | 2656 if (format) |
2528 saveOpts |= XML_SAVE_FORMAT; | 2657 saveOpts |= XML_SAVE_FORMAT; |
2529 | 2658 |
| 2659 #if defined(LIBXML_HTML_ENABLED) || defined(LIBXML_VALID_ENABLED) |
| 2660 if (xmlout) |
| 2661 saveOpts |= XML_SAVE_AS_XML; |
| 2662 #endif |
| 2663 |
2530 if (output == NULL) | 2664 if (output == NULL) |
2531 ctxt = xmlSaveToFd(1, encoding, saveOpts); | 2665 ctxt = xmlSaveToFd(1, encoding, saveOpts); |
2532 else | 2666 else |
2533 ctxt = xmlSaveToFilename(output, encoding, saveOpts); | 2667 ctxt = xmlSaveToFilename(output, encoding, saveOpts); |
2534 | 2668 |
2535 if (ctxt != NULL) { | 2669 if (ctxt != NULL) { |
2536 if (xmlSaveDoc(ctxt, doc) < 0) { | 2670 if (xmlSaveDoc(ctxt, doc) < 0) { |
2537 fprintf(stderr, "failed save to %s\n", | 2671 fprintf(stderr, "failed save to %s\n", |
2538 output ? output : "-"); | 2672 output ? output : "-"); |
2539 progresult = XMLLINT_ERR_OUT; | 2673 progresult = XMLLINT_ERR_OUT; |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2572 /* | 2706 /* |
2573 * A posteriori validation test | 2707 * A posteriori validation test |
2574 */ | 2708 */ |
2575 if ((dtdvalid != NULL) || (dtdvalidfpi != NULL)) { | 2709 if ((dtdvalid != NULL) || (dtdvalidfpi != NULL)) { |
2576 xmlDtdPtr dtd; | 2710 xmlDtdPtr dtd; |
2577 | 2711 |
2578 if ((timing) && (!repeat)) { | 2712 if ((timing) && (!repeat)) { |
2579 startTimer(); | 2713 startTimer(); |
2580 } | 2714 } |
2581 if (dtdvalid != NULL) | 2715 if (dtdvalid != NULL) |
2582 » dtd = xmlParseDTD(NULL, (const xmlChar *)dtdvalid); | 2716 » dtd = xmlParseDTD(NULL, (const xmlChar *)dtdvalid); |
2583 else | 2717 else |
2584 » dtd = xmlParseDTD((const xmlChar *)dtdvalidfpi, NULL); | 2718 » dtd = xmlParseDTD((const xmlChar *)dtdvalidfpi, NULL); |
2585 if ((timing) && (!repeat)) { | 2719 if ((timing) && (!repeat)) { |
2586 endTimer("Parsing DTD"); | 2720 endTimer("Parsing DTD"); |
2587 } | 2721 } |
2588 if (dtd == NULL) { | 2722 if (dtd == NULL) { |
2589 if (dtdvalid != NULL) | 2723 if (dtdvalid != NULL) |
2590 xmlGenericError(xmlGenericErrorContext, | 2724 xmlGenericError(xmlGenericErrorContext, |
2591 "Could not parse DTD %s\n", dtdvalid); | 2725 "Could not parse DTD %s\n", dtdvalid); |
2592 else | 2726 else |
2593 xmlGenericError(xmlGenericErrorContext, | 2727 xmlGenericError(xmlGenericErrorContext, |
2594 "Could not parse DTD %s\n", dtdvalidfpi); | 2728 "Could not parse DTD %s\n", dtdvalidfpi); |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2745 progresult = XMLLINT_ERR_VALID; | 2879 progresult = XMLLINT_ERR_VALID; |
2746 } | 2880 } |
2747 xmlSchemaFreeValidCtxt(ctxt); | 2881 xmlSchemaFreeValidCtxt(ctxt); |
2748 if ((timing) && (!repeat)) { | 2882 if ((timing) && (!repeat)) { |
2749 endTimer("Validating"); | 2883 endTimer("Validating"); |
2750 } | 2884 } |
2751 } | 2885 } |
2752 #endif | 2886 #endif |
2753 | 2887 |
2754 #ifdef LIBXML_DEBUG_ENABLED | 2888 #ifdef LIBXML_DEBUG_ENABLED |
| 2889 #if defined(LIBXML_HTML_ENABLED) || defined(LIBXML_VALID_ENABLED) |
2755 if ((debugent) && (!html)) | 2890 if ((debugent) && (!html)) |
2756 xmlDebugDumpEntities(stderr, doc); | 2891 xmlDebugDumpEntities(stderr, doc); |
2757 #endif | 2892 #endif |
| 2893 #endif |
2758 | 2894 |
2759 /* | 2895 /* |
2760 * free it. | 2896 * free it. |
2761 */ | 2897 */ |
2762 if ((timing) && (!repeat)) { | 2898 if ((timing) && (!repeat)) { |
2763 startTimer(); | 2899 startTimer(); |
2764 } | 2900 } |
2765 xmlFreeDoc(doc); | 2901 xmlFreeDoc(doc); |
2766 if ((timing) && (!repeat)) { | 2902 if ((timing) && (!repeat)) { |
2767 endTimer("Freeing"); | 2903 endTimer("Freeing"); |
2768 } | 2904 } |
2769 } | 2905 } |
2770 | 2906 |
2771 /************************************************************************ | 2907 /************************************************************************ |
2772 * » » » » » » » » » * | 2908 *» » » » » » » » » * |
2773 * » » » Usage and Main» » » » » * | 2909 *» » » Usage and Main» » » » » * |
2774 * » » » » » » » » » * | 2910 *» » » » » » » » » * |
2775 ************************************************************************/ | 2911 ************************************************************************/ |
2776 | 2912 |
2777 static void showVersion(const char *name) { | 2913 static void showVersion(const char *name) { |
2778 fprintf(stderr, "%s: using libxml version %s\n", name, xmlParserVersion); | 2914 fprintf(stderr, "%s: using libxml version %s\n", name, xmlParserVersion); |
2779 fprintf(stderr, " compiled with: "); | 2915 fprintf(stderr, " compiled with: "); |
2780 if (xmlHasFeature(XML_WITH_THREAD)) fprintf(stderr, "Threads "); | 2916 if (xmlHasFeature(XML_WITH_THREAD)) fprintf(stderr, "Threads "); |
2781 if (xmlHasFeature(XML_WITH_TREE)) fprintf(stderr, "Tree "); | 2917 if (xmlHasFeature(XML_WITH_TREE)) fprintf(stderr, "Tree "); |
2782 if (xmlHasFeature(XML_WITH_OUTPUT)) fprintf(stderr, "Output "); | 2918 if (xmlHasFeature(XML_WITH_OUTPUT)) fprintf(stderr, "Output "); |
2783 if (xmlHasFeature(XML_WITH_PUSH)) fprintf(stderr, "Push "); | 2919 if (xmlHasFeature(XML_WITH_PUSH)) fprintf(stderr, "Push "); |
2784 if (xmlHasFeature(XML_WITH_READER)) fprintf(stderr, "Reader "); | 2920 if (xmlHasFeature(XML_WITH_READER)) fprintf(stderr, "Reader "); |
2785 if (xmlHasFeature(XML_WITH_PATTERN)) fprintf(stderr, "Patterns "); | 2921 if (xmlHasFeature(XML_WITH_PATTERN)) fprintf(stderr, "Patterns "); |
2786 if (xmlHasFeature(XML_WITH_WRITER)) fprintf(stderr, "Writer "); | 2922 if (xmlHasFeature(XML_WITH_WRITER)) fprintf(stderr, "Writer "); |
2787 if (xmlHasFeature(XML_WITH_SAX1)) fprintf(stderr, "SAXv1 "); | 2923 if (xmlHasFeature(XML_WITH_SAX1)) fprintf(stderr, "SAXv1 "); |
2788 if (xmlHasFeature(XML_WITH_FTP)) fprintf(stderr, "FTP "); | 2924 if (xmlHasFeature(XML_WITH_FTP)) fprintf(stderr, "FTP "); |
2789 if (xmlHasFeature(XML_WITH_HTTP)) fprintf(stderr, "HTTP "); | 2925 if (xmlHasFeature(XML_WITH_HTTP)) fprintf(stderr, "HTTP "); |
2790 if (xmlHasFeature(XML_WITH_VALID)) fprintf(stderr, "DTDValid "); | 2926 if (xmlHasFeature(XML_WITH_VALID)) fprintf(stderr, "DTDValid "); |
2791 if (xmlHasFeature(XML_WITH_HTML)) fprintf(stderr, "HTML "); | 2927 if (xmlHasFeature(XML_WITH_HTML)) fprintf(stderr, "HTML "); |
2792 if (xmlHasFeature(XML_WITH_LEGACY)) fprintf(stderr, "Legacy "); | 2928 if (xmlHasFeature(XML_WITH_LEGACY)) fprintf(stderr, "Legacy "); |
2793 if (xmlHasFeature(XML_WITH_C14N)) fprintf(stderr, "C14N "); | 2929 if (xmlHasFeature(XML_WITH_C14N)) fprintf(stderr, "C14N "); |
2794 if (xmlHasFeature(XML_WITH_CATALOG)) fprintf(stderr, "Catalog "); | 2930 if (xmlHasFeature(XML_WITH_CATALOG)) fprintf(stderr, "Catalog "); |
2795 if (xmlHasFeature(XML_WITH_XPATH)) fprintf(stderr, "XPath "); | 2931 if (xmlHasFeature(XML_WITH_XPATH)) fprintf(stderr, "XPath "); |
2796 if (xmlHasFeature(XML_WITH_XPTR)) fprintf(stderr, "XPointer "); | 2932 if (xmlHasFeature(XML_WITH_XPTR)) fprintf(stderr, "XPointer "); |
2797 if (xmlHasFeature(XML_WITH_XINCLUDE)) fprintf(stderr, "XInclude "); | 2933 if (xmlHasFeature(XML_WITH_XINCLUDE)) fprintf(stderr, "XInclude "); |
2798 if (xmlHasFeature(XML_WITH_ICONV)) fprintf(stderr, "Iconv "); | 2934 if (xmlHasFeature(XML_WITH_ICONV)) fprintf(stderr, "Iconv "); |
2799 if (xmlHasFeature(XML_WITH_ISO8859X)) fprintf(stderr, "ISO8859X "); | 2935 if (xmlHasFeature(XML_WITH_ISO8859X)) fprintf(stderr, "ISO8859X "); |
2800 if (xmlHasFeature(XML_WITH_UNICODE)) fprintf(stderr, "Unicode "); | 2936 if (xmlHasFeature(XML_WITH_UNICODE)) fprintf(stderr, "Unicode "); |
2801 if (xmlHasFeature(XML_WITH_REGEXP)) fprintf(stderr, "Regexps "); | 2937 if (xmlHasFeature(XML_WITH_REGEXP)) fprintf(stderr, "Regexps "); |
2802 if (xmlHasFeature(XML_WITH_AUTOMATA)) fprintf(stderr, "Automata "); | 2938 if (xmlHasFeature(XML_WITH_AUTOMATA)) fprintf(stderr, "Automata "); |
2803 if (xmlHasFeature(XML_WITH_EXPR)) fprintf(stderr, "Expr "); | 2939 if (xmlHasFeature(XML_WITH_EXPR)) fprintf(stderr, "Expr "); |
2804 if (xmlHasFeature(XML_WITH_SCHEMAS)) fprintf(stderr, "Schemas "); | 2940 if (xmlHasFeature(XML_WITH_SCHEMAS)) fprintf(stderr, "Schemas "); |
2805 if (xmlHasFeature(XML_WITH_SCHEMATRON)) fprintf(stderr, "Schematron "); | 2941 if (xmlHasFeature(XML_WITH_SCHEMATRON)) fprintf(stderr, "Schematron "); |
2806 if (xmlHasFeature(XML_WITH_MODULES)) fprintf(stderr, "Modules "); | 2942 if (xmlHasFeature(XML_WITH_MODULES)) fprintf(stderr, "Modules "); |
2807 if (xmlHasFeature(XML_WITH_DEBUG)) fprintf(stderr, "Debug "); | 2943 if (xmlHasFeature(XML_WITH_DEBUG)) fprintf(stderr, "Debug "); |
2808 if (xmlHasFeature(XML_WITH_DEBUG_MEM)) fprintf(stderr, "MemDebug "); | 2944 if (xmlHasFeature(XML_WITH_DEBUG_MEM)) fprintf(stderr, "MemDebug "); |
2809 if (xmlHasFeature(XML_WITH_DEBUG_RUN)) fprintf(stderr, "RunDebug "); | 2945 if (xmlHasFeature(XML_WITH_DEBUG_RUN)) fprintf(stderr, "RunDebug "); |
2810 if (xmlHasFeature(XML_WITH_ZLIB)) fprintf(stderr, "Zlib "); | 2946 if (xmlHasFeature(XML_WITH_ZLIB)) fprintf(stderr, "Zlib "); |
2811 fprintf(stderr, "\n"); | 2947 fprintf(stderr, "\n"); |
2812 } | 2948 } |
2813 | 2949 |
2814 static void usage(const char *name) { | 2950 static void usage(const char *name) { |
2815 printf("Usage : %s [options] XMLfiles ...\n", name); | 2951 printf("Usage : %s [options] XMLfiles ...\n", name); |
2816 #ifdef LIBXML_OUTPUT_ENABLED | 2952 #ifdef LIBXML_OUTPUT_ENABLED |
2817 printf("\tParse the XML files and output the result of the parsing\n"); | 2953 printf("\tParse the XML files and output the result of the parsing\n"); |
2818 #else | 2954 #else |
2819 printf("\tParse the XML files\n"); | 2955 printf("\tParse the XML files\n"); |
2820 #endif /* LIBXML_OUTPUT_ENABLED */ | 2956 #endif /* LIBXML_OUTPUT_ENABLED */ |
2821 printf("\t--version : display the version of the XML library used\n"); | 2957 printf("\t--version : display the version of the XML library used\n"); |
2822 #ifdef LIBXML_DEBUG_ENABLED | 2958 #ifdef LIBXML_DEBUG_ENABLED |
2823 printf("\t--debug : dump a debug tree of the in-memory document\n"); | 2959 printf("\t--debug : dump a debug tree of the in-memory document\n"); |
2824 printf("\t--shell : run a navigating shell\n"); | 2960 printf("\t--shell : run a navigating shell\n"); |
2825 printf("\t--debugent : debug the entities defined in the document\n"); | 2961 printf("\t--debugent : debug the entities defined in the document\n"); |
2826 #else | 2962 #else |
2827 #ifdef LIBXML_READER_ENABLED | 2963 #ifdef LIBXML_READER_ENABLED |
2828 printf("\t--debug : dump the nodes content when using --stream\n"); | 2964 printf("\t--debug : dump the nodes content when using --stream\n"); |
2829 #endif /* LIBXML_READER_ENABLED */ | 2965 #endif /* LIBXML_READER_ENABLED */ |
2830 #endif | 2966 #endif |
2831 #ifdef LIBXML_TREE_ENABLED | 2967 #ifdef LIBXML_TREE_ENABLED |
2832 printf("\t--copy : used to test the internal copy implementation\n"); | 2968 printf("\t--copy : used to test the internal copy implementation\n"); |
2833 #endif /* LIBXML_TREE_ENABLED */ | 2969 #endif /* LIBXML_TREE_ENABLED */ |
2834 printf("\t--recover : output what was parsable on broken XML documents\n"); | 2970 printf("\t--recover : output what was parsable on broken XML documents\n"); |
| 2971 printf("\t--huge : remove any internal arbitrary parser limits\n"); |
2835 printf("\t--noent : substitute entity references by their value\n"); | 2972 printf("\t--noent : substitute entity references by their value\n"); |
2836 printf("\t--noout : don't output the result tree\n"); | 2973 printf("\t--noout : don't output the result tree\n"); |
2837 printf("\t--path 'paths': provide a set of paths for resources\n"); | 2974 printf("\t--path 'paths': provide a set of paths for resources\n"); |
2838 printf("\t--load-trace : print trace of all external entites loaded\n"); | 2975 printf("\t--load-trace : print trace of all external entites loaded\n"); |
2839 printf("\t--nonet : refuse to fetch DTDs or entities over network\n"); | 2976 printf("\t--nonet : refuse to fetch DTDs or entities over network\n"); |
2840 printf("\t--nocompact : do not generate compact text nodes\n"); | 2977 printf("\t--nocompact : do not generate compact text nodes\n"); |
2841 printf("\t--htmlout : output results as HTML\n"); | 2978 printf("\t--htmlout : output results as HTML\n"); |
2842 printf("\t--nowrap : do not put HTML doc wrapper\n"); | 2979 printf("\t--nowrap : do not put HTML doc wrapper\n"); |
2843 #ifdef LIBXML_VALID_ENABLED | 2980 #ifdef LIBXML_VALID_ENABLED |
2844 printf("\t--valid : validate the document in addition to std well-formed che
ck\n"); | 2981 printf("\t--valid : validate the document in addition to std well-formed che
ck\n"); |
(...skipping 22 matching lines...) Expand all Loading... |
2867 #endif | 3004 #endif |
2868 printf("\t--maxmem nbbytes : limits memory allocation to nbbytes bytes\n"); | 3005 printf("\t--maxmem nbbytes : limits memory allocation to nbbytes bytes\n"); |
2869 printf("\t--nowarning : do not emit warnings from parser/validator\n"); | 3006 printf("\t--nowarning : do not emit warnings from parser/validator\n"); |
2870 printf("\t--noblanks : drop (ignorable?) blanks spaces\n"); | 3007 printf("\t--noblanks : drop (ignorable?) blanks spaces\n"); |
2871 printf("\t--nocdata : replace cdata section with text nodes\n"); | 3008 printf("\t--nocdata : replace cdata section with text nodes\n"); |
2872 #ifdef LIBXML_OUTPUT_ENABLED | 3009 #ifdef LIBXML_OUTPUT_ENABLED |
2873 printf("\t--format : reformat/reindent the input\n"); | 3010 printf("\t--format : reformat/reindent the input\n"); |
2874 printf("\t--encode encoding : output in the given encoding\n"); | 3011 printf("\t--encode encoding : output in the given encoding\n"); |
2875 printf("\t--dropdtd : remove the DOCTYPE of the input docs\n"); | 3012 printf("\t--dropdtd : remove the DOCTYPE of the input docs\n"); |
2876 #endif /* LIBXML_OUTPUT_ENABLED */ | 3013 #endif /* LIBXML_OUTPUT_ENABLED */ |
2877 printf("\t--c14n : save in W3C canonical format (with comments)\n"); | 3014 printf("\t--c14n : save in W3C canonical format v1.0 (with comments)\n"); |
| 3015 printf("\t--c14n11 : save in W3C canonical format v1.1 (with comments)\n"); |
2878 printf("\t--exc-c14n : save in W3C exclusive canonical format (with comments
)\n"); | 3016 printf("\t--exc-c14n : save in W3C exclusive canonical format (with comments
)\n"); |
2879 #ifdef LIBXML_C14N_ENABLED | 3017 #ifdef LIBXML_C14N_ENABLED |
2880 #endif /* LIBXML_C14N_ENABLED */ | 3018 #endif /* LIBXML_C14N_ENABLED */ |
2881 printf("\t--nsclean : remove redundant namespace declarations\n"); | 3019 printf("\t--nsclean : remove redundant namespace declarations\n"); |
2882 printf("\t--testIO : test user I/O support\n"); | 3020 printf("\t--testIO : test user I/O support\n"); |
2883 #ifdef LIBXML_CATALOG_ENABLED | 3021 #ifdef LIBXML_CATALOG_ENABLED |
2884 printf("\t--catalogs : use SGML catalogs from $SGML_CATALOG_FILES\n"); | 3022 printf("\t--catalogs : use SGML catalogs from $SGML_CATALOG_FILES\n"); |
2885 printf("\t otherwise XML Catalogs starting from \n"); | 3023 printf("\t otherwise XML Catalogs starting from \n"); |
2886 printf("\t %s are activated by default\n", XML_XML_DEFAULT_CATALOG); | 3024 printf("\t %s are activated by default\n", XML_XML_DEFAULT_CATALOG); |
2887 printf("\t--nocatalogs: deactivate all catalogs\n"); | 3025 printf("\t--nocatalogs: deactivate all catalogs\n"); |
2888 #endif | 3026 #endif |
2889 printf("\t--auto : generate a small doc on the fly\n"); | 3027 printf("\t--auto : generate a small doc on the fly\n"); |
2890 #ifdef LIBXML_XINCLUDE_ENABLED | 3028 #ifdef LIBXML_XINCLUDE_ENABLED |
2891 printf("\t--xinclude : do XInclude processing\n"); | 3029 printf("\t--xinclude : do XInclude processing\n"); |
2892 printf("\t--noxincludenode : same but do not generate XInclude nodes\n"); | 3030 printf("\t--noxincludenode : same but do not generate XInclude nodes\n"); |
| 3031 printf("\t--nofixup-base-uris : do not fixup xml:base uris\n"); |
2893 #endif | 3032 #endif |
2894 printf("\t--loaddtd : fetch external DTD\n"); | 3033 printf("\t--loaddtd : fetch external DTD\n"); |
2895 printf("\t--dtdattr : loaddtd + populate the tree with inherited attributes
\n"); | 3034 printf("\t--dtdattr : loaddtd + populate the tree with inherited attributes
\n"); |
2896 #ifdef LIBXML_READER_ENABLED | 3035 #ifdef LIBXML_READER_ENABLED |
2897 printf("\t--stream : use the streaming interface to process very large files
\n"); | 3036 printf("\t--stream : use the streaming interface to process very large files
\n"); |
2898 printf("\t--walker : create a reader and walk though the resulting doc\n"); | 3037 printf("\t--walker : create a reader and walk though the resulting doc\n"); |
2899 #endif /* LIBXML_READER_ENABLED */ | 3038 #endif /* LIBXML_READER_ENABLED */ |
2900 #ifdef LIBXML_PATTERN_ENABLED | 3039 #ifdef LIBXML_PATTERN_ENABLED |
2901 printf("\t--pattern pattern_value : test the pattern support\n"); | 3040 printf("\t--pattern pattern_value : test the pattern support\n"); |
2902 #endif | 3041 #endif |
2903 printf("\t--chkregister : verify the node registration code\n"); | 3042 printf("\t--chkregister : verify the node registration code\n"); |
2904 #ifdef LIBXML_SCHEMAS_ENABLED | 3043 #ifdef LIBXML_SCHEMAS_ENABLED |
2905 printf("\t--relaxng schema : do RelaxNG validation against the schema\n"); | 3044 printf("\t--relaxng schema : do RelaxNG validation against the schema\n"); |
2906 printf("\t--schema schema : do validation against the WXS schema\n"); | 3045 printf("\t--schema schema : do validation against the WXS schema\n"); |
2907 #endif | 3046 #endif |
2908 #ifdef LIBXML_SCHEMATRON_ENABLED | 3047 #ifdef LIBXML_SCHEMATRON_ENABLED |
2909 printf("\t--schematron schema : do validation against a schematron\n"); | 3048 printf("\t--schematron schema : do validation against a schematron\n"); |
2910 #endif | 3049 #endif |
2911 #ifdef LIBXML_SAX1_ENABLED | 3050 #ifdef LIBXML_SAX1_ENABLED |
2912 printf("\t--sax1: use the old SAX1 interfaces for processing\n"); | 3051 printf("\t--sax1: use the old SAX1 interfaces for processing\n"); |
2913 #endif | 3052 #endif |
2914 printf("\t--sax: do not build a tree but work just at the SAX level\n"); | 3053 printf("\t--sax: do not build a tree but work just at the SAX level\n"); |
| 3054 printf("\t--oldxml10: use XML-1.0 parsing rules before the 5th edition\n"); |
| 3055 #ifdef LIBXML_XPATH_ENABLED |
| 3056 printf("\t--xpath expr: evaluate the XPath expression, inply --noout\n"); |
| 3057 #endif |
2915 | 3058 |
2916 printf("\nLibxml project home page: http://xmlsoft.org/\n"); | 3059 printf("\nLibxml project home page: http://xmlsoft.org/\n"); |
2917 printf("To report bugs or get some help check: http://xmlsoft.org/bugs.html\
n"); | 3060 printf("To report bugs or get some help check: http://xmlsoft.org/bugs.html\
n"); |
2918 } | 3061 } |
2919 | 3062 |
2920 static void registerNode(xmlNodePtr node) | 3063 static void registerNode(xmlNodePtr node) |
2921 { | 3064 { |
2922 node->_private = malloc(sizeof(long)); | 3065 node->_private = malloc(sizeof(long)); |
2923 *(long*)node->_private = (long) 0x81726354; | 3066 *(long*)node->_private = (long) 0x81726354; |
2924 nbregister++; | 3067 nbregister++; |
2925 } | 3068 } |
2926 | 3069 |
2927 static void deregisterNode(xmlNodePtr node) | 3070 static void deregisterNode(xmlNodePtr node) |
2928 { | 3071 { |
2929 assert(node->_private != NULL); | 3072 assert(node->_private != NULL); |
2930 assert(*(long*)node->_private == (long) 0x81726354); | 3073 assert(*(long*)node->_private == (long) 0x81726354); |
2931 free(node->_private); | 3074 free(node->_private); |
2932 nbregister--; | 3075 nbregister--; |
2933 } | 3076 } |
2934 | 3077 |
2935 int | 3078 int |
2936 main(int argc, char **argv) { | 3079 main(int argc, char **argv) { |
2937 int i, acount; | 3080 int i, acount; |
2938 int files = 0; | 3081 int files = 0; |
2939 int version = 0; | 3082 int version = 0; |
2940 const char* indent; | 3083 const char* indent; |
2941 | 3084 |
2942 if (argc <= 1) { | 3085 if (argc <= 1) { |
2943 usage(argv[0]); | 3086 usage(argv[0]); |
2944 return(1); | 3087 return(1); |
2945 } | 3088 } |
2946 LIBXML_TEST_VERSION | 3089 LIBXML_TEST_VERSION |
2947 for (i = 1; i < argc ; i++) { | 3090 for (i = 1; i < argc ; i++) { |
2948 if (!strcmp(argv[i], "-")) | 3091 if (!strcmp(argv[i], "-")) |
2949 break; | 3092 break; |
2950 | 3093 |
2951 if (argv[i][0] != '-') | 3094 if (argv[i][0] != '-') |
2952 continue; | 3095 continue; |
2953 if ((!strcmp(argv[i], "-debug")) || (!strcmp(argv[i], "--debug"))) | 3096 if ((!strcmp(argv[i], "-debug")) || (!strcmp(argv[i], "--debug"))) |
2954 debug++; | 3097 debug++; |
2955 else | 3098 else |
2956 #ifdef LIBXML_DEBUG_ENABLED | 3099 #ifdef LIBXML_DEBUG_ENABLED |
2957 if ((!strcmp(argv[i], "-shell")) || | 3100 if ((!strcmp(argv[i], "-shell")) || |
2958 (!strcmp(argv[i], "--shell"))) { | 3101 (!strcmp(argv[i], "--shell"))) { |
2959 shell++; | 3102 shell++; |
2960 noout = 1; | 3103 noout = 1; |
2961 } else | 3104 } else |
2962 #endif | 3105 #endif |
2963 #ifdef LIBXML_TREE_ENABLED | 3106 #ifdef LIBXML_TREE_ENABLED |
2964 if ((!strcmp(argv[i], "-copy")) || (!strcmp(argv[i], "--copy"))) | 3107 if ((!strcmp(argv[i], "-copy")) || (!strcmp(argv[i], "--copy"))) |
2965 copy++; | 3108 copy++; |
2966 else | 3109 else |
2967 #endif /* LIBXML_TREE_ENABLED */ | 3110 #endif /* LIBXML_TREE_ENABLED */ |
2968 if ((!strcmp(argv[i], "-recover")) || | 3111 if ((!strcmp(argv[i], "-recover")) || |
2969 (!strcmp(argv[i], "--recover"))) { | 3112 (!strcmp(argv[i], "--recover"))) { |
2970 recovery++; | 3113 recovery++; |
2971 options |= XML_PARSE_RECOVER; | 3114 options |= XML_PARSE_RECOVER; |
| 3115 } else if ((!strcmp(argv[i], "-huge")) || |
| 3116 (!strcmp(argv[i], "--huge"))) { |
| 3117 options |= XML_PARSE_HUGE; |
2972 } else if ((!strcmp(argv[i], "-noent")) || | 3118 } else if ((!strcmp(argv[i], "-noent")) || |
2973 (!strcmp(argv[i], "--noent"))) { | 3119 (!strcmp(argv[i], "--noent"))) { |
2974 noent++; | 3120 noent++; |
2975 options |= XML_PARSE_NOENT; | 3121 options |= XML_PARSE_NOENT; |
2976 } else if ((!strcmp(argv[i], "-nsclean")) || | 3122 } else if ((!strcmp(argv[i], "-nsclean")) || |
2977 (!strcmp(argv[i], "--nsclean"))) { | 3123 (!strcmp(argv[i], "--nsclean"))) { |
2978 options |= XML_PARSE_NSCLEAN; | 3124 options |= XML_PARSE_NSCLEAN; |
2979 } else if ((!strcmp(argv[i], "-nocdata")) || | 3125 } else if ((!strcmp(argv[i], "-nocdata")) || |
2980 (!strcmp(argv[i], "--nocdata"))) { | 3126 (!strcmp(argv[i], "--nocdata"))) { |
2981 options |= XML_PARSE_NOCDATA; | 3127 options |= XML_PARSE_NOCDATA; |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3084 (!strcmp(argv[i], "--xinclude"))) { | 3230 (!strcmp(argv[i], "--xinclude"))) { |
3085 xinclude++; | 3231 xinclude++; |
3086 options |= XML_PARSE_XINCLUDE; | 3232 options |= XML_PARSE_XINCLUDE; |
3087 } | 3233 } |
3088 else if ((!strcmp(argv[i], "-noxincludenode")) || | 3234 else if ((!strcmp(argv[i], "-noxincludenode")) || |
3089 (!strcmp(argv[i], "--noxincludenode"))) { | 3235 (!strcmp(argv[i], "--noxincludenode"))) { |
3090 xinclude++; | 3236 xinclude++; |
3091 options |= XML_PARSE_XINCLUDE; | 3237 options |= XML_PARSE_XINCLUDE; |
3092 options |= XML_PARSE_NOXINCNODE; | 3238 options |= XML_PARSE_NOXINCNODE; |
3093 } | 3239 } |
| 3240 else if ((!strcmp(argv[i], "-nofixup-base-uris")) || |
| 3241 (!strcmp(argv[i], "--nofixup-base-uris"))) { |
| 3242 xinclude++; |
| 3243 options |= XML_PARSE_XINCLUDE; |
| 3244 options |= XML_PARSE_NOBASEFIX; |
| 3245 } |
3094 #endif | 3246 #endif |
3095 #ifdef LIBXML_OUTPUT_ENABLED | 3247 #ifdef LIBXML_OUTPUT_ENABLED |
3096 #ifdef HAVE_ZLIB_H | 3248 #ifdef HAVE_ZLIB_H |
3097 else if ((!strcmp(argv[i], "-compress")) || | 3249 else if ((!strcmp(argv[i], "-compress")) || |
3098 (!strcmp(argv[i], "--compress"))) { | 3250 (!strcmp(argv[i], "--compress"))) { |
3099 compress++; | 3251 compress++; |
3100 xmlSetCompressMode(9); | 3252 xmlSetCompressMode(9); |
3101 } | 3253 } |
3102 #endif | 3254 #endif |
3103 #endif /* LIBXML_OUTPUT_ENABLED */ | 3255 #endif /* LIBXML_OUTPUT_ENABLED */ |
3104 else if ((!strcmp(argv[i], "-nowarning")) || | 3256 else if ((!strcmp(argv[i], "-nowarning")) || |
3105 (!strcmp(argv[i], "--nowarning"))) { | 3257 (!strcmp(argv[i], "--nowarning"))) { |
3106 xmlGetWarningsDefaultValue = 0; | 3258 xmlGetWarningsDefaultValue = 0; |
3107 xmlPedanticParserDefault(0); | 3259 xmlPedanticParserDefault(0); |
3108 options |= XML_PARSE_NOWARNING; | 3260 options |= XML_PARSE_NOWARNING; |
3109 } | 3261 } |
3110 else if ((!strcmp(argv[i], "-pedantic")) || | 3262 else if ((!strcmp(argv[i], "-pedantic")) || |
3111 (!strcmp(argv[i], "--pedantic"))) { | 3263 (!strcmp(argv[i], "--pedantic"))) { |
3112 xmlGetWarningsDefaultValue = 1; | 3264 xmlGetWarningsDefaultValue = 1; |
3113 xmlPedanticParserDefault(1); | 3265 xmlPedanticParserDefault(1); |
3114 options |= XML_PARSE_PEDANTIC; | 3266 options |= XML_PARSE_PEDANTIC; |
3115 } | 3267 } |
3116 #ifdef LIBXML_DEBUG_ENABLED | 3268 #ifdef LIBXML_DEBUG_ENABLED |
3117 else if ((!strcmp(argv[i], "-debugent")) || | 3269 else if ((!strcmp(argv[i], "-debugent")) || |
3118 (!strcmp(argv[i], "--debugent"))) { | 3270 (!strcmp(argv[i], "--debugent"))) { |
3119 debugent++; | 3271 debugent++; |
3120 xmlParserDebugEntities = 1; | 3272 xmlParserDebugEntities = 1; |
3121 » } | 3273 » } |
3122 #endif | 3274 #endif |
3123 #ifdef LIBXML_C14N_ENABLED | 3275 #ifdef LIBXML_C14N_ENABLED |
3124 else if ((!strcmp(argv[i], "-c14n")) || | 3276 else if ((!strcmp(argv[i], "-c14n")) || |
3125 (!strcmp(argv[i], "--c14n"))) { | 3277 (!strcmp(argv[i], "--c14n"))) { |
3126 canonical++; | 3278 canonical++; |
3127 options |= XML_PARSE_NOENT | XML_PARSE_DTDATTR | XML_PARSE_DTDLOAD; | 3279 options |= XML_PARSE_NOENT | XML_PARSE_DTDATTR | XML_PARSE_DTDLOAD; |
3128 » } | 3280 » } |
| 3281 » else if ((!strcmp(argv[i], "-c14n11")) || |
| 3282 » » (!strcmp(argv[i], "--c14n11"))) { |
| 3283 » canonical_11++; |
| 3284 » options |= XML_PARSE_NOENT | XML_PARSE_DTDATTR | XML_PARSE_DTDLOAD; |
| 3285 » } |
3129 else if ((!strcmp(argv[i], "-exc-c14n")) || | 3286 else if ((!strcmp(argv[i], "-exc-c14n")) || |
3130 (!strcmp(argv[i], "--exc-c14n"))) { | 3287 (!strcmp(argv[i], "--exc-c14n"))) { |
3131 exc_canonical++; | 3288 exc_canonical++; |
3132 options |= XML_PARSE_NOENT | XML_PARSE_DTDATTR | XML_PARSE_DTDLOAD; | 3289 options |= XML_PARSE_NOENT | XML_PARSE_DTDATTR | XML_PARSE_DTDLOAD; |
3133 » } | 3290 » } |
3134 #endif | 3291 #endif |
3135 #ifdef LIBXML_CATALOG_ENABLED | 3292 #ifdef LIBXML_CATALOG_ENABLED |
3136 else if ((!strcmp(argv[i], "-catalogs")) || | 3293 else if ((!strcmp(argv[i], "-catalogs")) || |
3137 (!strcmp(argv[i], "--catalogs"))) { | 3294 (!strcmp(argv[i], "--catalogs"))) { |
3138 catalogs++; | 3295 catalogs++; |
3139 } else if ((!strcmp(argv[i], "-nocatalogs")) || | 3296 } else if ((!strcmp(argv[i], "-nocatalogs")) || |
3140 (!strcmp(argv[i], "--nocatalogs"))) { | 3297 (!strcmp(argv[i], "--nocatalogs"))) { |
3141 nocatalogs++; | 3298 nocatalogs++; |
3142 » } | 3299 » } |
3143 #endif | 3300 #endif |
3144 else if ((!strcmp(argv[i], "-encode")) || | 3301 else if ((!strcmp(argv[i], "-encode")) || |
3145 (!strcmp(argv[i], "--encode"))) { | 3302 (!strcmp(argv[i], "--encode"))) { |
3146 i++; | 3303 i++; |
3147 encoding = argv[i]; | 3304 encoding = argv[i]; |
3148 /* | 3305 /* |
3149 * OK it's for testing purposes | 3306 * OK it's for testing purposes |
3150 */ | 3307 */ |
3151 xmlAddEncodingAlias("UTF-8", "DVEnc"); | 3308 xmlAddEncodingAlias("UTF-8", "DVEnc"); |
3152 } | 3309 } |
(...skipping 27 matching lines...) Expand all Loading... |
3180 } | 3337 } |
3181 else if ((!strcmp(argv[i], "-walker")) || | 3338 else if ((!strcmp(argv[i], "-walker")) || |
3182 (!strcmp(argv[i], "--walker"))) { | 3339 (!strcmp(argv[i], "--walker"))) { |
3183 walker++; | 3340 walker++; |
3184 noout++; | 3341 noout++; |
3185 } | 3342 } |
3186 #endif /* LIBXML_READER_ENABLED */ | 3343 #endif /* LIBXML_READER_ENABLED */ |
3187 #ifdef LIBXML_SAX1_ENABLED | 3344 #ifdef LIBXML_SAX1_ENABLED |
3188 else if ((!strcmp(argv[i], "-sax1")) || | 3345 else if ((!strcmp(argv[i], "-sax1")) || |
3189 (!strcmp(argv[i], "--sax1"))) { | 3346 (!strcmp(argv[i], "--sax1"))) { |
3190 » sax1++; | 3347 » sax1++; |
| 3348 » options |= XML_PARSE_SAX1; |
3191 } | 3349 } |
3192 #endif /* LIBXML_SAX1_ENABLED */ | 3350 #endif /* LIBXML_SAX1_ENABLED */ |
3193 else if ((!strcmp(argv[i], "-sax")) || | 3351 else if ((!strcmp(argv[i], "-sax")) || |
3194 (!strcmp(argv[i], "--sax"))) { | 3352 (!strcmp(argv[i], "--sax"))) { |
3195 » sax++; | 3353 » sax++; |
3196 } | 3354 } |
3197 else if ((!strcmp(argv[i], "-chkregister")) || | 3355 else if ((!strcmp(argv[i], "-chkregister")) || |
3198 (!strcmp(argv[i], "--chkregister"))) { | 3356 (!strcmp(argv[i], "--chkregister"))) { |
3199 » chkregister++; | 3357 » chkregister++; |
3200 #ifdef LIBXML_SCHEMAS_ENABLED | 3358 #ifdef LIBXML_SCHEMAS_ENABLED |
3201 } else if ((!strcmp(argv[i], "-relaxng")) || | 3359 } else if ((!strcmp(argv[i], "-relaxng")) || |
3202 (!strcmp(argv[i], "--relaxng"))) { | 3360 (!strcmp(argv[i], "--relaxng"))) { |
3203 i++; | 3361 i++; |
3204 relaxng = argv[i]; | 3362 relaxng = argv[i]; |
3205 noent++; | 3363 noent++; |
3206 options |= XML_PARSE_NOENT; | 3364 options |= XML_PARSE_NOENT; |
3207 } else if ((!strcmp(argv[i], "-schema")) || | 3365 } else if ((!strcmp(argv[i], "-schema")) || |
3208 (!strcmp(argv[i], "--schema"))) { | 3366 (!strcmp(argv[i], "--schema"))) { |
3209 i++; | 3367 i++; |
(...skipping 20 matching lines...) Expand all Loading... |
3230 } else if ((!strcmp(argv[i], "-path")) || | 3388 } else if ((!strcmp(argv[i], "-path")) || |
3231 (!strcmp(argv[i], "--path"))) { | 3389 (!strcmp(argv[i], "--path"))) { |
3232 i++; | 3390 i++; |
3233 parsePath(BAD_CAST argv[i]); | 3391 parsePath(BAD_CAST argv[i]); |
3234 #ifdef LIBXML_PATTERN_ENABLED | 3392 #ifdef LIBXML_PATTERN_ENABLED |
3235 } else if ((!strcmp(argv[i], "-pattern")) || | 3393 } else if ((!strcmp(argv[i], "-pattern")) || |
3236 (!strcmp(argv[i], "--pattern"))) { | 3394 (!strcmp(argv[i], "--pattern"))) { |
3237 i++; | 3395 i++; |
3238 pattern = argv[i]; | 3396 pattern = argv[i]; |
3239 #endif | 3397 #endif |
| 3398 #ifdef LIBXML_XPATH_ENABLED |
| 3399 } else if ((!strcmp(argv[i], "-xpath")) || |
| 3400 (!strcmp(argv[i], "--xpath"))) { |
| 3401 i++; |
| 3402 noout++; |
| 3403 xpathquery = argv[i]; |
| 3404 #endif |
| 3405 } else if ((!strcmp(argv[i], "-oldxml10")) || |
| 3406 (!strcmp(argv[i], "--oldxml10"))) { |
| 3407 oldxml10++; |
| 3408 options |= XML_PARSE_OLD10; |
3240 } else { | 3409 } else { |
3241 fprintf(stderr, "Unknown option %s\n", argv[i]); | 3410 fprintf(stderr, "Unknown option %s\n", argv[i]); |
3242 usage(argv[0]); | 3411 usage(argv[0]); |
3243 return(1); | 3412 return(1); |
3244 } | 3413 } |
3245 } | 3414 } |
3246 | 3415 |
3247 #ifdef LIBXML_CATALOG_ENABLED | 3416 #ifdef LIBXML_CATALOG_ENABLED |
3248 if (nocatalogs == 0) { | 3417 if (nocatalogs == 0) { |
3249 if (catalogs) { | 3418 if (catalogs) { |
(...skipping 13 matching lines...) Expand all Loading... |
3263 if (sax1) | 3432 if (sax1) |
3264 xmlSAXDefaultVersion(1); | 3433 xmlSAXDefaultVersion(1); |
3265 else | 3434 else |
3266 xmlSAXDefaultVersion(2); | 3435 xmlSAXDefaultVersion(2); |
3267 #endif /* LIBXML_SAX1_ENABLED */ | 3436 #endif /* LIBXML_SAX1_ENABLED */ |
3268 | 3437 |
3269 if (chkregister) { | 3438 if (chkregister) { |
3270 xmlRegisterNodeDefault(registerNode); | 3439 xmlRegisterNodeDefault(registerNode); |
3271 xmlDeregisterNodeDefault(deregisterNode); | 3440 xmlDeregisterNodeDefault(deregisterNode); |
3272 } | 3441 } |
3273 | 3442 |
3274 indent = getenv("XMLLINT_INDENT"); | 3443 indent = getenv("XMLLINT_INDENT"); |
3275 if(indent != NULL) { | 3444 if(indent != NULL) { |
3276 xmlTreeIndentString = indent; | 3445 xmlTreeIndentString = indent; |
3277 } | 3446 } |
3278 | 3447 |
3279 | 3448 |
3280 defaultEntityLoader = xmlGetExternalEntityLoader(); | 3449 defaultEntityLoader = xmlGetExternalEntityLoader(); |
3281 xmlSetExternalEntityLoader(xmllintExternalEntityLoader); | 3450 xmlSetExternalEntityLoader(xmllintExternalEntityLoader); |
3282 | 3451 |
3283 xmlLineNumbersDefault(1); | 3452 xmlLineNumbersDefault(1); |
3284 if (loaddtd != 0) | 3453 if (loaddtd != 0) |
3285 xmlLoadExtDtdDefaultValue |= XML_DETECT_IDS; | 3454 xmlLoadExtDtdDefaultValue |= XML_DETECT_IDS; |
3286 if (dtdattrs) | 3455 if (dtdattrs) |
3287 xmlLoadExtDtdDefaultValue |= XML_COMPLETE_ATTRS; | 3456 xmlLoadExtDtdDefaultValue |= XML_COMPLETE_ATTRS; |
3288 if (noent != 0) xmlSubstituteEntitiesDefault(1); | 3457 if (noent != 0) xmlSubstituteEntitiesDefault(1); |
3289 #ifdef LIBXML_VALID_ENABLED | 3458 #ifdef LIBXML_VALID_ENABLED |
3290 if (valid != 0) xmlDoValidityCheckingDefaultValue = 1; | 3459 if (valid != 0) xmlDoValidityCheckingDefaultValue = 1; |
3291 #endif /* LIBXML_VALID_ENABLED */ | 3460 #endif /* LIBXML_VALID_ENABLED */ |
3292 if ((htmlout) && (!nowrap)) { | 3461 if ((htmlout) && (!nowrap)) { |
3293 xmlGenericError(xmlGenericErrorContext, | 3462 xmlGenericError(xmlGenericErrorContext, |
3294 "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\"\n"); | 3463 "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\"\n"); |
3295 xmlGenericError(xmlGenericErrorContext, | 3464 xmlGenericError(xmlGenericErrorContext, |
3296 "\t\"http://www.w3.org/TR/REC-html40/loose.dtd\">\n"); | 3465 "\t\"http://www.w3.org/TR/REC-html40/loose.dtd\">\n"); |
3297 xmlGenericError(xmlGenericErrorContext, | 3466 xmlGenericError(xmlGenericErrorContext, |
3298 "<html><head><title>%s output</title></head>\n", | 3467 "<html><head><title>%s output</title></head>\n", |
3299 argv[0]); | 3468 argv[0]); |
3300 » xmlGenericError(xmlGenericErrorContext, | 3469 » xmlGenericError(xmlGenericErrorContext, |
3301 "<body bgcolor=\"#ffffff\"><h1 align=\"center\">%s output</h1>\n", | 3470 "<body bgcolor=\"#ffffff\"><h1 align=\"center\">%s output</h1>\n", |
3302 argv[0]); | 3471 argv[0]); |
3303 } | 3472 } |
3304 | 3473 |
3305 #ifdef LIBXML_SCHEMATRON_ENABLED | 3474 #ifdef LIBXML_SCHEMATRON_ENABLED |
3306 if ((schematron != NULL) && (sax == 0) | 3475 if ((schematron != NULL) && (sax == 0) |
3307 #ifdef LIBXML_READER_ENABLED | 3476 #ifdef LIBXML_READER_ENABLED |
3308 && (stream == 0) | 3477 && (stream == 0) |
3309 #endif /* LIBXML_READER_ENABLED */ | 3478 #endif /* LIBXML_READER_ENABLED */ |
3310 ) { | 3479 ) { |
3311 xmlSchematronParserCtxtPtr ctxt; | 3480 xmlSchematronParserCtxtPtr ctxt; |
3312 | 3481 |
3313 /* forces loading the DTDs */ | 3482 /* forces loading the DTDs */ |
3314 xmlLoadExtDtdDefaultValue |= 1; | 3483 xmlLoadExtDtdDefaultValue |= 1; |
3315 options |= XML_PARSE_DTDLOAD; | 3484 options |= XML_PARSE_DTDLOAD; |
3316 if (timing) { | 3485 if (timing) { |
3317 startTimer(); | 3486 startTimer(); |
3318 } | 3487 } |
3319 ctxt = xmlSchematronNewParserCtxt(schematron); | 3488 ctxt = xmlSchematronNewParserCtxt(schematron); |
3320 #if 0 | 3489 #if 0 |
3321 xmlSchematronSetParserErrors(ctxt, | 3490 xmlSchematronSetParserErrors(ctxt, |
3322 (xmlSchematronValidityErrorFunc) fprintf, | 3491 (xmlSchematronValidityErrorFunc) fprintf, |
3323 (xmlSchematronValidityWarningFunc) fprintf, | 3492 (xmlSchematronValidityWarningFunc) fprintf, |
3324 stderr); | 3493 stderr); |
(...skipping 13 matching lines...) Expand all Loading... |
3338 #endif | 3507 #endif |
3339 #ifdef LIBXML_SCHEMAS_ENABLED | 3508 #ifdef LIBXML_SCHEMAS_ENABLED |
3340 if ((relaxng != NULL) && (sax == 0) | 3509 if ((relaxng != NULL) && (sax == 0) |
3341 #ifdef LIBXML_READER_ENABLED | 3510 #ifdef LIBXML_READER_ENABLED |
3342 && (stream == 0) | 3511 && (stream == 0) |
3343 #endif /* LIBXML_READER_ENABLED */ | 3512 #endif /* LIBXML_READER_ENABLED */ |
3344 ) { | 3513 ) { |
3345 xmlRelaxNGParserCtxtPtr ctxt; | 3514 xmlRelaxNGParserCtxtPtr ctxt; |
3346 | 3515 |
3347 /* forces loading the DTDs */ | 3516 /* forces loading the DTDs */ |
3348 xmlLoadExtDtdDefaultValue |= 1; | 3517 xmlLoadExtDtdDefaultValue |= 1; |
3349 options |= XML_PARSE_DTDLOAD; | 3518 options |= XML_PARSE_DTDLOAD; |
3350 if (timing) { | 3519 if (timing) { |
3351 startTimer(); | 3520 startTimer(); |
3352 } | 3521 } |
3353 ctxt = xmlRelaxNGNewParserCtxt(relaxng); | 3522 ctxt = xmlRelaxNGNewParserCtxt(relaxng); |
3354 xmlRelaxNGSetParserErrors(ctxt, | 3523 xmlRelaxNGSetParserErrors(ctxt, |
3355 (xmlRelaxNGValidityErrorFunc) fprintf, | 3524 (xmlRelaxNGValidityErrorFunc) fprintf, |
3356 (xmlRelaxNGValidityWarningFunc) fprintf, | 3525 (xmlRelaxNGValidityWarningFunc) fprintf, |
3357 stderr); | 3526 stderr); |
3358 relaxngschemas = xmlRelaxNGParse(ctxt); | 3527 relaxngschemas = xmlRelaxNGParse(ctxt); |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3418 (!strcmp(argv[i], "-output")) || | 3587 (!strcmp(argv[i], "-output")) || |
3419 (!strcmp(argv[i], "--output"))) { | 3588 (!strcmp(argv[i], "--output"))) { |
3420 i++; | 3589 i++; |
3421 continue; | 3590 continue; |
3422 } | 3591 } |
3423 #ifdef LIBXML_VALID_ENABLED | 3592 #ifdef LIBXML_VALID_ENABLED |
3424 if ((!strcmp(argv[i], "-dtdvalid")) || | 3593 if ((!strcmp(argv[i], "-dtdvalid")) || |
3425 (!strcmp(argv[i], "--dtdvalid"))) { | 3594 (!strcmp(argv[i], "--dtdvalid"))) { |
3426 i++; | 3595 i++; |
3427 continue; | 3596 continue; |
3428 } | 3597 } |
3429 if ((!strcmp(argv[i], "-path")) || | 3598 if ((!strcmp(argv[i], "-path")) || |
3430 (!strcmp(argv[i], "--path"))) { | 3599 (!strcmp(argv[i], "--path"))) { |
3431 i++; | 3600 i++; |
3432 continue; | 3601 continue; |
3433 } | 3602 } |
3434 if ((!strcmp(argv[i], "-dtdvalidfpi")) || | 3603 if ((!strcmp(argv[i], "-dtdvalidfpi")) || |
3435 (!strcmp(argv[i], "--dtdvalidfpi"))) { | 3604 (!strcmp(argv[i], "--dtdvalidfpi"))) { |
3436 i++; | 3605 i++; |
3437 continue; | 3606 continue; |
3438 } | 3607 } |
(...skipping 18 matching lines...) Expand all Loading... |
3457 i++; | 3626 i++; |
3458 continue; | 3627 continue; |
3459 } | 3628 } |
3460 #ifdef LIBXML_PATTERN_ENABLED | 3629 #ifdef LIBXML_PATTERN_ENABLED |
3461 if ((!strcmp(argv[i], "-pattern")) || | 3630 if ((!strcmp(argv[i], "-pattern")) || |
3462 (!strcmp(argv[i], "--pattern"))) { | 3631 (!strcmp(argv[i], "--pattern"))) { |
3463 i++; | 3632 i++; |
3464 continue; | 3633 continue; |
3465 } | 3634 } |
3466 #endif | 3635 #endif |
| 3636 #ifdef LIBXML_XPATH_ENABLED |
| 3637 if ((!strcmp(argv[i], "-xpath")) || |
| 3638 (!strcmp(argv[i], "--xpath"))) { |
| 3639 i++; |
| 3640 continue; |
| 3641 } |
| 3642 #endif |
3467 if ((timing) && (repeat)) | 3643 if ((timing) && (repeat)) |
3468 startTimer(); | 3644 startTimer(); |
3469 /* Remember file names. "-" means stdin. <sven@zen.org> */ | 3645 /* Remember file names. "-" means stdin. <sven@zen.org> */ |
3470 if ((argv[i][0] != '-') || (strcmp(argv[i], "-") == 0)) { | 3646 if ((argv[i][0] != '-') || (strcmp(argv[i], "-") == 0)) { |
3471 if (repeat) { | 3647 if (repeat) { |
3472 xmlParserCtxtPtr ctxt = NULL; | 3648 xmlParserCtxtPtr ctxt = NULL; |
3473 | 3649 |
3474 for (acount = 0;acount < repeat;acount++) { | 3650 for (acount = 0;acount < repeat;acount++) { |
3475 #ifdef LIBXML_READER_ENABLED | 3651 #ifdef LIBXML_READER_ENABLED |
3476 if (stream != 0) { | 3652 if (stream != 0) { |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3508 fprintf(stderr, "Registration count off: %d\n", nbregister); | 3684 fprintf(stderr, "Registration count off: %d\n", nbregister); |
3509 progresult = XMLLINT_ERR_RDREGIS; | 3685 progresult = XMLLINT_ERR_RDREGIS; |
3510 } | 3686 } |
3511 } | 3687 } |
3512 files ++; | 3688 files ++; |
3513 if ((timing) && (repeat)) { | 3689 if ((timing) && (repeat)) { |
3514 endTimer("%d iterations", repeat); | 3690 endTimer("%d iterations", repeat); |
3515 } | 3691 } |
3516 } | 3692 } |
3517 } | 3693 } |
3518 if (generate) | 3694 if (generate) |
3519 parseAndPrintFile(NULL, NULL); | 3695 parseAndPrintFile(NULL, NULL); |
3520 if ((htmlout) && (!nowrap)) { | 3696 if ((htmlout) && (!nowrap)) { |
3521 xmlGenericError(xmlGenericErrorContext, "</body></html>\n"); | 3697 xmlGenericError(xmlGenericErrorContext, "</body></html>\n"); |
3522 } | 3698 } |
3523 if ((files == 0) && (!generate) && (version == 0)) { | 3699 if ((files == 0) && (!generate) && (version == 0)) { |
3524 usage(argv[0]); | 3700 usage(argv[0]); |
3525 } | 3701 } |
3526 #ifdef LIBXML_SCHEMATRON_ENABLED | 3702 #ifdef LIBXML_SCHEMATRON_ENABLED |
3527 if (wxschematron != NULL) | 3703 if (wxschematron != NULL) |
3528 xmlSchematronFree(wxschematron); | 3704 xmlSchematronFree(wxschematron); |
3529 #endif | 3705 #endif |
3530 #ifdef LIBXML_SCHEMAS_ENABLED | 3706 #ifdef LIBXML_SCHEMAS_ENABLED |
3531 if (relaxngschemas != NULL) | 3707 if (relaxngschemas != NULL) |
3532 xmlRelaxNGFree(relaxngschemas); | 3708 xmlRelaxNGFree(relaxngschemas); |
3533 if (wxschemas != NULL) | 3709 if (wxschemas != NULL) |
3534 xmlSchemaFree(wxschemas); | 3710 xmlSchemaFree(wxschemas); |
3535 xmlRelaxNGCleanupTypes(); | 3711 xmlRelaxNGCleanupTypes(); |
3536 #endif | 3712 #endif |
3537 #ifdef LIBXML_PATTERN_ENABLED | 3713 #ifdef LIBXML_PATTERN_ENABLED |
3538 if (patternc != NULL) | 3714 if (patternc != NULL) |
3539 xmlFreePattern(patternc); | 3715 xmlFreePattern(patternc); |
3540 #endif | 3716 #endif |
3541 xmlCleanupParser(); | 3717 xmlCleanupParser(); |
3542 xmlMemoryDump(); | 3718 xmlMemoryDump(); |
3543 | 3719 |
3544 return(progresult); | 3720 return(progresult); |
3545 } | 3721 } |
3546 | 3722 |
OLD | NEW |