@Override public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException { String elemName = getElementName(uri, localName, qName); if (readingBody) { onAnnotationStart(elemName, attributes); } else if (E_DOC.equals(elemName)) { onDocStart(); } else if (E_META.equals(elemName)) { onMetaStart(attributes); } else if (E_BODY.equals(elemName)) { onBodyStart(); } else if (E_ALIASES.equals(elemName)) { onAliasesStart(); } else if (E_ALIAS.equals(elemName)) { onAliasStart(attributes); } else if (E_FEATURE_ALIAS.equals(elemName)) { onFeatureAliasStart(attributes); } else { throw new SAXParseException(String.format("Unknown element '%s'", elemName), locator); } }
@Override public void endElement(String uri, String localName, String qName) throws SAXException { String elemName = getElementName(uri, localName, qName); if (readingBody) { if (E_BODY.equals(elemName)) { onBodyEnd(); } else { onAnnotationEnd(elemName); } } else if (E_DOC.equals(elemName)) { onDocEnd(); } else if (E_ALIASES.equals(elemName)) { onAliasesEnd(); } else if (E_ALIAS.equals(elemName)) { onAliasEnd(); } else if(E_FEATURE_ALIAS.equals(elemName)) { onFeatureAliasEnd(); } else if (E_META.equals(elemName)) { onMetaEnd(); } else { throw new SAXParseException(String.format("End of unknown element '%s'", elemName), locator); } }
AXMLContentHandler contentHandler = new AXMLContentHandler(cas.getTypeSystem()); xmlReader.setContentHandler(contentHandler); InputSource inputSource = new InputSource(in); xmlReader.parse(inputSource); cas.setDocumentText(contentHandler.getText()); for (Annotation _anno : contentHandler.getAnnotations()) { String typeName = _anno.getType(); Type type = cas.getTypeSystem().getType(typeName);