// Path: src/main/java/com/siemens/ct/exi/main/helpers/DefaultSchemaIdResolver.java
// public class DefaultSchemaIdResolver implements SchemaIdResolver {
// 
// 	// protected GrammarFactory gf;
// 
// 	public DefaultSchemaIdResolver() {
// 
// 	}
// 
// 	protected GrammarFactory getGrammarFactory() {
// 		return GrammarFactory.newInstance();
// 		// if (gf == null) {
// 		// gf = GrammarFactory.newInstance();
// 		// }
// 		// return gf;
// 	}
// 
// 	public Grammars resolveSchemaId(String schemaId) throws EXIException {
// 		if (schemaId == null) {
// 			return getGrammarFactory().createSchemaLessGrammars();
// 		} else if ("".equals(schemaId)) {
// 			return getGrammarFactory().createXSDTypesOnlyGrammars();
// 		} else {
// 			// interpret schemaId as location
// 			try {
// 				return getGrammarFactory().createGrammars(schemaId);
// 			} catch (Exception e) {
// 				throw new EXIException(this.getClass().getName()
// 						+ " failed to retrieve schemaId == " + schemaId, e);
// 			}
// 		}
// 	}
// 
// }
// 
// Path: src/main/java/com/siemens/ct/exi/main/util/NoEntityResolver.java
// public class NoEntityResolver implements EntityResolver {
// 
// 	public InputSource resolveEntity(String publicId, String systemId) {
// 		// if
// 		// (systemId.equals("http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"))
// 		// {
// 		// return new InputSource("./data/W3C/xhtml/xhtml1-strict.dtd");
// 		// }
// 		// System.out.println( publicId + "\t" + systemId);
// 		return new InputSource(new ByteArrayInputStream(
// 				"<?xml version='1.0' encoding='UTF-8'?>".getBytes()));
// 	}
// }


