001 package com.thaiopensource.validate.auto; 002 003 import com.thaiopensource.util.PropertyMap; 004 import com.thaiopensource.validate.IncorrectSchemaException; 005 import com.thaiopensource.validate.Schema; 006 import com.thaiopensource.validate.SchemaReader; 007 import com.thaiopensource.validate.auto.ReparseException; 008 import com.thaiopensource.validate.auto.SchemaFuture; 009 import org.xml.sax.InputSource; 010 import org.xml.sax.SAXException; 011 import org.xml.sax.XMLReader; 012 013 import java.io.IOException; 014 015 public class SchemaReaderSchemaReceiver implements SchemaReceiver { 016 private final SchemaReader schemaLanguage; 017 private final PropertyMap properties; 018 019 public SchemaReaderSchemaReceiver(SchemaReader schemaLanguage, PropertyMap properties) { 020 this.schemaLanguage = schemaLanguage; 021 this.properties = properties; 022 } 023 024 public SchemaFuture installHandlers(XMLReader xr) throws SAXException { 025 throw new ReparseException() { 026 public Schema reparse(InputSource in) throws IncorrectSchemaException, SAXException, IOException { 027 return schemaLanguage.createSchema(in, properties); 028 } 029 }; 030 } 031 }