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 ( ) ; } } } }
Translates a flat data file into an XML data file .