// Path: src/main/java/com/siemens/ct/exi/main/api/sax/EXIResult.java
// public class EXIResult extends SAXResult {
// 
// 	protected SAXEncoder handler;
// 
// 	public EXIResult() throws IOException, EXIException {
// 		// use default exi-factory
// 		this(DefaultEXIFactory.newInstance());
// 	}
// 
// 	public EXIResult(EXIFactory exiFactory) throws EXIException {
// 		// DefaultHandler2 handler = exiFactory.createEXIWriter(os);
// 		handler = new SAXFactory(exiFactory).createEXIWriter();
// 		// set internal states
// 		setHandler(handler);
// 		setLexicalHandler(handler);
// 	}
// 
// 	public void setOutputStream(OutputStream os) throws EXIException,
// 			IOException {
// 		handler.setOutputStream(os);
// 	}
// 
// }


import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.util.Arrays;
import javax.xml.namespace.QName;
import junit.framework.TestCase;
import org.xml.sax.InputSource;
import org.xml.sax.XMLReader;
import org.xml.sax.helpers.XMLReaderFactory;
import com.siemens.ct.exi.core.CodingMode;
import com.siemens.ct.exi.core.EXIBodyDecoder;
import com.siemens.ct.exi.core.EXIBodyEncoder;
import com.siemens.ct.exi.core.EXIFactory;
import com.siemens.ct.exi.core.EXIStreamDecoder;
import com.siemens.ct.exi.core.EXIStreamEncoder;
import com.siemens.ct.exi.core.EncodingOptions;
import com.siemens.ct.exi.core.FidelityOptions;
import com.siemens.ct.exi.core.container.NamespaceDeclaration;
import com.siemens.ct.exi.core.context.QNameContext;
import com.siemens.ct.exi.core.grammars.Grammars;
import com.siemens.ct.exi.core.grammars.event.EventType;
import com.siemens.ct.exi.core.helpers.DefaultEXIFactory;
import com.siemens.ct.exi.core.values.IntegerValue;
import com.siemens.ct.exi.core.values.StringValue;
import com.siemens.ct.exi.core.values.Value;
import com.siemens.ct.exi.core.values.ValueType;
import com.siemens.ct.exi.grammars.GrammarFactory;
import com.siemens.ct.exi.main.api.sax.EXIResult;

		enc2.encodeEndDocument();
		enc2.flush();

		/*
		 * Check equality of streams
		 */
		assertTrue(os1.size() == os2.size());
		assertTrue(Arrays.equals(os1.toByteArray(), os2.toByteArray()));
	}

	// type-aware roundtrip of notebook example
	public void testNotebook() throws Exception {
		String xsd = "./data/W3C/PrimerNotebook/notebook.xsd";
		String xml = "./data/W3C/PrimerNotebook/notebook.xml";

		GrammarFactory gf = GrammarFactory.newInstance();
		Grammars grammar = gf.createGrammars(xsd);

		EXIFactory factory = DefaultEXIFactory.newInstance();
		factory.setCodingMode(CodingMode.BYTE_PACKED);
		factory.setGrammars(grammar);
		factory.setFidelityOptions(FidelityOptions.createStrict());

		/*
		 * Encode to EXI
		 */
		EXIBodyEncoder enc1 = factory.createEXIBodyEncoder();
		ByteArrayOutputStream os1 = new ByteArrayOutputStream();
		enc1.setOutputStream(os1);
		XMLReader xmlReader = XMLReaderFactory.createXMLReader();

// Path: src/main/java/com/siemens/ct/exi/main/api/sax/EXIResult.java
// public class EXIResult extends SAXResult {
// 
// 	protected SAXEncoder handler;
// 
// 	public EXIResult() throws IOException, EXIException {
// 		// use default exi-factory
// 		this(DefaultEXIFactory.newInstance());
// 	}
// 
// 	public EXIResult(EXIFactory exiFactory) throws EXIException {
// 		// DefaultHandler2 handler = exiFactory.createEXIWriter(os);
// 		handler = new SAXFactory(exiFactory).createEXIWriter();
// 		// set internal states
// 		setHandler(handler);
// 		setLexicalHandler(handler);
// 	}
// 
// 	public void setOutputStream(OutputStream os) throws EXIException,
// 			IOException {
// 		handler.setOutputStream(os);
// 	}
// 
// }


// Path: src/test/java/com/siemens/ct/exi/main/core/RoundtripTestCase.java
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.util.Arrays;
import javax.xml.namespace.QName;
import junit.framework.TestCase;
import org.xml.sax.InputSource;
import org.xml.sax.XMLReader;
import org.xml.sax.helpers.XMLReaderFactory;
import com.siemens.ct.exi.core.CodingMode;
import com.siemens.ct.exi.core.EXIBodyDecoder;
import com.siemens.ct.exi.core.EXIBodyEncoder;
import com.siemens.ct.exi.core.EXIFactory;
import com.siemens.ct.exi.core.EXIStreamDecoder;
import com.siemens.ct.exi.core.EXIStreamEncoder;
import com.siemens.ct.exi.core.EncodingOptions;
import com.siemens.ct.exi.core.FidelityOptions;
import com.siemens.ct.exi.core.container.NamespaceDeclaration;
import com.siemens.ct.exi.core.context.QNameContext;
import com.siemens.ct.exi.core.grammars.Grammars;
import com.siemens.ct.exi.core.grammars.event.EventType;
import com.siemens.ct.exi.core.helpers.DefaultEXIFactory;
import com.siemens.ct.exi.core.values.IntegerValue;
import com.siemens.ct.exi.core.values.StringValue;
import com.siemens.ct.exi.core.values.Value;
import com.siemens.ct.exi.core.values.ValueType;
import com.siemens.ct.exi.grammars.GrammarFactory;
import com.siemens.ct.exi.main.api.sax.EXIResult;

		enc2.encodeEndDocument();
		enc2.flush();

		/*
		 * Check equality of streams
		 */
		assertTrue(os1.size() == os2.size());
		assertTrue(Arrays.equals(os1.toByteArray(), os2.toByteArray()));
	}

	// type-aware roundtrip of notebook example
	public void testNotebook() throws Exception {
		String xsd = "./data/W3C/PrimerNotebook/notebook.xsd";
		String xml = "./data/W3C/PrimerNotebook/notebook.xml";

		GrammarFactory gf = GrammarFactory.newInstance();
		Grammars grammar = gf.createGrammars(xsd);

		EXIFactory factory = DefaultEXIFactory.newInstance();
		factory.setCodingMode(CodingMode.BYTE_PACKED);
		factory.setGrammars(grammar);
		factory.setFidelityOptions(FidelityOptions.createStrict());

		/*
		 * Encode to EXI
		 */
		EXIBodyEncoder enc1 = factory.createEXIBodyEncoder();
		ByteArrayOutputStream os1 = new ByteArrayOutputStream();
		enc1.setOutputStream(os1);
		XMLReader xmlReader = XMLReaderFactory.createXMLReader();

		EXIResult exiResult = new EXIResult(factory);
