* @author Gabriele Droege, DNA Bank Network
* @version 2.0
* @package Input
* @copyright Copyright © 2011 DNA Bank Network http://www.dnabank-network.org
The contents of this file are subject to the Mozilla Public License Version 1.1
* @filesource
* @license http://www.mozilla.org/MPL/ MPL
*/
$Units = $dom->getElementsByTagName('Unit');
foreach ($Units as $Unit) {
$UnitID = $Unit->getElementsByTagName('UnitID');
$SourceInstitutionCode = $Unit->getElementsByTagName('SourceInstitutionID');
$SourceName = $Unit->getElementsByTagName('SourceID');
// echo "Unit ID: " . $UnitID->item(0)->nodeValue . "
";
// echo "Source Institution: " . $SourceInstitutionCode->item(0)->nodeValue . "
";
// echo "Source Collection: " . $SourceName->item(0)->nodeValue . "
";
$sqlUnitID = addslashes(utf8_decode($UnitID->item(0)->nodeValue));
$sqlSourceInstitutionCode = addslashes(utf8_decode($SourceInstitutionCode->item(0)->nodeValue));
$sqlSourceName = addslashes(utf8_decode($SourceName->item(0)->nodeValue));
/*----------------------------GATHERING--------------------------------------------------------- */
$Gatherings = $Unit->getElementsByTagName('Gathering');
foreach ($Gatherings as $Gathering) {
$CollectionDate = $Gathering->getElementsByTagName('DateTime');
$GatheringAgents = $Gathering->getElementsByTagName('Agents');
$Locality = $Gathering->getElementsByTagName('LocalityText');
$Country = $Gathering->getElementsByTagName('Country');
$NamedArea = $Gathering->getElementsByTagName('NamedArea'); //if (empty($Country))
$AreaName = $Gathering->getElementsByTagName('AreaName');
$NearNamedPlaces = $Gathering->getElementsByTagName('NearNamedPlaces'); //if (empty($Country))
$Altitude = $Gathering->getElementsByTagName('Altitude');
$Longitude = $Gathering->getElementsByTagName('LongitudeDecimal');
$Latitude = $Gathering->getElementsByTagName('LatitudeDecimal');
$SiteCoordinates = $Gathering->getElementsByTagName('SiteCoordinatesSets'); //if (empty($Longitude & Latitude))
foreach ($Altitude as $AltitudeDetail) {
$AltitudeLowerValue = $AltitudeDetail->getElementsByTagName('LowerValue');
$AltitudeUpperValue = $AltitudeDetail->getElementsByTagName('UpperValue');
if(!empty($AltitudeLowerValue))
{$sqlAltitude = $AltitudeLowerValue->item(0)->nodeValue;}
if(!empty($AltitudeUpperValue))
{ $sqlAltitude .= $AltitudeUpperValue->item(0)->nodeValue;}
}
foreach ($CollectionDate as $DateTime) {
$CollectionDateText = $DateTime->getElementsByTagName('DateText');
$GatheringISODateTimeBegin = $DateTime->getElementsByTagName('ISODateTimeBegin');
$GatheringDayNumberBegin = $DateTime->getElementsByTagName('DayNumberBegin');
$GatheringTimeOfDayBegin = $DateTime->getElementsByTagName('ISOTimeOfDayBegin');
$GatheringISODateTimeEnd = $DateTime->getElementsByTagName('ISODateTimeEnd');
$GatheringDayNumberEnd = $DateTime->getElementsByTagName('DayNumberEnd');
$GatheringTimeOfDayEnd = $DateTime->getElementsByTagName('TimeOfDayEnd');
if(empty($CollectionDateText)) {
// echo "Date2: " . $CollectionDate->item(0)->nodeValue . "
"; //if (empty($CollectionDate))
$sqlCollectionDate = addslashes($CollectionDate->item(0)->nodeValue); }
else {
// echo "Date: " . $CollectionDateText->item(0)->nodeValue . "
";
$sqlCollectionDate = addslashes($CollectionDateText->item(0)->nodeValue); }
if($GatheringISODateTimeBegin) {
$sqlCollectionDate .= " " . $GatheringISODateTimeBegin->item(0)->nodeValue; }
if($GatheringDayNumberBegin) {
$sqlCollectionDate .= " " . $GatheringDayNumberBegin->item(0)->nodeValue; }
if($GatheringTimeOfDayBegin) {
$sqlCollectionDate .= " " . $GatheringTimeOfDayBegin->item(0)->nodeValue; }
if($GatheringISODateTimeEnd) {
$sqlCollectionDate .= " " . $GatheringISODateTimeEnd->item(0)->nodeValue; }
if($GatheringDayNumberEnd) {
$sqlCollectionDate .= " " . $GatheringDayNumberEnd->item(0)->nodeValue; }
if($GatheringTimeOfDayEnd) {
$sqlCollectionDate .= " " . $GatheringTimeOfDayEnd->item(0)->nodeValue; }
}
foreach ($GatheringAgents as $Collectors) {
$PersonName = $Collectors->getElementsByTagName('GatheringAgent');
$AgentText = $Collectors->getElementsByTagName('GatheringAgentsText'); //if (empty($Collectors)
if(empty($PersonName->item(0)->nodeValue)) {
// echo "Person: " . $PersonName->item(0)->nodeValue . "
";
$sqlPersonName = addslashes(utf8_decode($AgentText->item(0)->nodeValue));
}
else {
$sqlPersonName = addslashes(utf8_decode($PersonName->item(0)->nodeValue)); }
}
// echo "Locality: " . $Locality->item(0)->nodeValue . "
";
$sqlLocality = addslashes(utf8_decode($Locality->item(0)->nodeValue));
foreach ($Country as $Countries) {
$CountryName = $Countries->getElementsByTagName('Name');
$ISO2 = $Countries->getElementsByTagName('ISO3166Code');
if(empty($CountryName)) {
// echo "Country2: " . $Country->item(0)->nodeValue . "
";
$sqlCountryName = addslashes($Country->item(0)->nodeValue); }
else {
// echo "Country: " . $CountryName->item(0)->nodeValue . "
";
$sqlCountryName = addslashes($CountryName->item(0)->nodeValue); }
// echo "ISO2: " . $ISO2->item(0)->nodeValue . "
";
$sqlISO2 = addslashes($ISO2->item(0)->nodeValue); }
if(empty($NamedArea)) {
// echo "NearNamedPlaces: " . $NearNamedPlaces->item(0)->nodeValue . "
";
$sqlGatheringOther = addslashes($NearNamedPlaces->item(0)->nodeValue);
}
$sqlNamedAreas = addslashes($AreaName->item(0)->nodeValue);
if($sqlNamedAreas = 'Africa' or $sqlNamedAreas = 'Asia' or $sqlNamedAreas = 'Australia' or $sqlNamedAreas = 'Australia and Oceania' or $sqlNamedAreas = 'Europe' or $sqlNamedAreas = 'Middle America' or $sqlNamedAreas = 'South America' or $sqlNamedAreas = 'Middle America' or $sqlNamedAreas = 'Middle and South America' or $sqlNamedAreas = 'North America' or $sqlNamedAreas = ' Atlantic Ocean' or $sqlNamedAreas = 'Arctic Ocean' or $sqlNamedAreas = 'Indian Ocean' or $sqlNamedAreas = 'Pacific Ocean' or $sqlNamedAreas = 'Southern Ocean' or $sqlNamedAreas = 'Landlocked Sea')
{ $sqlContinentOrOcean = addslashes($AreaName->item(0)->nodeValue); }
else {
// echo "NamedAreas: " . $NamedAreas->item(0)->nodeValue . "
";
$sqlGatheringOther = addslashes($NamedArea->item(0)->nodeValue);
}
// echo "Longitude: " . $Longitude->item(0)->nodeValue . "
";
$sqlLongitude = $Longitude->item(0)->nodeValue;
// echo "Latitude: " . $Latitude->item(0)->nodeValue . "
";
$sqlLatitude = $Latitude->item(0)->nodeValue;
} //foreach $Gatherings
/*----------------------------IDENTIFICATIONS--------------------------------------------------------- */
$Identifications = $Unit->getElementsByTagName('Identification');
foreach ($Identifications as $IndexIdentification => $Identification) { // more than one Identification possible
$TaxaIdentified = $Identification->getElementsByTagName('TaxonIdentified');
$Preferred = $Identification->getElementsByTagName('PreferredFlag');
foreach ($TaxaIdentified as $TaxonIdentified) {
$NameAuthorYearString = $TaxonIdentified->getElementsByTagName('FullScientificNameString'); // Name, Author, Year
$HigherTaxa = $TaxonIdentified->getElementsByTagName('HigherTaxon');
$ScientificNames = $TaxonIdentified->getElementsByTagName('ScientificName');
// echo "Name All: " . $NameAuthorYearString->item(0)->nodeValue . "
";
$sqlNameAuthorYearString[] = addslashes(utf8_decode($NameAuthorYearString->item(0)->nodeValue));
// echo "Preferred: " . $Preferred->item(0)->nodeValue . "
";
$sqlPreferredIdentificationFlag[] = $Preferred->item(0)->nodeValue;
foreach ($HigherTaxa as $index => $HigherTaxon1) { // more than one HigherTaxon per Identification possible
$HigherTaxon = $HigherTaxon1->getElementsByTagName('HigherTaxonName');
$TaxonRank = $HigherTaxon1->getElementsByTagName('HigherTaxonRank');
// echo "Higher Taxon: " .$HigherTaxon->item(0)->nodeValue." (".$TaxonRank->item(0)->nodeValue.")
";
$sqlHigherTaxon[] = $HigherTaxon->item(0)->nodeValue;
$sqlHigherTaxonRank[] = $TaxonRank->item(0)->nodeValue;
} //foreach $HugherTaxa
foreach ($ScientificNames as $ScientificName) {
// $ScientificNamesAtomized = $ScientificName->getElementsByTagName('NameAtomised');
// foreach ($ScientificNamesAtomized as $ScientificNameAtomized) {
$Bacteria = $ScientificName->getElementsByTagName('Bacterial');
$Botany = $ScientificName->getElementsByTagName('Botanical');
$Zoology = $ScientificName->getElementsByTagName('Zoological');
$Virology = $ScientificName->getElementsByTagName('Viral');
if($Bacteria) {
foreach ($Bacteria as $Bacterical) {
$GenusBac = $Bacterical->getElementsByTagName('GenusOrMonomial');
$SubgenusBac = $Bacterical->getElementsByTagName('Subgenus');
$SpeciesEpithetBac = $Bacterical->getElementsByTagName('SpeciesEpithet');
$SubspeciesEpithetBac = $Bacterical->getElementsByTagName('SubspeciesEpithet');
// echo "Genus: " . $GenusBac->item(0)->nodeValue . "
";
$sqlGenus[] = $GenusBac->item(0)->nodeValue;
// echo "Subgenus: " . $SubgenusBac->item(0)->nodeValue . "
";
$sqlSubgenus[] = $SubgenusBac->item(0)->nodeValue;
// echo "Spec.Epi: " . $SpeciesEpithetBac->item(0)->nodeValue . "
";
$sqlFirstEpithet[] = $SpeciesEpithetBac->item(0)->nodeValue;
// echo "SspEpi: " . $SubspeciesEpithetBac->item(0)->nodeValue . "
";
$sqlSecondEpithet[] = $SubspeciesEpithetBac->item(0)->nodeValue;
if(empty($sqlGenus) and empty($sqlSubgenus) and empty($sqlFirstEpithet) and empty($sqlSubspecies))
{
// echo "Bacteria_All: " . $Bacteria->item(0)->nodeValue . "
"; //if (empty -> $GenusBac, $SubgenusBac, $SpeciesEpithetBac, $SubspeciesEpithetBac)
$sqlName_All[] = $Bacteria->item(0)->nodeValue; }
} //foreach $Bacteria
} //if($Bacteria)
if($Botany) {
foreach ($Botany as $Botanical) {
$GenusBot = $Botanical->getElementsByTagName('GenusOrMonomial');
$FirstEpithet = $Botanical->getElementsByTagName('FirstEpithet');
$SecondEpithet = $Botanical->getElementsByTagName('InfraspecificEpithet');
$Rank = $Botanical->getElementsByTagName('Rank');
$HybridFlag = $Botanical->getElementsByTagName('HybridFlag');
// echo "Genus: " . $GenusBot->item(0)->nodeValue . "
";
$sqlGenus[] = $GenusBot->item(0)->nodeValue;
// echo "Spec.Epi: " . $FirstEpithet->item(0)->nodeValue . "
";
$sqlFirstEpithet[] = $FirstEpithet->item(0)->nodeValue;
// echo "Rank: " . $Rank->item(0)->nodeValue . "
";
$sqlRank[] = $Rank->item(0)->nodeValue;
// echo "Sec.Epi: " . $SecondEpithet->item(0)->nodeValue . "
";
$sqlSecondEpithet[] = $SecondEpithet->item(0)->nodeValue;
// echo "Hybrid: " . $HybridFlag->item(0)->nodeValue . "
";
$sqlHybridFlag[] = $HybridFlag->item(0)->nodeValue;
if(empty($sqlGenus) and empty($sqlFirstEpithet) and empty($sqlRank) and empty($sqlSecondEpithet))
{
// echo "Botany_All: " . $Botany->item(0)->nodeValue . "
"; //if (empty -> $GenusBot, $FirstEpithet, $SecondEpithet, $Rank, $HybridFlag)
$sqlName_All[] = $Botany->item(0)->nodeValue; }
} //foreach $Botany
} //if($Botany)
if($Zoology) {
foreach ($Zoology as $Zoological => $Zoo) {
$GenusZoo = $Zoo->getElementsByTagName('GenusOrMonomial');
$SubgenusZoo = $Zoo->getElementsByTagName('Subgenus');
$SpeciesEpithetZoo = $Zoo->getElementsByTagName('SpeciesEpithet');
$SubspeciesEpithetZoo = $Zoo->getElementsByTagName('SubspeciesEpithet');
// echo "Genus: " .$GenusZoo->item(0)->nodeValue."
";
$sqlGenus[] = $GenusZoo->item(0)->nodeValue;
// echo "Subgenus: " . $SubgenusZoo->item(0)->nodeValue . "
";
$sqlSubgenus[] = $SubgenusZoo->item(0)->nodeValue;
// echo "Spec.Epi: " . $SpeciesEpithetZoo->item(0)->nodeValue . "
";
$sqlFirstEpithet[] = $SpeciesEpithetZoo->item(0)->nodeValue;
// echo "SspEpi: " . $SubspeciesEpithetZoo->item(0)->nodeValue . "
";
$sqlSecondEpithet[] = $SubspeciesEpithetZoo->item(0)->nodeValue;
if($sqlSecondEpithet) {
$sqlRank = "ssp."; }
if(empty($sqlGenus) and empty($sqlSubgenus) and empty($sqlFirstEpithet) and empty($sqlSecondEpithet))
{
// echo "Zoology_All: " . $Zoo->nodeValue . "
"; //if (empty -> $GenusZ, $SubgenusZ, $SpeciesEpithetZ, $SubspeciesEpithetZ)
$sqlName_All[] = $Zoology->item(0)->nodeValue; }
} //foreach $Zoology
} //if($Zoology)
if($Virology)
{
foreach ($Virology as $Viral) {
$GenusV = $Viral->getElementsByTagName('GenusOrMonomial');
// echo "Genus: " . $GenusV->item(0)->nodeValue . "
";
$sqlGenus[] = $GenusV->item(0)->nodeValue;
if(empty($sqlGenus))
{
// echo "Virology_All: " . $Virology->item(0)->nodeValue . "
";
$sqlName_All[] = $Virology->item(0)->nodeValue; }
} //foreach $Virology
} //if($Virology)
// } //foreach $ScientificNamesAtomized
} //foreach $ScientificNames
} //foreach $TaxaIdentified
} //foreach $Identifications
/*----------------------------------------MULTI MEDIA OBJECTS -----------------------------*/
$MultiMediaObjects = $Unit->getElementsByTagName('MultiMediaObject');
foreach ($MultiMediaObjects as $IndexMultiMediaObjects => $MultiMediaObject) { // more than one Identification possible
$FileURI = $MultiMediaObject->getElementsByTagName('FileURI');
$ProductURI = $MultiMediaObject->getElementsByTagName('ProductURI');
$sqlFileURI[] = $FileURI->item(0)->nodeValue;
$sqlProductURI[] = $ProductURI->item(0)->nodeValue;
} // foreach $MultiMediaObjects
$TypeDesignations = $Unit->get_elements_by_tagname('NomenclaturalTypeDesignation');
foreach ($TypeDesignations as $TypeDesignation) {
$TypeStatus = $TypeDesignation->get_elements_by_tagname('TypeStatus');
$sqlTypeStatus = $TypeStatus[0]->get_content();
}
} //foreach $Units
?>