KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > thaiopensource > relaxng > jarv > VerifierFactoryImpl


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 JavaDoc;
16 import org.xml.sax.InputSource JavaDoc;
17 import org.xml.sax.SAXException JavaDoc;
18
19 import java.io.IOException JavaDoc;
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 JavaDoc is) throws SAXException JavaDoc, IOException JavaDoc {
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 JavaDoc("unreported schema error");
36     }
37   }
38 }
39
Popular Tags