public function processExport($pa_data, $pa_options = array()) { $pb_single_record = isset($pa_options['singleRecord']) && $pa_options['singleRecord']; $o_record = new File_MARC_Record(); foreach ($pa_data as $va_item) { $vs_element = $va_item['element']; if (stripos($vs_element, "/") !== false) { // data field $va_split = explode("/", $vs_element); $vs_tag = $va_split[0]; $vs_ind1 = substr($va_split[1], 0, 1); $vs_ind2 = substr($va_split[1], 1, 1); $va_subfields = array(); // process sub-fields if (is_array($va_item['children'])) { foreach ($va_item['children'] as $va_child) { $va_subfields[] = new File_MARC_Subfield($va_child['element'], $va_child['text']); } } $o_field = new File_MARC_Data_field($vs_tag, $va_subfields, $vs_ind1, $vs_ind2); } else { // simple control field $o_field = new File_MARC_Control_Field($vs_element, $va_item['text']); } $o_record->appendField($o_field); } if (isset($pa_options['settings']['MARC_outputFormat'])) { switch ($pa_options['settings']['MARC_outputFormat']) { case 'raw': return $o_record->toRaw(); case 'xml': $vs_string = $o_record->toXML(); $vo_dom = new DOMDocument('1.0', 'utf-8'); $vo_dom->preserveWhiteSpace = false; $vo_dom->loadXML($vs_string); $vo_dom->formatOutput = true; // when dealing with a record set export, we don't want <?xml tags in front so // that we can simply dump each record in a file and have valid XML as result return $pb_single_record ? $vo_dom->saveXML() : $vo_dom->saveXML($vo_dom->firstChild); case 'readable': default: return $o_record->__toString(); } } else { return $o_record->__toString(); } }