فهرست منبع

fixed redeclare xmlns namespace

Piotr Labudda 8 سال پیش
والد
کامیت
3b9967ab03
1فایلهای تغییر یافته به همراه8 افزوده شده و 4 حذف شده
  1. 8 4
      SE/se-lib/Api/WfsDataServer.php

+ 8 - 4
SE/se-lib/Api/WfsDataServer.php

@@ -174,7 +174,7 @@ class Api_WfsDataServer extends Api_WfsServerBase {
 		$rootWfsNs = 'p5';
 		$rootWfsNsUri = "{$baseNsUri}";
 		$wfsNs = $args['typePrefix'];
-		$wfsNsUri = "{$baseNsUri}/" . ('p5_' === substr($args['typePrefix'], 0, 3) ? substr($args['typePrefix'], 3) : $args['typePrefix']);
+		$wfsNsUri = "{$baseNsUri}/" . str_replace('__x3A__', '/', ('p5_' === substr($args['typePrefix'], 0, 3) ? substr($args['typePrefix'], 3) : $args['typePrefix']));
 		$featureTypeUri = $this->getBaseUri() . "?SERVICE=WFS&VERSION=1.0.0&TYPENAME={$args['xsd:type']}&REQUEST=DescribeFeatureType";
 
 		// get BBox from geom_field (only one geom fld is allowed)
@@ -282,10 +282,14 @@ class Api_WfsDataServer extends Api_WfsServerBase {
 		$xmlWriter->writeAttribute('xmlns:gml', 'http://www.opengis.net/gml');
 		$xmlWriter->writeAttribute('xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance');
 		$xmlWriter->writeAttribute('xmlns:xlink', 'http://www.w3.org/1999/xlink');
-		$xmlWriter->writeAttribute("xmlns:{$wfsNs}", $wfsNsUri); // TODO: BUG $wfsNsUri
-		if (!$simple) $xmlWriter->writeAttribute("xmlns:{$rootWfsNs}", $rootWfsNsUri);
+		$xlmns = [];
+		$xlmns[ $wfsNs ] = $wfsNsUri;
+		if (!$simple) $xlmns[ $rootWfsNs ] = $rootWfsNsUri;
 		foreach ($schemaCache as $childSchema) {
-			$xmlWriter->writeAttribute("xmlns:{$childSchema['nsPrefix']}", "{$rootWfsNsUri}/" . str_replace('__x3A__', '/', $childSchema['nsPrefix']));
+			$xlmns[ $childSchema['nsPrefix'] ] = "{$rootWfsNsUri}/" . str_replace('__x3A__', '/', $childSchema['nsPrefix']);
+		}
+		foreach ($xlmns as $prefixXmlns => $urlXmlns) {
+			$xmlWriter->writeAttribute("xmlns:{$prefixXmlns}", $urlXmlns);
 		}
 		$xmlWriter->writeAttribute('xsi:schemaLocation', "{$wfsNsUri} {$featureTypeUri}"); // TODO: BUG $wfsNsUri
 		$xmlWriter->writeAttribute('numberMatched', 'unknown'); // TODO: return total items if simple query (without prefix, small total number, maxFeatures set, etc.)