Richard Eckart de Castilho created UIMA-3219:
------------------------------------------------

             Summary: Simpler XMI writing than XWriter
                 Key: UIMA-3219
                 URL: https://issues.apache.org/jira/browse/UIMA-3219
             Project: UIMA
          Issue Type: Improvement
          Components: uimaFIT
            Reporter: Steven Bethard
            Assignee: Richard Eckart de Castilho
             Fix For: 2.0.0uimaFIT


The whole FileNamer thing in XWriter is more complexity than most users need. 
You have to declare a new FileNamer class every time you create an XWriter. But 
that FileNamer class, even though it takes a JCas just like an annotator would, 
isn't actually an annotator, it's a totally different API.

We should instead leverage our users' existing understanding of the annotator 
API. If they're going to have to write a new class every time, we should let 
them write an annotator class like they're already used to. We should provide a 
simple static method that makes it easy to write such a class, something like:

{noformat}
public class XUtil {
        public static void writeXMI(JCas jCas, File outputFile) throws 
IOException, SAXException {
                FileOutputStream outputStream = new 
FileOutputStream(outputFile);
                try {
                        ContentHandler handler = new 
XMLSerializer(outputStream).getContentHandler();
                        XmiCasSerializer serializer = new 
XmiCasSerializer(jCas.getTypeSystem());
                        serializer.serialize(jCas.getCas(), handler);
                }
                finally {
                        outputStream.close();
                }
        }
}
{noformat}

(The new XUtil class could also grow methods for writing XCAS, and for reading 
XMI and XCAS.)

More discussion here: https://code.google.com/p/uimafit/issues/detail?id=121

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to