code: public static void writeXmlFile(NaaccrData data, File xmlFile, NaaccrOptions options, List<NaaccrDictionary> userDictionaries, NaaccrObserver observer) throws NaaccrIOException {
          if (data == null)
              throw new NaaccrIOException("Data is required");
          if (!xmlFile.getParentFile().exists())
              throw new NaaccrIOException("Target folder must exist");
  
          try (PatientXmlWriter writer = new PatientXmlWriter(createWriter(xmlFile), data, options, userDictionaries)) {
              for (Patient patient : data.getPatients()) {
                  writer.writePatient(patient);
                  if (observer != null)
                      observer.patientWritten(patient);
                  if (Thread.currentThread().isInterrupted())
                      break;
              }
          }
      }
docs: Writes the provided data to the requested XML file.
  <br/>
  ATTENTION: THIS METHOD REQUIRES THE ENTIRE DATA OBJECT TO BE IN MEMORY; CONSIDER USING A STREAM INSTEAD.
  @param data a <code>NaaccrData</code> object, cannot be null
  @param xmlFile target XML data file
  @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