import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.Reader;
import java.io.StringReader;
import java.util.List;
import org.xml.sax.ContentHandler;
import org.xml.sax.DTDHandler;
import org.xml.sax.EntityResolver;
import org.xml.sax.ErrorHandler;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import org.xml.sax.SAXNotRecognizedException;
import org.xml.sax.SAXNotSupportedException;
import org.xml.sax.XMLReader;
import org.xml.sax.ext.DeclHandler;
import org.xml.sax.ext.LexicalHandler;
import org.xml.sax.helpers.AttributesImpl;
import org.xml.sax.helpers.XMLReaderFactory;
import com.siemens.ct.exi.core.Constants;
import com.siemens.ct.exi.core.EXIBodyDecoder;
import com.siemens.ct.exi.core.EXIFactory;
import com.siemens.ct.exi.core.EXIStreamDecoder;
import com.siemens.ct.exi.core.FidelityOptions;
import com.siemens.ct.exi.core.container.DocType;
import com.siemens.ct.exi.core.container.NamespaceDeclaration;
import com.siemens.ct.exi.core.container.ProcessingInstruction;
import com.siemens.ct.exi.core.context.QNameContext;
import com.siemens.ct.exi.core.exceptions.EXIException;
import com.siemens.ct.exi.core.grammars.event.EventType;
import com.siemens.ct.exi.core.values.ListValue;
import com.siemens.ct.exi.core.values.Value;
import com.siemens.ct.exi.core.values.ValueType;
import com.siemens.ct.exi.main.helpers.DefaultSchemaIdResolver;
import com.siemens.ct.exi.main.util.NoEntityResolver;

		// <!DOCTYPE foo [
		// <!ELEMENT foo (#PCDATA)>
		// ]>

		// e.g., (b) External DTD
		// <!DOCTYPE root_element SYSTEM "DTD_location">
		// <!DOCTYPE root_element PUBLIC "DTD_name" "DTD_location">

		// Combining
		// <!DOCTYPE document SYSTEM "subjects.dtd" [
		// <!ATTLIST assessment assessment_type (exam | assignment | prac)>
		// <!ELEMENT results (#PCDATA)>
		// ]>

		// DeclHandler dh;
		XMLReader xmlReader;

		public DocTypeTextLexicalHandler(DeclHandler dh) throws SAXException {
			// this.dh = dh;

			xmlReader = XMLReaderFactory.createXMLReader();

			// xmlReader.setProperty(
			// "http://xml.org/sax/properties/lexical-handler",
			// lh);

			// DTD
			xmlReader.setFeature(
					"http://xml.org/sax/features/resolve-dtd-uris", false);
			// *skip* resolving entities like DTDs

// Path: src/main/java/com/siemens/ct/exi/main/helpers/DefaultSchemaIdResolver.java
// public class DefaultSchemaIdResolver implements SchemaIdResolver {
// 
// 	// protected GrammarFactory gf;
// 
// 	public DefaultSchemaIdResolver() {
// 
// 	}
// 
// 	protected GrammarFactory getGrammarFactory() {
// 		return GrammarFactory.newInstance();
// 		// if (gf == null) {
// 		// gf = GrammarFactory.newInstance();
// 		// }
// 		// return gf;
// 	}
// 
// 	public Grammars resolveSchemaId(String schemaId) throws EXIException {
// 		if (schemaId == null) {
// 			return getGrammarFactory().createSchemaLessGrammars();
// 		} else if ("".equals(schemaId)) {
// 			return getGrammarFactory().createXSDTypesOnlyGrammars();
// 		} else {
// 			// interpret schemaId as location
// 			try {
// 				return getGrammarFactory().createGrammars(schemaId);
// 			} catch (Exception e) {
// 				throw new EXIException(this.getClass().getName()
// 						+ " failed to retrieve schemaId == " + schemaId, e);
// 			}
// 		}
// 	}
// 
// }
// 
// Path: src/main/java/com/siemens/ct/exi/main/util/NoEntityResolver.java
// public class NoEntityResolver implements EntityResolver {
// 
// 	public InputSource resolveEntity(String publicId, String systemId) {
// 		// if
// 		// (systemId.equals("http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"))
// 		// {
// 		// return new InputSource("./data/W3C/xhtml/xhtml1-strict.dtd");
// 		// }
// 		// System.out.println( publicId + "\t" + systemId);
// 		return new InputSource(new ByteArrayInputStream(
// 				"<?xml version='1.0' encoding='UTF-8'?>".getBytes()));
// 	}
// }


// Path: src/main/java/com/siemens/ct/exi/main/api/sax/SAXDecoder.java
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.Reader;
import java.io.StringReader;
import java.util.List;
import org.xml.sax.ContentHandler;
import org.xml.sax.DTDHandler;
import org.xml.sax.EntityResolver;
import org.xml.sax.ErrorHandler;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import org.xml.sax.SAXNotRecognizedException;
import org.xml.sax.SAXNotSupportedException;
import org.xml.sax.XMLReader;
import org.xml.sax.ext.DeclHandler;
import org.xml.sax.ext.LexicalHandler;
import org.xml.sax.helpers.AttributesImpl;
import org.xml.sax.helpers.XMLReaderFactory;
import com.siemens.ct.exi.core.Constants;
import com.siemens.ct.exi.core.EXIBodyDecoder;
import com.siemens.ct.exi.core.EXIFactory;
import com.siemens.ct.exi.core.EXIStreamDecoder;
import com.siemens.ct.exi.core.FidelityOptions;
import com.siemens.ct.exi.core.container.DocType;
import com.siemens.ct.exi.core.container.NamespaceDeclaration;
import com.siemens.ct.exi.core.container.ProcessingInstruction;
import com.siemens.ct.exi.core.context.QNameContext;
import com.siemens.ct.exi.core.exceptions.EXIException;
import com.siemens.ct.exi.core.grammars.event.EventType;
import com.siemens.ct.exi.core.values.ListValue;
import com.siemens.ct.exi.core.values.Value;
import com.siemens.ct.exi.core.values.ValueType;
import com.siemens.ct.exi.main.helpers.DefaultSchemaIdResolver;
import com.siemens.ct.exi.main.util.NoEntityResolver;

		// <!DOCTYPE foo [
		// <!ELEMENT foo (#PCDATA)>
		// ]>

		// e.g., (b) External DTD
		// <!DOCTYPE root_element SYSTEM "DTD_location">
		// <!DOCTYPE root_element PUBLIC "DTD_name" "DTD_location">

		// Combining
		// <!DOCTYPE document SYSTEM "subjects.dtd" [
		// <!ATTLIST assessment assessment_type (exam | assignment | prac)>
		// <!ELEMENT results (#PCDATA)>
		// ]>

		// DeclHandler dh;
		XMLReader xmlReader;

		public DocTypeTextLexicalHandler(DeclHandler dh) throws SAXException {
			// this.dh = dh;

			xmlReader = XMLReaderFactory.createXMLReader();

			// xmlReader.setProperty(
			// "http://xml.org/sax/properties/lexical-handler",
			// lh);

			// DTD
			xmlReader.setFeature(
					"http://xml.org/sax/features/resolve-dtd-uris", false);
			// *skip* resolving entities like DTDs

			xmlReader.setEntityResolver(new NoEntityResolver());
