[Mapbender-commits] r8600 - trunk/mapbender/http/php

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Wed Apr 10 12:06:14 PDT 2013


Author: armin11
Date: 2013-04-10 12:06:14 -0700 (Wed, 10 Apr 2013)
New Revision: 8600

Modified:
   trunk/mapbender/http/php/mod_dataISOMetadata.php
   trunk/mapbender/http/php/mod_layerISOMetadata.php
   trunk/mapbender/http/php/mod_validateInspire.php
Log:
Some further enhancement for inspire validator - metadate will validate now! Some code cleaning needed.

Modified: trunk/mapbender/http/php/mod_dataISOMetadata.php
===================================================================
--- trunk/mapbender/http/php/mod_dataISOMetadata.php	2013-04-10 14:14:32 UTC (rev 8599)
+++ trunk/mapbender/http/php/mod_dataISOMetadata.php	2013-04-10 19:06:14 UTC (rev 8600)
@@ -1334,7 +1334,7 @@
 
 	//rs identifier - why?
 	//<gmd:measureIdentification>
-	$measureIdentification=$iso19139->createElement("gmd:measureIdentification");
+/*	$measureIdentification=$iso19139->createElement("gmd:measureIdentification");
 
 	$identifier=$iso19139->createElement("gmd:identifier");
 	$rs_identifier=$iso19139->createElement("gmd:RS_Identifier");
@@ -1355,9 +1355,71 @@
 	$codeSpace->appendChild($codeSpace_cs);
 	$rs_identifier->appendChild($codeSpace);
 	$measureIdentification->appendChild($rs_identifier);
+*/
 
 
+	$gmd_result=$iso19139->createElement("gmd:result");
+	$DQ_ConformanceResult=$iso19139->createElement("gmd:DQ_ConformanceResult");
+        $DQ_ConformanceResult->setAttribute("xsi:type","gmd:DQ_ConformanceResult_Type");
+	$gmd_specification=$iso19139->createElement("gmd:specification");
+	$CI_Citation=$iso19139->createElement("gmd:CI_Citation");
+	$gmd_title=$iso19139->createElement("gmd:title");
+	$gmd_title_cs=$iso19139->createElement("gco:CharacterString");
+	$gmd_titleText=$iso19139->createTextNode("VERORDNUNG (EG) Nr. 1089/2010 DER KOMMISSION vom 23. November 2010 zur Durchführung der Richtlinie 2007/2/EG des Europäischen Parlaments und des Rates hinsichtlich der Interoperabilität von Geodatensätzen und -diensten"); //TODO put in the inspire test suites from mb database!
+	$gmd_date=$iso19139->createElement("gmd:date");
+	$CI_Date=$iso19139->createElement("gmd:CI_Date");
+	$gmd_date_2=$iso19139->createElement("gmd:date");
+	$gco_Date=$iso19139->createElement("gco:Date");
+	$gco_DateText=$iso19139->createTextNode("2010-12-08"); //TODO put in the info from database
+	
+	$gmd_dateType=$iso19139->createElement("gmd:dateType");
+	$CI_DateTypeCode=$iso19139->createElement("gmd:CI_DateTypeCode");
+	$CI_DateTypeCode->setAttribute("codeList","http://standards.iso.org/ittf/PubliclyAvailableStandards/ISO_19139_Schemas/resources/Codelist/ML_gmxCodelists.xml#CI_DateTypeCode");
+	$CI_DateTypeCode->setAttribute("codeListValue","publication");
+	$CI_DateTypeCodeText=$iso19139->createTextNode("publication");
+	
+	$gmd_explanation=$iso19139->createElement("gmd:explanation");
+	$gmd_explanation_cs=$iso19139->createElement("gco:CharacterString");
+	$gmd_explanationText=$iso19139->createTextNode("No explanation available");
+		
+	$gmd_pass=$iso19139->createElement("gmd:pass");
+	$gco_Boolean=$iso19139->createElement("gco:Boolean");
+	$gco_BooleanText=$iso19139->createTextNode("false"); //TODO maybe set here a string cause it can be unevaluated!! See Implementing Rules
+	//generate XML objects
+	$gco_Date->appendChild($gco_DateText);
+	$gmd_date->appendChild($gco_Date);
+	
+	$CI_DateTypeCode->appendChild($CI_DateTypeCodeText);
+	$gmd_dateType->appendChild($CI_DateTypeCode);
+	$CI_Date->appendChild($gmd_date);
+	$CI_Date->appendChild($gmd_dateType);
+	$gmd_date_2->appendChild($CI_Date);
+	$gmd_title_cs->appendChild($gmd_titleText);
+	$gmd_title->appendChild($gmd_title_cs);
+	$CI_Citation->appendChild($gmd_title);
+	$CI_Citation->appendChild($gmd_date_2);
+	$gmd_specification->appendChild($CI_Citation);
+	$gmd_explanation_cs->appendChild($gmd_explanationText);
+	$gmd_explanation->appendChild($gmd_explanation_cs);
+	$gco_Boolean->appendChild($gco_BooleanText);
+	$gmd_pass->appendChild($gco_Boolean);
+	$DQ_ConformanceResult->appendChild($gmd_specification);
+	$DQ_ConformanceResult->appendChild($gmd_explanation);
+	$DQ_ConformanceResult->appendChild($gmd_pass);
 
