code: private void writeXmi(CAS aCas, File name, String modelFileName)
        throws IOException, SAXException {
      FileOutputStream out = null;
  
      try {
        // write XMI
        out = new FileOutputStream(name);
        XmiCasSerializer ser = new XmiCasSerializer(aCas.getTypeSystem());
        XMLSerializer xmlSer = new XMLSerializer(out, false);
        ser.serialize(aCas, xmlSer.getContentHandler());
      } finally {
        if (out != null) {
          out.close();
        }
      }
    }
docs: Serialize a CAS to a file in XMI format
  
  @param aCas
  CAS to serialize
  @param name
  output file
  @throws SAXException
  @throws Exception
  
  @throws ResourceProcessException