File:  [Public] / XML / testSchema.c
Revision 1.3: download - view: text, annotated - select for diffs
Mon Sep 25 14:24:33 2000 UTC (25 years, 2 months ago) by veillard
Branches: MAIN
CVS tags: LIBXML_2_2_8, LIBXML_2_2_6, HEAD
Avoiding a few warning when compiling with MSC, Daniel

/*
 * testScheam.c : a small tester program for Schema validation
 *
 * See Copyright for the status of this software.
 *
 * Daniel.Veillard@w3.org
 */

#ifdef WIN32
#include "win32config.h"
#else
#include "config.h"
#endif

#include "xmlversion.h"
#include "libxml/parser.h"
/* #ifdef LIBXML_SCHEMA_ENABLED */

#include <stdio.h>
#include <string.h>
#include <stdarg.h>


#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#ifdef HAVE_SYS_STAT_H
#include <sys/stat.h>
#endif
#ifdef HAVE_FCNTL_H
#include <fcntl.h>
#endif
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
#endif

#include <libxml/xmlmemory.h>
#include <libxml/schema.h>
#include <libxml/debugXML.h>

#ifdef LIBXML_DEBUG_ENABLED
static int debug = 0;
#endif
static int noout = 0;


int main(int argc, char **argv) {
    int i;
    int files = 0;
    xmlSchemaPtr schema = NULL;
    xmlSchemaValidCtxt ctxt;

    for (i = 1; i < argc ; i++) {
#ifdef LIBXML_DEBUG_ENABLED
	if ((!strcmp(argv[i], "-debug")) || (!strcmp(argv[i], "--debug")))
	    debug++;
	else
#endif
	if ((!strcmp(argv[i], "-noout")) || (!strcmp(argv[i], "--noout"))) {
	    noout++;
        }
    }
    ctxt.userData = stderr;
    ctxt.error = (xmlSchemaValidityErrorFunc) fprintf;
    ctxt.warning = (xmlSchemaValidityWarningFunc) fprintf;
    for (i = 1; i < argc ; i++) {
	if (argv[i][0] != '-') {
	    if (schema != NULL)
		schema = xmlSchemaLoad(&ctxt, argv[i]);
	    files ++;
	}
    }
    if (schema != NULL)
	xmlSchemaFree(schema);
    if (files == 0) {
	printf("Usage : %s [--debug] [--copy] [--copy] HTMLfiles ...\n",
	       argv[0]);
	printf("\tParse the HTML files and output the result of the parsing\n");
#ifdef LIBXML_DEBUG_ENABLED
	printf("\t--debug : dump a debug tree of the in-memory document\n");
#endif
	printf("\t--copy : used to test the internal copy implementation\n");
	printf("\t--sax : debug the sequence of SAX callbacks\n");
	printf("\t--repeat : parse the file 100 times, for timing\n");
	printf("\t--noout : do not print the result\n");
	printf("\t--push : use the push mode parser\n");
	printf("\t--encode encoding : output in the given encoding\n");
    }
    xmlCleanupParser();
    xmlMemoryDump();

    return(0);
}
/* !LIBXML_SCHEMA_ENABLED
#else
#include <stdio.h>
int main(int argc, char **argv) {
    printf("%s : HTML support not compiled in\n", argv[0]);
    return(0);
}
#endif
*/

Webmaster