+//$DQ_DomainConsistency->appendChild($measureIdentification);
+
+	$gmd_result->appendChild($DQ_ConformanceResult);
+	$DQ_DomainConsistency->appendChild($gmd_result);
+
+	$gmd_report->appendChild($DQ_DomainConsistency);
+	$DQ_DataQuality->appendChild($gmd_report);
+
+	//next report
+	//gmd:report in dataQualityInfo
+	$gmd_report=$iso19139->createElement("gmd:report");
+	$DQ_DomainConsistency=$iso19139->createElement("gmd:DQ_DomainConsistency");
+        $DQ_DomainConsistency->setAttribute("xsi:type","gmd:DQ_DomainConsistency_Type");
 	$gmd_result=$iso19139->createElement("gmd:result");
 	$DQ_ConformanceResult=$iso19139->createElement("gmd:DQ_ConformanceResult");
         $DQ_ConformanceResult->setAttribute("xsi:type","gmd:DQ_ConformanceResult_Type");
@@ -1365,7 +1427,7 @@
 	$CI_Citation=$iso19139->createElement("gmd:CI_Citation");
 	$gmd_title=$iso19139->createElement("gmd:title");
 	$gmd_title_cs=$iso19139->createElement("gco:CharacterString");
-	$gmd_titleText=$iso19139->createTextNode("INSPIRE Metadata Regulation"); //TODO put in the inspire test suites from mb database!
+	$gmd_titleText=$iso19139->createTextNode("Verordnung (EG) Nr. 1205/2008 der Kommission vom 3. Dezember 2008 zur Durchführung der Richtlinie 2007/2/EG des Europäischen Parlaments und des Rates hinsichtlich Metadaten"); //TODO put in the inspire test suites from mb database!
 	$gmd_date=$iso19139->createElement("gmd:date");
 	$CI_Date=$iso19139->createElement("gmd:CI_Date");
 	$gmd_date_2=$iso19139->createElement("gmd:date");
@@ -1407,12 +1469,22 @@
 	$DQ_ConformanceResult->appendChild($gmd_explanation);
 	$DQ_ConformanceResult->appendChild($gmd_pass);
 
-$DQ_DomainConsistency->appendChild($measureIdentification);
+//$DQ_DomainConsistency->appendChild($measureIdentification);
 
 	$gmd_result->appendChild($DQ_ConformanceResult);
 	$DQ_DomainConsistency->appendChild($gmd_result);
+
 	$gmd_report->appendChild($DQ_DomainConsistency);
 	$DQ_DataQuality->appendChild($gmd_report);
+
+
+
+
+
+
+
+
+
 	$DQ_DataQuality->appendChild($lineage);
 	$gmd_dataQualityInfo->appendChild($DQ_DataQuality);
 	//$MD_ScopeCode->setAttribute("codeListValue", "service");

Modified: trunk/mapbender/http/php/mod_layerISOMetadata.php
===================================================================
--- trunk/mapbender/http/php/mod_layerISOMetadata.php	2013-04-10 14:14:32 UTC (rev 8599)
+++ trunk/mapbender/http/php/mod_layerISOMetadata.php	2013-04-10 19:06:14 UTC (rev 8600)
@@ -56,6 +56,8 @@
 	//Initialize XML document
 	$iso19139Doc = new DOMDocument('1.0');
 	$iso19139Doc->encoding = 'UTF-8';
+	$iso19139Doc->preserveWhiteSpace = false;
+	$iso19139Doc->formatOutput = true;
 } else {
 	//echo 'outputFormat: <b>'.$_REQUEST['OUTPUTFORMAT'].'</b> is not set or valid.<br/>'; 
 	echo 'Parameter <b>outputFormat</b> is not set or valid (iso19139).<br/>'; 

Modified: trunk/mapbender/http/php/mod_validateInspire.php
===================================================================
--- trunk/mapbender/http/php/mod_validateInspire.php	2013-04-10 14:14:32 UTC (rev 8599)
+++ trunk/mapbender/http/php/mod_validateInspire.php	2013-04-10 19:06:14 UTC (rev 8600)
@@ -64,6 +64,112 @@
 	$context = stream_context_create($context_options);
 	$response = @file_get_contents($validatorUrl, FILE_TEXT, $context);
 	header("Content-type: text/html; charset=UTF-8");
-	echo $response;
+	$repl = str_replace('/schemas/altova/inspireResource.css', 'http://inspire-geoportal.ec.europa.eu/schemas/altova/inspireResource.css', trim($response));
+	echo $repl;
 }
