Uploaded image for project: 'UIMA'
  1. UIMA
  2. UIMA-3219

Simpler XMI writing than XWriter

    XMLWordPrintableJSON

    Details

    • Type: Improvement
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 2.0.0uimaFIT
    • Component/s: uimaFIT
    • Labels:
      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

        Attachments

          Activity

            People

            • Assignee:
              rec Richard Eckart de Castilho
              Reporter:
              steven.bethard Steven Bethard
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: