function oaidcCollection($result) { global $contentTypeCharset; // these variables are defined in 'ini.inc.php' global $convertExportDataToUTF8; global $citeKeysArray; // '$citeKeysArray' is made globally available from // within this function // Individual records are objects and collections of records are strings $oaidcCollectionDoc = new XMLDocument(); if ($convertExportDataToUTF8 == "yes" and $contentTypeCharset != "UTF-8") { $oaidcCollectionDoc->setEncoding("UTF-8"); } else { $oaidcCollectionDoc->setEncoding($contentTypeCharset); } $oaidcCollection = new XML("dcCollection"); $oaidcCollection->setTagAttribute("xmlns:oai_dc", "http://www.openarchives.org/OAI/2.0/oai_dc/"); $oaidcCollection->setTagAttribute("xmlns:dc", "http://purl.org/dc/elements/1.1/"); $oaidcCollection->setTagAttribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance"); $oaidcCollection->setTagAttribute("xsi:schemaLocation", "http://www.openarchives.org/OAI/2.0/oai_dc/ http://www.openarchives.org/OAI/2.0/oai_dc.xsd"); // ---------------------------------------------------------- // Add OAI_DC XML entries: $exportArray = array(); // array for individually exported records $citeKeysArray = array(); // array of cite keys (used to ensure uniqueness of cite keys among all exported records) // Generate the export for each record and push them onto an array: while ($row = @mysql_fetch_array($result)) { // Export the current record as OAI_DC XML: $record = oaidcRecord($row, "oai_dc"); if (!empty($record)) { // unless the record buffer is empty... array_push($exportArray, $record); } // ...add it to an array of exports } // for each of the OAI_DC XML entries in the result set... foreach ($exportArray as $oaidc) { $oaidcCollection->addXMLasBranch($oaidc); } $oaidcCollectionDoc->setXML($oaidcCollection); $oaidcCollectionString = $oaidcCollectionDoc->getXMLString(); return $oaidcCollectionString; }
function modsCollection($result) { global $contentTypeCharset; // these variables are defined in 'ini.inc.php' global $convertExportDataToUTF8; global $citeKeysArray; // '$citeKeysArray' is made globally available from // within this function // The array '$transtab_refbase_unicode' contains search & replace patterns // for conversion from refbase markup to Unicode entities. global $transtab_refbase_unicode; // defined in 'transtab_refbase_unicode.inc.php' global $fieldSpecificSearchReplaceActionsArray; // Individual records are objects and collections of records are strings $exportArray = array(); // array for individually exported records $citeKeysArray = array(); // array of cite keys (used to ensure uniqueness of // cite keys among all exported records) // Defines field-specific search & replace 'actions' that will be applied to all // those refbase fields that are listed in the corresponding 'fields' element: // (If you don't want to perform any search and replace actions, specify an empty // array, like: '$fieldSpecificSearchReplaceActionsArray = array();'. // Note that the search patterns MUST include the leading & trailing slashes -- // which is done to allow for mode modifiers such as 'imsxU'.) $fieldSpecificSearchReplaceActionsArray = array(); if ($convertExportDataToUTF8 == "yes") { $fieldSpecificSearchReplaceActionsArray[] = array('fields' => array("title", "publication", "abbrev_journal", "address", "keywords", "abstract", "orig_title", "series_title", "abbrev_series_title", "notes"), 'actions' => $transtab_refbase_unicode); } // Generate the export for each record and push them onto an array: while ($row = @mysql_fetch_array($result)) { // Export the current record as MODS XML $record = modsRecord($row); if (!empty($record)) { // unless the record buffer is empty... array_push($exportArray, $record); } // ...add it to an array of exports } $modsCollectionDoc = new XMLDocument(); if ($convertExportDataToUTF8 == "yes" and $contentTypeCharset != "UTF-8") { $modsCollectionDoc->setEncoding("UTF-8"); } else { $modsCollectionDoc->setEncoding($contentTypeCharset); } $modsCollection = new XML("modsCollection"); $modsCollection->setTagAttribute("xmlns", "http://www.loc.gov/mods/v3"); foreach ($exportArray as $mods) { $modsCollection->addXMLasBranch($mods); } $modsCollectionDoc->setXML($modsCollection); $modsCollectionString = $modsCollectionDoc->getXMLString(); return $modsCollectionString; }