code: public static void flatToXml(File flatFile, File xmlFile, NaaccrOptions options, List<NaaccrDictionary> userDictionaries, NaaccrObserver observer) throws NaaccrIOException {
          if (flatFile == null)
              throw new NaaccrIOException("Source flat file is required");
          if (!flatFile.exists())
              throw new NaaccrIOException("Source flat file must exist");
          if (!xmlFile.getParentFile().exists())
              throw new NaaccrIOException("Target folder must exist");
  
          // create the reader and writer and let them do all the work!
          try (PatientFlatReader reader = new PatientFlatReader(createReader(flatFile), options, userDictionaries)) {
              try (PatientXmlWriter writer = new PatientXmlWriter(createWriter(xmlFile), reader.getRootData(), options, userDictionaries)) {
                  Patient patient = reader.readPatient();
                  while (patient != null && !Thread.currentThread().isInterrupted()) {
                      if (observer != null)
                          observer.patientRead(patient);
                      writer.writePatient(patient);
                      if (observer != null)
                          observer.patientWritten(patient);
                      patient = reader.readPatient();
                  }
              }
          }
      }
docs: Translates a flat data file into an XML data file.
  @param flatFile source flat data file, must exists
  @param xmlFile target XML data file, parent file must exists
  @param options optional validating options
  @param userDictionaries optional user-defined dictionaries (will be merged with the base dictionary)
  @param observer an optional observer, useful to keep track of the progress
  @throws NaaccrIOException if there is problem reading/writing the file