/// <summary> Read the metadata file and enrich the existing bibliographic package </summary> /// <param name="Data_File">Generic (unspecified) metadata file</param> /// <param name="thisPackage">Bibliographic package to enrich</param> public void Read(string Data_File, SobekCM_Item thisPackage) { // Many readers output an error message string errorMessage; // Does this filename have '.info.xml' in it? if (Data_File.ToUpper().IndexOf(".INFO.XML") > 0) { INFO_File_ReaderWriter readInfo = new INFO_File_ReaderWriter(); readInfo.Read_Metadata(Data_File, thisPackage, null, out errorMessage); return; } // Does this file have '.mets' in it? if ((Data_File.ToUpper().IndexOf(".METS") > 0) || (Data_File.ToUpper().IndexOf(".PMETS") > 0)) { METS_File_ReaderWriter readInfo = new METS_File_ReaderWriter(); readInfo.Read_Metadata(Data_File, thisPackage, null, out errorMessage); return; } // If it made it here, it may be METS or MXF if (Data_File.ToUpper().IndexOf(".XML") > 0) { // Read first couple lines StreamReader reader = new StreamReader(Data_File); string thisLine = reader.ReadLine(); while (thisLine != null) { // Is this MXF? if (thisLine.ToUpper().Trim() == "<MXF>") { // Close the current connection reader.Close(); // Read in the MXF file MXF_File_ReaderWriter readInfo = new MXF_File_ReaderWriter(); readInfo.Read_Metadata(Data_File, thisPackage, null, out errorMessage); return; } // Is this a METS declaration? if (thisLine.ToUpper().IndexOf("<METS:") > 0) { // Close the current connection reader.Close(); // Read in the METS file METS_File_ReaderWriter readInfo = new METS_File_ReaderWriter(); readInfo.Read_Metadata(Data_File, thisPackage, null, out errorMessage); return; } // Read the next line thisLine = reader.ReadLine(); } } }
/// <summary> Read from an existing MXF file and returns a new object</summary> /// <param name="fileName">Name of the MXF file</param> /// <returns>Built SobekCM_Item object</returns> public static SobekCM_Item Read_MXF(string fileName) { SobekCM_Item returnVal = new SobekCM_Item(); string errorMessage; MXF_File_ReaderWriter reader = new MXF_File_ReaderWriter(); reader.Read_Metadata(fileName, returnVal, null, out errorMessage); return returnVal; }
/// <summary> Read from an existing MXF file into the current object</summary> /// <param name="fileName">Name of the MXF file</param> public bool Read_From_MXF(string fileName) { string errorMessage; MXF_File_ReaderWriter reader = new MXF_File_ReaderWriter(); return reader.Read_Metadata(fileName, this, null, out errorMessage); }