Annotation of XML/testSchema.c, revision 1.1

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

Webmaster