Details
-
Improvement
-
Status: Resolved
-
Major
-
Resolution: Fixed
-
None
-
None
Description
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:
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(); } } }
(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