code: public static Schema genSchema(Store env, String ... filenames) throws APIException {
  		String schemaDir = env.get(
  				env.staticSlot(EnvFactory.SCHEMA_DIR),
  				EnvFactory.DEFAULT_SCHEMA_DIR);
  		File dir = new File(schemaDir);
  		if(!dir.exists())throw new APIException("Schema Directory " + schemaDir + " does not exist.  You can set this with " + EnvFactory.SCHEMA_DIR + " property");
  		FileInputStream[] fis = new FileInputStream[filenames.length];
  		Source[] sources = new Source[filenames.length];
  		File f; 
  		for(int i=0; i<filenames.length; ++i) {
  			if(!(f=new File(schemaDir + File.separatorChar + filenames[i])).exists()) {
  				if(!f.exists()) throw new APIException("Cannot find " + f.getName() + " for schema validation");
  			}
  			try {
  				fis[i]=new FileInputStream(f);
  			} catch (FileNotFoundException e) {
  				throw new APIException(e);
  			}
  			sources[i]= new StreamSource(fis[i]);
  		}
  		try {
  			//Note: SchemaFactory is not reentrant or very thread safe either... see docs
  			synchronized(XMLConstants.W3C_XML_SCHEMA_NS_URI) { // SchemaFactory is not reentrant
  				return SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI)
  				 	.newSchema(sources);
  			}
  		} catch (SAXException e) {
  			throw new APIException(e);
  		} finally {
  			for(FileInputStream d : fis) {
  				try {
  					d.close();
  				} catch (IOException e) {
  				 // Never mind... we did our best
  				}
  			}
  		}
  
  	}
docs: Generate a Schema Object for use in validation based on FileNames.
  
  WARNING: The java.xml.binding code requires YOU to figure out what order the
  files go in.  If there is an import from A in B, then you must list A first.
  
  @param err
  @param filenames
  @return
  @throws APIException