+
+
+
+
+
+function validateInspireXml($xml){
+	//$validatorUrl = 'http://localhost/mapbender_trunk/geoportal/log_requests.php';
+	//$validatorUrl = 'http://inspire-geoportal.ec.europa.eu/GeoportalProxyWebServices/resources/INSPIREResourceTester';
+	if (defined("INSPIRE_VALIDATOR_URL") && INSPIRE_VALIDATOR_URL != '') {
+		$validatorUrl = INSPIRE_VALIDATOR_URL;
+	} else {
+		echo "No validation service defined! Please check your mapbender.conf";
+		die();
+	}
+	$eol = "\r\n";
+	$data = '';
+	$mime_boundary=md5(time());
+	$data .= '--' . $mime_boundary . $eol;
+	$data .= 'Content-Disposition: form-data; name="resourceRepresentation"' .$eol.$eol;
+	//example
+	//$data .= "http://map1.naturschutz.rlp.de/service_lanis/mod_wms/wms_getmap.php?mapfile=naturschutzgebiet&REQUEST=GetCapabilities&VERSION=1.1.1&SERVICE=WMS";
+	$data .= $xml;
+	$data .= $eol;
+	$data .= '--' . $mime_boundary . $eol;
+	$data .= $eol; // finish with two eol's!!
+	$header = "";
+	$header .= 'Accept: application/xml'.$eol;
+	$header .= 'Content-Type: multipart/form-data; boundary='.$mime_boundary.$eol;
+	$header .= 'Content-Length: '.strlen($data).$eol;
+	//$data = http_build_query($data);
+	//check proxy connections
+	if (defined("CONNECTION_PROXY") &&  CONNECTION_PROXY != "") {
+		$context_options = array (
+        			'http' => array (
+					'proxy' => "tcp://".CONNECTION_PROXY.":".CONNECTION_PORT,
+            				'method' => 'POST',
+            				'header' => $header,
+            				'content' => $data
+            				)
+        			);
+	} else {
+		$context_options = array (
+        			'http' => array (
+            				'method' => 'POST',
+            				'header' => $header,
+            				'content' => $data
+            				)
+        			);
+	}
+	$context = stream_context_create($context_options);
+	$response = @file_get_contents($validatorUrl, FILE_TEXT, $context);
+
+        //Simple XML seems a bit too picky so we massage the response a bit
+        $repl = str_replace('<?xml version="1.0" encoding="UTF-8" standalone="yes"?>', '', trim($response));
+        $repl = str_replace("\n", '', $repl); // remove new lines
+        $repl = str_replace("\r", '', $repl); // remove carriage returns
+        $repl = trim($repl);
+
+        $xml = simplexml_load_string($repl);
+
+        $resource = $xml->getName();
+
+        $namespaces = $xml->getNameSpaces(true);
+        //$key_inspire_geoportal_namespace = array_search('http://inspire.ec.europa.eu/schemas/geoportal/1.0', $namespaces);
+        //$namespaces[$key_inspire_geoportal_namespace];
+
+        $ns_inspire_geoportal = "http://inspire.ec.europa.eu/schemas/geoportal/1.0";
+        $ns_inspire_common = "http://inspire.ec.europa.eu/schemas/common/1.0";
+
+        foreach ($xml->children($ns_inspire_geoportal) as $child) {
+            $nodeName = $child->getName();
+            if ($nodeName == "ResourceReportResource") {
+                //There were issues 
+                print("Issues were found");
+                foreach ($child->children($ns_inspire_geoportal) as $errorNode) {
+                    $errorNodeName = $errorNode->getName();
+                    if ($errorNodeName == "InspireValidationErrors") {
+                        foreach ($errorNode->children($ns_inspire_geoportal) as $validationErrorNode) {
+                            $validationErrorNodeName = $validationErrorNode->getName();
+                            if ($validationErrorNodeName == "ValidationError") {
+                                foreach ($validationErrorNode->children($ns_inspire_geoportal) as $geoportalErrorNode) {
+                                    $geoportalErrorNodeName = $geoportalErrorNode->getName();
+                                    if ($geoportalErrorNodeName == "GeoportalExceptionMessage") {
+                                        foreach ($geoportalErrorNode->children($ns_inspire_geoportal) as $geoportalMessageNode) {
+                                            $geoportalMessageNodeName = $geoportalMessageNode->getName();
+                                            if ($geoportalMessageNodeName == "Message") {
+                                                $message = (string) $geoportalMessageNode;
+                                                print($message);
+                                                print("<BR>");
+                                            }
+                                        }
+                                    }
+                                }
+                                //
+                            }
+                        }
+                    }
+                }
+                break;
+            } else {
+                print("The resource has no validation issues and has been recognized as a: " . $nodeName);
+                break;
+            }
+        }
+}
 ?>



More information about the Mapbender_commits mailing list