Source for file Save_ABCD1.2.php
Documentation is available at Save_ABCD1.2.php
* extracting data from original specimen data provider, following ABCD1.2 format, using DOM
* @author Gabriele Droege, DNA Bank Network <contact@dnabank-network.org>
* @copyright Copyright © 2011 DNA Bank Network http://www.dnabank-network.org<br>The contents of this file are subject to the Mozilla Public License Version 1.1
* @license http://www.mozilla.org/MPL/ MPL
$Datasets =
$dom->getElementsByTagName('DataSet');
foreach ($Datasets as $Dataset) {
$SourceInstitutionCode =
$Dataset->getElementsByTagName('SourceInstitutionCode');
$SourceName =
$Dataset->getElementsByTagName('SourceName');
// echo "Source Institution: " . $SourceInstitutionCode->item(0)->nodeValue . "<br>";
// echo "Source Collection: " . $SourceName->item(0)->nodeValue . "<br>";
$sqlSourceInstitutionCode =
addslashes($SourceInstitutionCode->item(0)->nodeValue);
$sqlSourceName =
addslashes($SourceName->item(0)->nodeValue);
$Units =
$Dataset->getElementsByTagName('Unit');
foreach ($Units as $Unit) {
$UnitID =
$Unit->getElementsByTagName('UnitID');
$GatheringNo =
$Unit->getElementsByTagName('CollectorsFieldNumber');
// echo "Unit ID: " . $UnitID->item(0)->nodeValue . "<br>";
$sqlUnitID =
addslashes($UnitID->item(0)->nodeValue);
$sqlGatheringNo =
addslashes($GatheringNo->item(0)->nodeValue);
/*----------------------------GATHERING---------------------------------------------------------*/
$Gatherings =
$Unit->getElementsByTagName('Gathering');
foreach ($Gatherings as $Gathering) {
$CollectionDate =
$Gathering->getElementsByTagName('DateText');
$GatheringDateText =
$Gathering->getElementsByTagName('GatheringDateTime'); //if (empty($CollectionDate))
$GatheringISODateTimeBegin =
$Gathering->getElementsByTagName('ISODateTimeBegin');
$GatheringDayNumberBegin =
$Gathering->getElementsByTagName('DayNumberBegin');
$GatheringTimeOfDayBegin =
$Gathering->getElementsByTagName('ISOTimeOfDayBegin');
$GatheringISODateTimeEnd =
$Gathering->getElementsByTagName('ISODateTimeEnd');
$GatheringDayNumberEnd =
$Gathering->getElementsByTagName('DayNumberEnd');
$GatheringTimeOfDayEnd =
$Gathering->getElementsByTagName('TimeOfDayEnd');
$GatheringAgents =
$Gathering->getElementsByTagName('GatheringAgent');
$GatheringSites =
$Gathering->getElementsByTagName('GatheringSite');
if($GatheringDateText->item(0)->nodeValue !=
"") {
// echo "Date: " . $GatheringDateText->item(0)->nodeValue . "<br>";
$sqlCollectionDate =
addslashes($GatheringDateText->item(0)->nodeValue); }
else { $sqlCollectionDate =
""; }
if($GatheringISODateTimeBegin->item(0)->nodeValue !=
"") {
$sqlCollectionDateMin =
$GatheringISODateTimeBegin->item(0)->nodeValue; }
if($GatheringDayNumberBegin->item(0)->nodeValue !=
"") {
$sqlCollectionDateMin .=
" " .
$GatheringDayNumberBegin->item(0)->nodeValue; }
if($GatheringTimeOfDayBegin->item(0)->nodeValue !=
"") {
$sqlCollectionDateMin .=
" " .
$GatheringTimeOfDayBegin->item(0)->nodeValue; }
if($GatheringISODateTimeEnd->item(0)->nodeValue !=
"") {
$sqlCollectionDateMax =
" " .
$GatheringISODateTimeEnd->item(0)->nodeValue; }
if($GatheringDayNumberEnd->item(0)->nodeValue !=
"") {
$sqlCollectionDateMax .=
" " .
$GatheringDayNumberEnd->item(0)->nodeValue; }
if($GatheringTimeOfDayEnd->item(0)->nodeValue !=
"") {
$sqlCollectionDateMax .=
" " .
$GatheringTimeOfDayEnd->item(0)->nodeValue; }
foreach ($GatheringAgents as $Collectors) {
$PersonName =
$Collectors->getElementsByTagName('PersonName');
$AgentText =
$Collectors->getElementsByTagName('AgentText'); //if (empty($Collectors)
// echo "Person2: " . $AgentText->item(0)->nodeValue . "<br>";
$sqlPersonName =
addslashes($AgentText->item(0)->nodeValue); }
// echo "Person: " . $PersonName->item(0)->nodeValue . "<br>";
$sqlPersonName =
addslashes($PersonName->item(0)->nodeValue); } }
foreach ($GatheringSites as $GatheringSite) {
$Locality =
$GatheringSite->getElementsByTagName('LocalityText');
$ContinentOrOcean =
$GatheringSite->getElementsByTagName('ContinentOrOcean');
$CountryName =
$GatheringSite->getElementsByTagName('CountryName');
$Country =
$GatheringSite->getElementsByTagName('Country'); //if (empty($CountryName))
$ISO2 =
$GatheringSite->getElementsByTagName('ISO2Letter');
$NamedArea =
$GatheringSite->getElementsByTagName('NamedArea'); //if (empty($Country))
$NearNamedPlaces =
$GatheringSite->getElementsByTagName('NearNamedPlaces'); //if (empty($Country))
$Longitude =
$GatheringSite->getElementsByTagName('LongitudeDecimal');
$Latitude =
$GatheringSite->getElementsByTagName('LatitudeDecimal');
$SiteCoordinates =
$GatheringSite->getElementsByTagName('SiteCoordinates'); //if (empty($Longitude & Latitude))
$Altitude =
$GatheringSite->getElementsByTagName('Altitude');
// echo "Locality: " . $Locality->item(0)->nodeValue . "<br>";
$sqlLocality =
addslashes($Locality->item(0)->nodeValue);
// echo "Continent: " . $ContinentOrOcean->item(0)->nodeValue . "<br>";
$sqlContinentOrOcean =
addslashes($ContinentOrOcean->item(0)->nodeValue);
if(empty($CountryName)) {
// echo "Country2: " . $Country->item(0)->nodeValue . "<br>";
$sqlCountryName =
addslashes($Country->item(0)->nodeValue); }
// echo "Country: " . $CountryName->item(0)->nodeValue . "<br>";
$sqlCountryName =
addslashes($CountryName->item(0)->nodeValue); }
// echo "ISO2: " . $ISO2->item(0)->nodeValue . "<br>";
// echo "NearNamedPlaces: " . $NearNamedPlaces->item(0)->nodeValue . "<br>";
$sqlGatheringOther =
addslashes($NearNamedPlaces->item(0)->nodeValue);
if(!empty($GatheringOther)) {
// echo "NamedAreas: " . $NamedAreas->item(0)->nodeValue . "<br>";
$sqlGatheringOther =
addslashes($NamedAreas->item(0)->nodeValue);
// echo "Longitude: " . $Longitude->item(0)->nodeValue . "<br>";
$sqlLongitude =
$Longitude->item(0)->nodeValue;
// echo "Latitude: " . $Latitude->item(0)->nodeValue . "<br>";
$sqlLatitude =
$Latitude->item(0)->nodeValue;
// echo "Coordinates: " . $SiteCoordinates->item(0)->nodeValue . "<br>";
// echo "Altitude: " . $Altitude->item(0)->nodeValue . "<br>";
$sqlAltitude =
addslashes($Altitude->item(0)->nodeValue);
} // foreach $GatheringSites
/*----------------------------IDENTIFICATIONS---------------------------------------------------------*/
$Identifications =
$Unit->getElementsByTagName('Identification');
foreach ($Identifications as $IndexIdentification =>
$Identification) { // more than one Identification possible
// $TaxaIdentified = $Identification->getElementsByTagName('TaxonIdentified');
// foreach ($TaxaIdentified as $TaxonIdentified) {
$NameAuthorYearString =
$Identification->getElementsByTagName('NameAuthorYearString'); // Name, Author, Year
$ScientificNamesAtomized =
$Identification->getElementsByTagName('ScientificNameAtomized');
$HigherTaxa =
$Identification->getElementsByTagname('HigherTaxon');
// echo "Name All: " . $NameAuthorYearString->item(0)->nodeValue . "<br>";
$sqlNameAuthorYearString[] =
addslashes($NameAuthorYearString->item(0)->nodeValue);
// echo "Preferred: " . $Identification->getAttribute('PreferredIdentificationFlag') . "<br>";
$sqlPreferredIdentificationFlag[] =
$Identification->getAttribute('PreferredIdentificationFlag');
foreach ($HigherTaxa as $index =>
$HigherTaxon) { // more than one HigherTaxon per Identification possible
// echo "Higher Taxon: " .$HigherTaxon->nodeValue." (".$HigherTaxon->getAttribute('TaxonRank').")<br>";
$sqlHigherTaxon[] =
$HigherTaxon->nodeValue;
$sqlHigherTaxonRank[] =
$HigherTaxon->getAttribute('TaxonRank');
foreach ($ScientificNamesAtomized as $ScientificNameAtomized) {
$Bacteria =
$ScientificNameAtomized->getElementsByTagName('Bacterial');
$Botany =
$ScientificNameAtomized->getElementsByTagName('Botanical');
$Zoology =
$ScientificNameAtomized->getElementsByTagName('Zoological');
$Virology =
$ScientificNameAtomized->getElementsByTagName('Viral');
foreach ($Bacteria as $Bacterical) {
$GenusBac =
$Bacterical->getElementsByTagName('Genus');
$SubgenusBac =
$Bacterical->getElementsByTagName('Subgenus');
$SpeciesEpithetBac =
$Bacterical->getElementsByTagName('SpeciesEpithet');
$SubspeciesEpithetBac =
$Bacterical->getElementsByTagName('SubspeciesEpithet');
// echo "Genus: " . $GenusBac->item(0)->nodeValue . "<br>";
$sqlGenus[] =
$GenusBac->item(0)->nodeValue;
// echo "Subgenus: " . $SubgenusBac->item(0)->nodeValue . "<br>";
$sqlSubgenus[] =
$SubgenusBac->item(0)->nodeValue;
// echo "Spec.Epi: " . $SpeciesEpithetBac->item(0)->nodeValue . "<br>";
$sqlFirstEpithet[] =
$SpeciesEpithetBac->item(0)->nodeValue;
// echo "SspEpi: " . $SubspeciesEpithetBac->item(0)->nodeValue . "<br>";
$sqlSecondEpithet[] =
$SubspeciesEpithetBac->item(0)->nodeValue;
if(empty($sqlGenus) and empty($sqlSubgenus) and empty($sqlFirstEpithet) and empty($sqlSubspecies))
// echo "Bacteria_All: " . $Bacteria->item(0)->nodeValue . "<br>"; //if (empty -> $GenusBac, $SubgenusBac, $SpeciesEpithetBac, $SubspeciesEpithetBac)
$sqlName_All[] =
$Bacteria->item(0)->nodeValue; }
foreach ($Botany as $Botanical) {
$GenusBot =
$Botanical->getElementsByTagName('Genus');
$FirstEpithet =
$Botanical->getElementsByTagName('FirstEpithet');
$SecondEpithet =
$Botanical->getElementsByTagName('SecondEpithet');
$Rank =
$Botanical->getElementsByTagName('Rank');
$HybridFlag =
$Botanical->getElementsByTagName('HybridFlag');
// echo "Genus: " . $GenusBot->item(0)->nodeValue . "<br>";
$sqlGenus[] =
$GenusBot->item(0)->nodeValue;
// echo "Spec.Epi: " . $FirstEpithet->item(0)->nodeValue . "<br>";
$sqlFirstEpithet[] =
$FirstEpithet->item(0)->nodeValue;
// echo "Rank: " . $Rank->item(0)->nodeValue . "<br>";
$sqlRank[] =
$Rank->item(0)->nodeValue;
// echo "Sec.Epi: " . $SecondEpithet->item(0)->nodeValue . "<br>";
$sqlSecondEpithet[] =
$SecondEpithet->item(0)->nodeValue;
// echo "Hybrid: " . $HybridFlag->item(0)->nodeValue . "<br>";
$sqlHybridFlag[] =
$HybridFlag->item(0)->nodeValue;
if(empty($sqlGenus) and empty($sqlFirstEpithet) and empty($sqlRank) and empty($sqlSecondEpithet))
// echo "Botany_All: " . $Botany->item(0)->nodeValue . "<br>"; //if (empty -> $GenusBot, $FirstEpithet, $SecondEpithet, $Rank, $HybridFlag)
$sqlName_All[] =
$Botany->item(0)->nodeValue; }
foreach ($Zoology as $Zoological =>
$Zoo) {
$GenusZoo =
$Zoo->getElementsByTagName('Genus');
$SubgenusZoo =
$Zoo->getElementsByTagName('Subgenus');
$SpeciesEpithetZoo =
$Zoo->getElementsByTagName('SpeciesEpithet');
$SubspeciesEpithetZoo =
$Zoo->getElementsByTagName('SubspeciesEpithet');
// echo "Genus: " .$GenusZoo->item(0)->nodeValue."<br>";
$sqlGenus[] =
$GenusZoo->item(0)->nodeValue;
// echo "Subgenus: " . $SubgenusZoo->item(0)->nodeValue . "<br>";
$sqlSubgenus[] =
$SubgenusZoo->item(0)->nodeValue;
// echo "Spec.Epi: " . $SpeciesEpithetZoo->item(0)->nodeValue . "<br>";
$sqlFirstEpithet[] =
$SpeciesEpithetZoo->item(0)->nodeValue;
// echo "SspEpi: " . $SubspeciesEpithetZoo->item(0)->nodeValue . "<br>";
$sqlSecondEpithet[] =
$SubspeciesEpithetZoo->item(0)->nodeValue;
if(empty($sqlGenus) and empty($sqlSubgenus) and empty($sqlFirstEpithet) and empty($sqlSecondEpithet))
// echo "Zoology_All: " . $Zoo->nodeValue . "<br>"; //if (empty -> $GenusZ, $SubgenusZ, $SpeciesEpithetZ, $SubspeciesEpithetZ)
$sqlName_All[] =
$Zoology->item(0)->nodeValue; }
foreach ($Virology as $Viral) {
$GenusV =
$Viral->getElementsByTagName('Genus');
// echo "Genus: " . $GenusV->item(0)->nodeValue . "<br>";
$sqlGenus[] =
$GenusV->item(0)->nodeValue;
// echo "Virology_All: " . $Virology->item(0)->nodeValue . "<br>";
$sqlName_All[] =
$Virology->item(0)->nodeValue; }
} //foreach $ScientificNamesAtomized
// } //foreach $TaxaIdentified
} //foreach $Identifications
/*----------------------------------------MULTI MEDIA OBJECTS -----------------------------*/
$MultiMediaObjects =
$Unit->getElementsByTagName('UnitDigitalImage');
foreach ($MultiMediaObjects as $IndexMultiMediaObjects =>
$MultiMediaObject) { // more than one Identification possible
$FileURI =
$MultiMediaObject->getElementsByTagName('ImageURI');
$sqlFileURI[] =
$FileURI->item(0)->nodeValue;
} // foreach $MultiMediaObjects
$TypeDesignations =
$Unit->getElementsByTagName('NomenclaturalTypeDesignation');
foreach ($TypeDesignations as $TypeDesignation) {
$TypeStatus =
$TypeDesignation->getElementsByTagName('TypeStatus');
$sqlTypeStatus =
$TypeStatus->item(0)->nodeValue;
Documentation generated on Tue, 29 Nov 2011 10:45:06 +0100 by phpDocumentor 1.4.3