1 package com.thaiopensource.relaxng.jarv; 2 3 import com.thaiopensource.validate.IncorrectSchemaException; 4 import com.thaiopensource.xml.sax.XMLReaderCreator; 5 import com.thaiopensource.relaxng.impl.SchemaBuilderImpl; 6 import com.thaiopensource.relaxng.impl.SchemaPatternBuilder; 7 import com.thaiopensource.relaxng.parse.Parseable; 8 import com.thaiopensource.relaxng.parse.sax.SAXParseable; 9 import com.thaiopensource.xml.sax.DraconianErrorHandler; 10 import com.thaiopensource.xml.sax.Jaxp11XMLReaderCreator; 11 import org.iso_relax.verifier.Schema; 12 import org.iso_relax.verifier.VerifierFactory; 13 import org.relaxng.datatype.DatatypeLibraryFactory; 14 import org.relaxng.datatype.helpers.DatatypeLibraryLoader; 15 import org.xml.sax.ErrorHandler ; 16 import org.xml.sax.InputSource ; 17 import org.xml.sax.SAXException ; 18 19 import java.io.IOException ; 20 21 public class VerifierFactoryImpl extends VerifierFactory { 22 private final XMLReaderCreator xrc = new Jaxp11XMLReaderCreator(); 23 private final DatatypeLibraryFactory dlf = new DatatypeLibraryLoader(); 24 private final ErrorHandler eh = new DraconianErrorHandler(); 25 26 public VerifierFactoryImpl() { } 27 28 public Schema compileSchema(InputSource is) throws SAXException , IOException { 29 SchemaPatternBuilder spb = new SchemaPatternBuilder(); 30 Parseable parseable = new SAXParseable(xrc, is, eh); 31 try { 32 return new SchemaImpl(SchemaBuilderImpl.parse(parseable, eh, dlf, spb, false), spb); 33 } 34 catch (IncorrectSchemaException e) { 35 throw new SAXException ("unreported schema error"); 36 } 37 } 38 } 39 | Popular Tags |