2002/ws/desc/tools ValidateSchema.java,NONE,1.1 ValidateSchema.class,NONE,1.1 xercesImpl.jar,1.4,1.5

Update of /sources/public/2002/ws/desc/tools
In directory homer:/tmp/cvs-serv20924

Modified Files:
	xercesImpl.jar 
Added Files:
	ValidateSchema.java ValidateSchema.class 
Log Message:
Schema validation

Index: xercesImpl.jar
===================================================================
RCS file: /sources/public/2002/ws/desc/tools/xercesImpl.jar,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
Binary files /tmp/cvsUTUy30 and /tmp/cvsdbrxyQ differ

--- NEW FILE: ValidateSchema.java ---
// Validates schemas - HH 2005-10-21
// $Id: ValidateSchema.java,v 1.1 2005/10/21 12:54:41 hugo Exp $

import org.apache.xerces.parsers.DOMParser;
import org.xml.sax.ErrorHandler;
import org.xml.sax.SAXParseException;

public class ValidateSchema implements ErrorHandler {

    private int exitcode;
    
    public ValidateSchema(String file) {
	DOMParser parser = new DOMParser();

	parser.setErrorHandler(this);

	try {
	    // Setting all the features so that we validate fully
	    parser.setFeature("http://xml.org/sax/features/validation", true);
	    parser.setFeature("http://apache.org/xml/features/validation/schema",true);
	    parser.setFeature("http://apache.org/xml/features/validation/schema-full-checking",true);    
	    // Location of my Schema 1.0 schema
	    parser.setProperty("http://apache.org/xml/properties/schema/external-schemaLocation",
			       "http://www.w3.org/2001/XMLSchema file:../tools/schema10.xsd");

	} catch (Exception e) {
	    errorh("Feature error", e);
	}

	// Do the parsing
        try {
            parser.parse(file);
        } catch (Exception e) {
	    errorh("Parsing error", e);
        }
    }

    private void errorh(String type, Exception e) {
	String msg = new String(e.toString());
	String ridof = new String("org.xml.sax.SAXParseException: ");
	msg = msg.substring(ridof.length());
        System.err.println("[" + type + "] " + msg);
	exitcode = 1;
    }

    public void warning(SAXParseException e) {
	errorh("Warning", e);
    }
    public void error(SAXParseException e) {
	errorh("Error", e);
    }
    public void fatalError(SAXParseException e) {
	errorh("Fatal", e);
    }

    public int exit() {
	return exitcode;
    }

    public static void main (String[] args) {
	if (args == null || args.length != 1) {
	    System.err.println("Usage: ValidateSchema <schema URI>");
	    return;
	}
        ValidateSchema validator = new ValidateSchema(args[0]);
	System.exit(validator.exit());
    }
}

--- NEW FILE: ValidateSchema.class ---
(This appears to be a binary file; contents omitted.)

Received on Friday, 21 October 2005 12:54:53 UTC