get_elements_by_tagname('DataSet'); foreach ($Datasets as $Dataset) { $SourceInstitutionCode = $Dataset->get_elements_by_tagname('SourceInstitutionCode'); $SourceName = $Dataset->get_elements_by_tagname('SourceName'); if(!empty($SourceInstitutionCode)) { $sqlSourceInstitutionCode = addslashes(utf8_decode($SourceInstitutionCode[0]->get_content())); } else { $sqlSourceInstitutionCode = "";} if(!empty($SourceName)) { $sqlSourceName = addslashes(utf8_decode($SourceName[0]->get_content())); } else { $sqlSourceName = "";} $Units = $Dataset->get_elements_by_tagname('Unit'); if(!$Units) { echo "Provider sendet keine Suchergebnisse. Bitte prüfen Sie, ob der Provider nicht verfügbar ist und ob sie die richten UnitIDs abgefragt haben, mitunter sind z.B. für die UnitIDs keine Buchstaben zulässig sind (letzteres erzeugt einen Fehler auf Provider-Seite!)"; } foreach ($Units as $Unit) { $UnitID = $Unit->get_elements_by_tagname('UnitID'); if(!empty($UnitID)) { $sqlUnitID = addslashes($UnitID[0]->get_content()); } else { $sqlUnitID = ""; } echo "Unit ID: " . $UnitID[0]->get_content() . ""; echo "Source Institution: " . $SourceInstitutionCode[0]->get_content() . ""; echo "Source Collection: " . $SourceName[0]->get_content() . ""; $resultTest = "SELECT ID_Cache FROM tablecache WHERE UnitID_Specimen = '$sqlUnitID' AND CollectionCode_Specimen = '$sqlSourceName' AND InstitutionCode_Specimen = '$sqlSourceInstitutionCode' AND ID_Dataset_Specimen = '$formProviderIntern'"; $sqlTest = mysql_query($resultTest); if(mysql_num_rows($sqlTest)) { echo "Specimen already exist in database
"; } if(!mysql_num_rows($sqlTest)) { /*----------------------------GATHERING---------------------------------------------------------*/ $Gatherings = $Unit->get_elements_by_tagname('Gathering'); foreach ($Gatherings as $Gathering) { $GatheringDate = $Gathering->get_elements_by_tagname('DateText'); $GatheringDateAll = $Gathering->get_elements_by_tagname('GatheringDateTime'); //if (empty($GatheringDate)) $GatheringISODateTimeBegin = $Gathering->get_elements_by_tagname('ISODateTimeBegin'); $GatheringDayNumberBegin = $Gathering->get_elements_by_tagname('DayNumberBegin'); $GatheringTimeOfDayBegin = $Gathering->get_elements_by_tagname('ISOTimeOfDayBegin'); $GatheringISODateTimeEnd = $Gathering->get_elements_by_tagname('ISODateTimeEnd'); $GatheringDayNumberEnd = $Gathering->get_elements_by_tagname('DayNumberEnd'); $GatheringTimeOfDayEnd = $Gathering->get_elements_by_tagname('TimeOfDayEnd'); $GatheringAgents = $Gathering->get_elements_by_tagname('GatheringAgent'); $GatheringSites = $Gathering->get_elements_by_tagname('GatheringSite'); if(empty($GatheringDate)) { if(!empty($GatheringDateAll)) { //echo "Date2: " . $GatheringDateAll[0]->get_content() . "
"; //if (empty($GatheringDate)) $sqlGatheringDate = addslashes($GatheringDateAll[0]->get_content()); } } else { if($GatheringDate) { //echo "Date: " . $GatheringDate[0]->get_content() . "
"; $sqlGatheringDate = addslashes($GatheringDate[0]->get_content()); }} if($GatheringISODateTimeBegin) { $sqlGatheringDate .= " " . $GatheringISODateTimeBegin[0]->get_content(); } if($GatheringDayNumberBegin) { $sqlGatheringDate .= " " . $GatheringDayNumberBegin[0]->get_content(); } if($GatheringTimeOfDayBegin) { $sqlGatheringDate .= " " . $GatheringTimeOfDayBegin[0]->get_content(); } if($GatheringISODateTimeEnd) { $sqlGatheringDate .= " " . $GatheringISODateTimeEnd[0]->get_content(); } if($GatheringDayNumberEnd) { $sqlGatheringDate .= " " . $GatheringDayNumberEnd[0]->get_content(); } if($GatheringTimeOfDayEnd) { $sqlGatheringDate .= " " . $GatheringTimeOfDayEnd[0]->get_content(); } foreach ($GatheringAgents as $GatheringAgent) { $PersonName = $GatheringAgent->get_elements_by_tagname('PersonName'); $AgentText = $GatheringAgent->get_elements_by_tagname('AgentText'); //if (empty($GatheringAgent) if(empty($GatheringAgent)) { // echo "Person2: " . $AgentText[0]->get_content() . "
"; $sqlPersonName = addslashes($AgentText[0]->get_content()); } else { if($PersonName) { // echo "Person: " . $PersonName[0]->get_content() . "
"; $sqlPersonName = addslashes($PersonName[0]->get_content()); } }} foreach ($GatheringSites as $GatheringSite) { $LocalityText = $GatheringSite->get_elements_by_tagname('LocalityText'); $ContinentOrOcean = $GatheringSite->get_elements_by_tagname('ContinentOrOcean'); $CountryName = $GatheringSite->get_elements_by_tagname('CountryName'); $Country = $GatheringSite->get_elements_by_tagname('Country'); //if (empty($CountryName)) $ISO2 = $GatheringSite->get_elements_by_tagname('ISO2Letter'); $NamedAreas = $GatheringSite->get_elements_by_tagname('NamedAreas'); //if (empty($Country)) $NearNamedPlaces = $GatheringSite->get_elements_by_tagname('NearNamedPlaces'); //if (empty($Country)) $LongitudeDecimal = $GatheringSite->get_elements_by_tagname('LongitudeDecimal'); $LatitudeDecimal = $GatheringSite->get_elements_by_tagname('LatitudeDecimal'); $SiteCoordinates = $GatheringSite->get_elements_by_tagname('SiteCoordinates'); //if (empty($LongitudeDecimal & LatitudeDecimal)) $Altitude = $GatheringSite->get_elements_by_tagname('Altitude'); if($LocalityText) { // echo "Locality: " . $LocalityText[0]->get_content() . "
"; $sqlLocalityText = addslashes($LocalityText[0]->get_content()); } if($ContinentOrOcean) { // echo "Continent: " . $ContinentOrOcean[0]->get_content() . "
"; $sqlContinentOrOcean = addslashes($ContinentOrOcean[0]->get_content()); } if(empty($CountryName)) { // echo "Country2: " . $Country[0]->get_content() . "
"; $sqlCountryName = addslashes($Country[0]->get_content()); } else { // echo "Country: " . $CountryName[0]->get_content() . "
"; $sqlCountryName = addslashes($CountryName[0]->get_content()); } if(!empty($ISO2)) { // echo "ISO2: " . $ISO2[0]->get_content() . "
"; $sqlISO2 = addslashes($ISO2[0]->get_content()); } if(empty($NamedAreas) and !empty($NearNamedPlaces)) { $sqlGatheringOther = addslashes($NearNamedPlaces[0]->get_content()); } if($NamedAreas) {$sqlNamedAreas = addslashes($NamedAreas[0]->get_content());} 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 = $sqlNamedAreas; } else { // echo "NamedAreas: " . $NamedAreas[0]->get_content() . "
"; $sqlGatheringOther = addslashes($NamedArea[0]->get_content()); } if($LongitudeDecimal) { // echo "Longitude: " . $LongitudeDecimal[0]->get_content() . "
"; $sqlLongitudeDecimal = $LongitudeDecimal[0]->get_content(); } if($LatitudeDecimal) { // echo "Latitude: " . $LatitudeDecimal[0]->get_content() . "
"; $sqlLatitudeDecimal = $LatitudeDecimal[0]->get_content(); } // echo "Coordinates: " . $SiteCoordinates[0]->get_content() . "
"; // echo "Altitude: " . $Altitude[0]->get_content() . "
"; if($Altitude) { $sqlAltitude = addslashes($Altitude[0]->get_content()); } } // foreach $GatheringSites } //foreach $Gatherings $TypeDesignations = $Unit->get_elements_by_tagname('NomenclaturalTypeDesignation'); foreach ($TypeDesignations as $TypeDesignation) { $TypeStatus = $TypeDesignation->get_elements_by_tagname('TypeStatus'); $sqlTypeStatus = $TypeStatus[0]->get_content(); } $result1 = "INSERT INTO tablecache (UnitID_Specimen, CollectionCode_Specimen, InstitutionCode_Specimen, ContinentOrOcean, CountryName, CountryISO2, GatheringAgent, GatheringDate, LocalityText, LongitudeDecimal, LatitudeDecimal, Altitude, Gathering_Other, ID_Dataset_Specimen, , TypeStatus, Created_Who) VALUES ('$sqlUnitID','$sqlSourceName','$sqlSourceInstitutionCode','$sqlContinentOrOcean','$sqlCountryName','$sqlISO2','$sqlPersonName','$sqlGatheringDate','$sqlLocalityText','$sqlLongitudeDecimal','$sqlLatitudeDecimal','$sqlAltitude','$sqlGatheringOther','$formProviderIntern','$sqlTypeStatus','$log')"; $sql1 = mysql_query($result1); $IDTableCache=mysql_insert_id(); #######################################Error 1############################################################### if(!$sql1) { $msg = $result1."\n"; $msg .= "####Error 1####"; trigger_error($msg, E_USER_ERROR); include ("Errorreport.php"); } ############################################################################################################# /*----------------------------IDENTIFICATIONS---------------------------------------------------------*/ $Identifications = $Unit->get_elements_by_tagname('Identifications'); foreach ($Identifications as $IndexIdentification => $Identification) { $IdentificationSingle = $Unit->get_elements_by_tagname('Identification'); foreach ($IdentificationSingle as $Index2Indentification => $Identification2) { // more than one Identification possible // $TaxaIdentified = $Identification->get_elements_by_tagname('TaxonIdentified'); // foreach ($TaxaIdentified as $TaxonIdentified) { $NameAuthorYearString = $Identification2->get_elements_by_tagname('NameAuthorYearString'); // Name, Author, Year $ScientificNames = $Identification2->get_elements_by_tagname('ScientificNameAtomized'); $HigherTaxa = $Identification2->get_elements_by_tagname('HigherTaxon'); if($NameAuthorYearString) { // echo "Name All: " . $NameAuthorYearString[0]->get_content() . "
"; $sqlNameAuthorYearString = addslashes($NameAuthorYearString[0]->get_content()); } if($Identification2) { // echo "Preferred: " . $Identification->getAttribute('PreferredIdentificationFlag') . "
"; $sqlPreferredIdentificationFlag = $Identification2->get_attribute('PreferredIdentificationFlag'); } foreach ($ScientificNames as $ScientificName) { // $ScientificNamesAtomized = $ScientificName->get_elements_by_tagname('NameAtomised'); // foreach ($ScientificNamesAtomized as $ScientificNameAtomized) { $Bacteria = $ScientificName->get_elements_by_tagname('Bacterial'); $Botany = $ScientificName->get_elements_by_tagname('Botanical'); $Zoology = $ScientificName->get_elements_by_tagname('Zoological'); $Virology = $ScientificName->get_elements_by_tagname('Viral'); if($Bacteria) { foreach ($Bacteria as $Bacterical) { $GenusBac = $Bacterical->get_elements_by_tagname('Genus'); $SubgenusBac = $Bacterical->get_elements_by_tagname('Subgenus'); $SpeciesEpithetBac = $Bacterical->get_elements_by_tagname('SpeciesEpithet'); $SubspeciesEpithetBac = $Bacterical->get_elements_by_tagname('SubspeciesEpithet'); if($GenusBac) { // echo "Genus: " . $GenusBac[0]->get_content() . "
"; $sqlGenus = $GenusBac[0]->get_content(); } if($SubgenusBac) { // echo "Subgenus: " . $SubgenusBac[0]->get_content() . "
"; $sqlSubgenus = $SubgenusBac[0]->get_content(); } if($SpeciesEpithetBac) { // echo "Spec.Epi: " . $SpeciesEpithetBac[0]->get_content() . "
"; $sqlFirstEpithet = $SpeciesEpithetBac[0]->get_content(); } if($SubspeciesEpithetBac) { // echo "SspEpi: " . $SubspeciesEpithetBac[0]->get_content() . "
"; $sqlSecondEpithet = $SubspeciesEpithetBac[0]->get_content(); } if(empty($sqlGenus) and empty($sqlSubgenus) and empty($sqlFirstEpithet) and empty($sqlSubspecies)) { // echo "Bacteria_All: " . $Bacteria[0]->get_content() . "
"; //if (empty -> $GenusBac, $SubgenusBac, $SpeciesEpithetBac, $SubspeciesEpithetBac) $sqlName_All = $Bacteria[0]->get_content(); } } //foreach $Bacteria } //if($Bacteria) if($Botany) { foreach ($Botany as $Botanical) { $GenusBot = $Botanical->get_elements_by_tagname('Genus'); $FirstEpithet = $Botanical->get_elements_by_tagname('FirstEpithet'); $SecondEpithet = $Botanical->get_elements_by_tagname('SecondEpithet'); $Rank = $Botanical->get_elements_by_tagname('Rank'); $HybridFlag = $Botanical->get_elements_by_tagname('HybridFlag'); if($GenusBot) { // echo "Genus: " . $GenusBot[0]->get_content() . "
"; $sqlGenus = $GenusBot[0]->get_content(); } if($FirstEpithet) { // echo "Spec.Epi: " . $FirstEpithet[0]->get_content() . "
"; $sqlFirstEpithet = $FirstEpithet[0]->get_content(); } if($Rank) { // echo "Rank: " . $Rank[0]->get_content() . "
"; $sqlRank = $Rank[0]->get_content(); } if($SecondEpithet) { // echo "Sec.Epi: " . $SecondEpithet[0]->get_content() . "
"; $sqlSecondEpithet = $SecondEpithet[0]->get_content(); } if($HybridFlag) { // echo "Hybrid: " . $HybridFlag[0]->get_content() . "
"; $sqlHybridFlag = $HybridFlag[0]->get_content(); } if(empty($sqlGenus) and empty($sqlFirstEpithet) and empty($sqlRank) and empty($sqlSecondEpithet)) { // echo "Botany_All: " . $Botany[0]->get_content() . "
"; //if (empty -> $GenusBot, $FirstEpithet, $SecondEpithet, $Rank, $HybridFlag) $sqlName_All = $Botany[0]->get_content(); } } //foreach $Botany } //if($Botany) if($Zoology) { foreach ($Zoology as $Zoological => $Zoo) { $GenusZoo = $Zoo->get_elements_by_tagname('Genus'); $SubgenusZoo = $Zoo->get_elements_by_tagname('Subgenus'); $SpeciesEpithetZoo = $Zoo->get_elements_by_tagname('SpeciesEpithet'); $SubspeciesEpithetZoo = $Zoo->get_elements_by_tagname('SubspeciesEpithet'); if($GenusZoo) { // echo "Genus: " .$GenusZoo[0]->get_content()."
"; $sqlGenus = $GenusZoo[0]->get_content(); } if($SubgenusZoo) { // echo "Subgenus: " . $SubgenusZoo[0]->get_content() . "
"; $sqlSubgenus = $SubgenusZoo[0]->get_content(); } if($SpeciesEpithetZoo) { // echo "Spec.Epi: " . $SpeciesEpithetZoo[0]->get_content() . "
"; $sqlFirstEpithet = $SpeciesEpithetZoo[0]->get_content(); } if($SubspeciesEpithetZoo) { // echo "SspEpi: " . $SubspeciesEpithetZoo[0]->get_content() . "
"; $sqlSecondEpithet = $SubspeciesEpithetZoo[0]->get_content(); } if($sqlSecondEpithet) { $sqlRank = "ssp."; } if(empty($sqlGenus) and empty($sqlSubgenus) and empty($sqlFirstEpithet) and empty($sqlSecondEpithet)) { // echo "Zoology_All: " . $Zoo . "
"; //if (empty -> $GenusZ, $SubgenusZ, $SpeciesEpithetZ, $SubspeciesEpithetZ) $sqlName_All = $Zoology[0]->get_content(); } } //foreach $Zoology } //if($Zoology) if($Virology) { foreach ($Virology as $Viral) { $GenusV = $Viral->get_elements_by_tagname('Genus'); if($GenusV) { // echo "Genus: " . $GenusV[0]->get_content() . "
"; $sqlGenus = $GenusV[0]->get_content(); } if(empty($sqlGenus)) { // echo "Virology_All: " . $Virology[0]->get_content() . "
"; $sqlName_All = $Virology[0]->get_content(); } } //foreach $Virology } //if($Virology) // } //foreach $ScientificNamesAtomized $result2 = "INSERT INTO tablecachetaxonidentified (ID_Cache, Genus, Subgenus, FirstEpithet, SecondEpithet, Rank, HybridFlag, NameAuthorYear, Other, PreferredFlag, Created_Who) VALUES ('$IDTableCache','$sqlGenus','$sqlSubgenus','$sqlFirstEpithet','$sqlSecondEpithet','$sqlRank','$sqlHybridFlag','$sqlNameAuthorYearString','$sqlName_All','$sqlPreferredIdentificationFlag','$log')"; $sql2 = mysql_query($result2); $IDTableCacheTaxonIdentified=mysql_insert_id(); #######################################Error 2############################################################### if(!$sql2) { $msg = $result2."\n"; $msg .= "####Error 2####"; trigger_error($msg, E_USER_ERROR); include ("Errorreport.php"); } ############################################################################################################# } //foreach $ScientificName foreach ($HigherTaxa as $index => $HigherTaxon) { // more than one HigherTaxon per Identification possible if(!empty($HigherTaxon)) { // echo "Higher Taxon: " .$HigherTaxon->nodeValue." (".$HigherTaxon->getAttribute('TaxonRank').")
"; $sqlHigherTaxon = $HigherTaxon->get_content(); } if(!empty($HigherTaxonRank)) { $sqlHigherTaxonRank = $HigherTaxon->get_attribute('TaxonRank'); } $result3 = "INSERT INTO tablecachehighertaxa (ID_CacheTaxonIdentified, HigherTaxon, TaxonRank, Created_Who) VALUES ('$IDTableCacheTaxonIdentified','$sqlHigherTaxon','$sqlHigherTaxonRank','$log')"; $sql3 = mysql_query($result3); #######################################Error 3############################################################### if(!$sql3) { $msg = $result3."\n"; $msg .= "####Error 3####"; trigger_error($msg, E_USER_ERROR); include ("Errorreport.php"); } ############################################################################################################# } //foreach $HugherTaxa } //foreach $IdentificationSingle } //foreach $Identifications /*----------------------------------------MULTI MEDIA OBJECTS -----------------------------*/ $MultiMediaObjects = $Unit->get_elements_by_tagname('UnitDigitalImage'); foreach ($MultiMediaObjects as $IndexMultiMediaObjects => $MultiMediaObject) { // more than one Identification possible $FileURI = $MultiMediaObject->get_elements_by_tagname('ImageURI'); if(!empty($FileURI)) { $sqlFileURI = $FileURI[0]->get_content(); } $result4 = "INSERT INTO tablecacheimages (ID_Cache, Images, Created_Who) VALUES ('$IDTableCache','$sqlFileURI','$log')"; $sql4 = mysql_query($result4); #######################################Error 4############################################################### if(!$sql4) { $msg = $result4."\n"; $msg .= "####Error 4####"; trigger_error($msg, E_USER_ERROR); include ("Errorreport.php"); $error = "true"; } ############################################################################################################# } // foreach $MultiMediaObjects if($sql1 and $sql2) { echo "Data have been saved!
"; } } // if(!mysql_num_rows($sqlTest)) } //foreach $Units } //foreach $Datasets ?>