package com.thaiopensource.relaxng.jarv;

import com.thaiopensource.datatype.DatatypeLibraryLoader;
import com.thaiopensource.relaxng.parse.IllegalSchemaException;
import com.thaiopensource.relaxng.parse.Parseable;
import com.thaiopensource.relaxng.parse.sax.SAXParseable;
import com.thaiopensource.relaxng.pattern.SchemaBuilderImpl;
import com.thaiopensource.relaxng.pattern.SchemaPatternBuilder;
import com.thaiopensource.resolver.Resolver;
import com.thaiopensource.resolver.xml.sax.SAX;
import com.thaiopensource.resolver.xml.sax.SAXResolver;
import com.thaiopensource.xml.sax.DraconianErrorHandler;
import org.iso_relax.verifier.Schema;
import org.iso_relax.verifier.VerifierFactory;
import org.relaxng.datatype.DatatypeLibraryFactory;
import org.xml.sax.EntityResolver;
import org.xml.sax.ErrorHandler;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;

import javax.xml.transform.sax.SAXSource;
import java.io.IOException;

public class VerifierFactoryImpl extends VerifierFactory {
  private final DatatypeLibraryFactory dlf = new DatatypeLibraryLoader();
  private final ErrorHandler eh = new DraconianErrorHandler();

  public VerifierFactoryImpl() { }

  public Schema compileSchema(InputSource inputSource) throws SAXException, IOException {
    SchemaPatternBuilder spb = new SchemaPatternBuilder();
    Resolver resolver = null;
    EntityResolver entityResolver = getEntityResolver();
    if (entityResolver != null)
      resolver = SAX.createResolver(entityResolver, true);
    SAXResolver saxResolver = new SAXResolver(resolver);
    Parseable parseable = new SAXParseable(new SAXSource(saxResolver.createXMLReader(), inputSource),
                                           saxResolver,
                                           eh);
    try {
      return new SchemaImpl(SchemaBuilderImpl.parse(parseable, eh, dlf, spb, false), spb);
    }
    catch (IllegalSchemaException e) {
      throw new SAXException("unreported schema error");
    }
  }
}

@@ -387,24 +387,246 @@
 ernBuilder;%0A
+import com.thaiopensource.relaxng.pattern.Pattern;%0Aimport com.thaiopensource.relaxng.pattern.NameClass;%0Aimport com.thaiopensource.relaxng.pattern.CommentListImpl;%0Aimport com.thaiopensource.relaxng.pattern.AnnotationsImpl;%0A
 import com.t
@@ -650,32 +650,32 @@
 olver.Resolver;%0A
-
 import com.thaio
@@ -811,32 +811,74 @@
 anErrorHandler;%0A
+import com.thaiopensource.util.VoidValue;%0A
 import org.iso_r
@@ -1130,16 +1130,44 @@
 ception;
+%0Aimport org.xml.sax.Locator;
 %0A%0Aimport
@@ -1865,153 +1865,437 @@
 able
- parseable = new SAXParseable(new SAXSource(saxResolver.createXMLReader(), inputSource),%0A                                           saxResolver,%0A
+%3CPattern, NameClass, Locator, VoidValue, CommentListImpl, AnnotationsImpl%3E parseable%0A            = new SAXParseable%3CPattern, NameClass, Locator, VoidValue, CommentListImpl, AnnotationsImpl%3E(new SAXSource(saxResolver.createXMLReader(), inputSource),%0A                                                                                                         saxResolver,%0A                                                              
     

Generify VerifierFactoryImpl.