// get the CAS used above that is in v2.0 format
InputStream serCasStream = new FileInputStream(JUnitExtension.getFile("ExampleCas/cas.xml"));
XCASDeserializer deser = new XCASDeserializer(cas.getTypeSystem());
ContentHandler deserHandler = deser.getXCASHandler(cas);
SAXParserFactory fact = SAXParserFactory.newInstance();
SAXParser parser = fact.newSAXParser();
XMLReader xmlReader = parser.getXMLReader();
xmlReader.setContentHandler(deserHandler);
xmlReader.parse(new InputSource(serCasStream));
serCasStream.close();
// get a v1.x version of the same CAS
serCasStream = new FileInputStream(JUnitExtension.getFile("ExampleCas/v1cas.xml"));
deser = new XCASDeserializer(v1cas.getTypeSystem());
deserHandler = deser.getXCASHandler(v1cas);
fact = SAXParserFactory.newInstance();
parser = fact.newSAXParser();
xmlReader = parser.getXMLReader();
xmlReader.setContentHandler(deserHandler);
xmlReader.parse(new InputSource(serCasStream));
serCasStream.close();
// compare
assertEquals(cas.getAnnotationIndex().size(), v1cas.getAnnotationIndex().size());
// now a v1.x version of a multiple Sofa CAS
v1cas.reset();
serCasStream = new FileInputStream(JUnitExtension.getFile("ExampleCas/v1MultiSofaCas.xml"));
deser = new XCASDeserializer(v1cas.getTypeSystem());
deserHandler = deser.getXCASHandler(v1cas);
fact = SAXParserFactory.newInstance();
parser = fact.newSAXParser();
xmlReader = parser.getXMLReader();
xmlReader.setContentHandler(deserHandler);
xmlReader.parse(new InputSource(serCasStream));
serCasStream.close();
// test it