[Mapbender-commits] r10325 - trunk/mapbender/tools

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Mon Nov 11 08:21:40 PST 2019


Author: armin11
Date: 2019-11-11 08:21:39 -0800 (Mon, 11 Nov 2019)
New Revision: 10325

Modified:
   trunk/mapbender/tools/mod_qualifyPersistedMetadataXml.php
Log:
Fix some more for validation against inspire

Modified: trunk/mapbender/tools/mod_qualifyPersistedMetadataXml.php
===================================================================
--- trunk/mapbender/tools/mod_qualifyPersistedMetadataXml.php	2019-11-11 15:23:39 UTC (rev 10324)
+++ trunk/mapbender/tools/mod_qualifyPersistedMetadataXml.php	2019-11-11 16:21:39 UTC (rev 10325)
@@ -21,8 +21,14 @@
 $metadataClass = new Iso19139();
 $injectRegistryUuid = false;
 
-$metadataDir = str_replace("../../", "../", METADATA_DIR);
+$debug = false;
 
+if ($debug == true) {
+    $metadataDir = str_replace("../../", "../", METADATA_DIR)."/test/";
+} else {
+    $metadataDir = str_replace("../../", "../", METADATA_DIR);
+}
+
 if (defined("MAPBENDER_REGISTRY_UUID") && MAPBENDER_REGISTRY_UUID != "") {
     $uuid = new Uuid(MAPBENDER_REGISTRY_UUID);
     $injectRegistryUuid = $uuid->isValid();
@@ -68,13 +74,18 @@
 		    $keywordsArray[$newKeywordsIndex]->thesaurusPubDate = "2019-10-30";
 		}    
                 //logMessages("count keywordsArray: ".count($keywordsArray)." - count metadataObject->keywords: ".count($metadataObject->keywords));
-		if (count($keywordsArray) > 0 && count($metadataObject->keywords) > 0) {
+		if ($debug == true) {
 		    $metadataXml = addKeywords($metadataXml, $keywordsArray);
-                    logMessages("Keywords will be injected!");
+                    logMessages("Keywords will be injected without test before - debug mode!");
 		} else {
-		    //TODO inject keyword after some other element!
-		    logMessages("No keywords will be injected - file unaltered!");
-		}
+		    if (count($keywordsArray) > 0 && count($metadataObject->keywords) > 0) {
+		        $metadataXml = addKeywords($metadataXml, $keywordsArray);
+                        logMessages("Keywords will be injected!");
+		    } else {
+		        //TODO inject keyword after some other element!
+		        logMessages("No keywords will be injected - file unaltered!");
+		    }
+                }
 		unset($keywordsArray);
 		//debug
 		//header("Content-type: text/xml");
@@ -87,7 +98,7 @@
             $writeHandle = fopen($metadataDir."/".$file, "w+");
 	    fwrite($writeHandle, $metadataXml);
 	    fclose($writeHandle);
-	    logMessages("number of altered file: ".$numberOfFile);
+	    logMessages("Number of altered file: ".($numberOfFile + 1));
 	    $numberOfFile++;
 	    $timeToBuild = microtime(true) - $startTime;
             logMessages("time to alter xml: ".$timeToBuild);
@@ -131,8 +142,28 @@
 		$xpath->registerNamespace("gco", "http://www.isotc211.org/2005/gco");
 		$xpath->registerNamespace("gmd", "http://www.isotc211.org/2005/gmd");
 		$xpath->registerNamespace("gts", "http://www.isotc211.org/2005/gts");
+                $xpath->registerNamespace("xsi", "http://www.w3c.org/2001/XMLSchema-instance");
 		//$xpath->registerNamespace("srv", "http://www.isotc211.org/2005/srv");
 		$xpath->registerNamespace("xlink", "http://www.w3.org/1999/xlink");
+
+//Qualify schemaLocation ***********************************************************************************************************************************************
+//extract attribute schemaLocation - alter it if it has only one uri entry for gmd!
+$MD_MetadataNodeList = $xpath->query("//gmd:MD_Metadata[@xsi:schemaLocation = 'http://www.isotc211.org/2005/gmd']");
+if ($MD_MetadataNodeList->item(0) != null) {
+    $MD_MetadataNodeList->item(0)->setAttribute('xsi:schemaLocation', 'http://www.isotc211.org/2005/gmd http://schemas.opengis.net/iso/19139/20060504/gmd/gmd.xsd');
+    logMessages("schemaLocation attribute extended!!!!");
+} else {
+    logMessages("schemaLocation attribute is not http://www.isotc211.org/2005/gmd. Nothing will be done!");
+}
+
+//Qualify schemaLocation end *******************************************************************************************************************************************
+//check for empty keyword
+//check for right date formats
+//check for empty use constraints
+//check for empty responsible party elements
+//check for wrong format description - name, version, specification
+//check ... - maybe include it into class_iso19139 - this will be easier!
+
 		//inspire specific keywords
 		//https://webgate.ec.europa.eu/fpfis/wikis/display/InspireMIG/Spatial+scope+code+list
 		//problem: gmx namespace does not exists !!!!! - have to be declared before!!!!!!



More information about the Mapbender_commits mailing list