Annotation of XML/testSchema.c, revision 1.2

1.1       veillard    1: /*
                      2:  * testScheam.c : a small tester program for Schema validation
                      3:  *
                      4:  * See Copyright for the status of this software.
                      5:  *
                      6:  * Daniel.Veillard@w3.org
                      7:  */
                      8: 
                      9: #ifdef WIN32
                     10: #include "win32config.h"
                     11: #else
                     12: #include "config.h"
                     13: #endif
                     14: 
                     15: #include "xmlversion.h"
1.2     ! veillard   16: #include "libxml/parser.h"
1.1       veillard   17: /* #ifdef LIBXML_SCHEMA_ENABLED */
                     18: 
                     19: #include <stdio.h>
                     20: #include <string.h>
                     21: #include <stdarg.h>
                     22: 
                     23: 
                     24: #ifdef HAVE_SYS_TYPES_H
                     25: #include <sys/types.h>
                     26: #endif
                     27: #ifdef HAVE_SYS_STAT_H
                     28: #include <sys/stat.h>
                     29: #endif
                     30: #ifdef HAVE_FCNTL_H
                     31: #include <fcntl.h>
                     32: #endif
                     33: #ifdef HAVE_UNISTD_H
                     34: #include <unistd.h>
                     35: #endif
                     36: #ifdef HAVE_STDLIB_H
                     37: #include <stdlib.h>
                     38: #endif
                     39: 
                     40: #include <libxml/xmlmemory.h>
                     41: #include <libxml/schema.h>
                     42: #include <libxml/debugXML.h>
                     43: 
                     44: #ifdef LIBXML_DEBUG_ENABLED
                     45: static int debug = 0;
                     46: #endif
                     47: static int noout = 0;
                     48: 
                     49: 
                     50: int main(int argc, char **argv) {
1.2     ! veillard   51:     int i;
1.1       veillard   52:     int files = 0;
                     53:     xmlSchemaPtr schema;
                     54:     xmlSchemaValidCtxt ctxt;
                     55: 
                     56:     for (i = 1; i < argc ; i++) {
                     57: #ifdef LIBXML_DEBUG_ENABLED
                     58:        if ((!strcmp(argv[i], "-debug")) || (!strcmp(argv[i], "--debug")))
                     59:            debug++;
                     60:        else
                     61: #endif
                     62:        if ((!strcmp(argv[i], "-noout")) || (!strcmp(argv[i], "--noout"))) {
                     63:            noout++;
                     64:         }
                     65:     }
                     66:     ctxt.userData = stderr;
                     67:     ctxt.error = (xmlSchemaValidityErrorFunc) fprintf;
                     68:     ctxt.warning = (xmlSchemaValidityWarningFunc) fprintf;
                     69:     for (i = 1; i < argc ; i++) {
                     70:        if (argv[i][0] != '-') {
                     71:            if (schema != NULL)
                     72:                schema = xmlSchemaLoad(&ctxt, argv[i]);
                     73:            files ++;
                     74:        }
                     75:     }
                     76:     if (schema != NULL)
                     77:        xmlSchemaFree(schema);
                     78:     if (files == 0) {
                     79:        printf("Usage : %s [--debug] [--copy] [--copy] HTMLfiles ...\n",
                     80:               argv[0]);
                     81:        printf("\tParse the HTML files and output the result of the parsing\n");
                     82: #ifdef LIBXML_DEBUG_ENABLED
                     83:        printf("\t--debug : dump a debug tree of the in-memory document\n");
                     84: #endif
                     85:        printf("\t--copy : used to test the internal copy implementation\n");
                     86:        printf("\t--sax : debug the sequence of SAX callbacks\n");
                     87:        printf("\t--repeat : parse the file 100 times, for timing\n");
                     88:        printf("\t--noout : do not print the result\n");
                     89:        printf("\t--push : use the push mode parser\n");
                     90:        printf("\t--encode encoding : output in the given encoding\n");
                     91:     }
                     92:     xmlCleanupParser();
                     93:     xmlMemoryDump();
                     94: 
                     95:     return(0);
                     96: }
                     97: /* !LIBXML_SCHEMA_ENABLED
                     98: #else
                     99: #include <stdio.h>
                    100: int main(int argc, char **argv) {
                    101:     printf("%s : HTML support not compiled in\n", argv[0]);
                    102:     return(0);
                    103: }
                    104: #endif
                    105: */

Webmaster