[Mapbender-commits] r9287 - trunk/mapbender/http/classes

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Thu Sep 10 07:39:33 PDT 2015


Author: armin11
Date: 2015-09-10 07:39:33 -0700 (Thu, 10 Sep 2015)
New Revision: 9287

Modified:
   trunk/mapbender/http/classes/class_wfs_1_0_factory.php
   trunk/mapbender/http/classes/class_wfs_2_0_factory.php
Log:
Enhancement as done for wfs 1.1.0 - should be extracted to special class later!

Modified: trunk/mapbender/http/classes/class_wfs_1_0_factory.php
===================================================================
--- trunk/mapbender/http/classes/class_wfs_1_0_factory.php	2015-09-10 14:31:16 UTC (rev 9286)
+++ trunk/mapbender/http/classes/class_wfs_1_0_factory.php	2015-09-10 14:39:33 UTC (rev 9287)
@@ -76,43 +76,59 @@
 		foreach ($elementList as $elementNode){
 			$elementName = $elementNode->getAttribute("name");
 			$elementType = $elementNode->getAttribute("type");
+            		//if Type is empty, we assume an anonymousType, else we go looking for the anmed Type
+            		if($elementType == ""){
+                		//Just querying for complexTypes containing a Sequence - good enough for Simple Features
+                		$query = "xs:complexType//xs:element";
+                		$subElementList = $xpath->query($query,$elementNode);
+            		} else {
+                		// The elementType is now bound to a prefix e.g. topp:housType
+                		// if the prefix is in the targetNamespace, changces are good it's defined in this very document
+                		// if the prefix is not in the targetNamespace, it's likely not defined here, and we bail
 
-            // if Type is empty, we assume an anonymousType, else we go looking for the anmed Type
-            if($elementType == ""){
-                // Just querying for complexTypes containing a Sequence - good enough for Simple Features
-                $query = "xs:complexType//xs:element";
-                $subElementList = $xpath->query($query,$elementNode);
+                		list($elementTypeLocalname,$elementTypePrefix) = array_reverse(explode(":",$elementType));
+                		$elementTypeNamespace = $doc->lookupNamespaceURI($elementTypePrefix);
+                		if($elementTypeNamespace !== $targetNamespaceNode->nodeValue){
+                    			$e = new mb_warning("Tried to parse FeatureTypeName $featureTypeName : $elementType is not in the targetNamespace");	
+                    			break;
+                		}
 
-            }else{
-
-                // The elementType is now bound to a prefix e.g. topp:housType
-                // if the prefix is in the targetNamespace, changces are good it's defined in this very document
-                // if the prefiox is not in the targetNamespace, it's likely not defined here, and we bail
-
-                list($elementTypeLocalname,$elementTypePrefix) = array_reverse(explode(":",$elementType));
-                $elementTypeNamespace = $doc->lookupNamespaceURI($elementTypePrefix);
-                if($elementTypeNamespace !== $targetNamespaceNode->nodeValue){
-                    $e = new mb_warning("Tried to parse FeatureTypeName $featureTypeName : $elementType is not in the targetNamespace");	
-                    break;
-                }
-
-                // Just querying for complexTypes containing a Sequence - good enough for Simple Features
-                $query = sprintf("//xs:complexType[@name='%s']//xs:element",$elementTypeLocalname);
-                $subElementList = $xpath->query($query);
-
-            }
-			foreach($subElementList as $subElement){
-                // Since this is a rewrite of the old way, it reproduces it quirks
-                // in this case the namespace of the type was cut off for some reason
+                		// Just querying for complexTypes containing a Sequence - good enough for Simple Features
+                		$query = sprintf("//xs:complexType[@name='%s']//xs:element",$elementTypeLocalname);
+                		$subElementList = $xpath->query($query);
+            		}
+	    		foreach ($subElementList as $subElement) {
+            			// Since this is a rewrite of the old way, it reproduces it quirks
+                		// in this case the namespace of the type was cut off for some reason
 				$name = $subElement->getAttribute('name');
-                $typeParts = explode(":",$subElement->getAttribute('type'));
-                if(count($typeParts) == 1){
-                    $type = $typeParts[0];
-                }else{
-                    $type = $typeParts[1];
-                }
-				$newFeatureType->addElement($name,$type);
-			}
+                		$typeParts = explode(":",$subElement->getAttribute('type'));
+				//$e = new mb_exception("element: ".$name." - type: ".$typeParts[0]);
+				if (empty($typeParts[0])) {
+					$e = new mb_warning("No type attribute found in xs:element - test for integrated simpleType!");
+					//it maybe a simple type
+					/*<xs:element name="kennung" nillable="true" minOccurs="0" maxOccurs="1">
+						<xs:simpleType>
+							<xs:restriction base="string">
+								<xs:maxLength value="40"/>
+							</xs:restriction>
+						</xs:simpleType>
+					</xs:element>*/
+					$query = "xs:simpleType/xs:restriction";
+					$restriction = $xpath->query($query,$subElement);
+					$type = $restriction->item(0)->getAttribute('base');
+					//TODO parse further information from xsd like maxLength: <xs:maxLength value="40"/> - add further column in wfs_element!
+				} else {
+					switch (count($typeParts)) {
+						case 1 :
+							$type = $typeParts[0];
+						break;
+						case 2 :
+							$type = $typeParts[1];
+						break;
+					}
+				}
+	    			$newFeatureType->addElement($name,$type);
+	    		}
 
 		}
 		return $newFeatureType;

Modified: trunk/mapbender/http/classes/class_wfs_2_0_factory.php
===================================================================
--- trunk/mapbender/http/classes/class_wfs_2_0_factory.php	2015-09-10 14:31:16 UTC (rev 9286)
+++ trunk/mapbender/http/classes/class_wfs_2_0_factory.php	2015-09-10 14:39:33 UTC (rev 9287)
@@ -172,43 +172,59 @@
 		foreach ($elementList as $elementNode){
 			$elementName = $elementNode->getAttribute("name");
 			$elementType = $elementNode->getAttribute("type");
+            		//if Type is empty, we assume an anonymousType, else we go looking for the anmed Type
+            		if($elementType == ""){
+                		//Just querying for complexTypes containing a Sequence - good enough for Simple Features
+                		$query = "xs:complexType//xs:element";
+                		$subElementList = $xpath->query($query,$elementNode);
+            		} else {
+                		// The elementType is now bound to a prefix e.g. topp:housType
+                		// if the prefix is in the targetNamespace, changces are good it's defined in this very document
+                		// if the prefix is not in the targetNamespace, it's likely not defined here, and we bail
 
-            // if Type is empty, we assume an anonymousType, else we go looking for the anmed Type
-            if($elementType == ""){
-                // Just querying for complexTypes containing a Sequence - good enough for Simple Features
-                $query = "xs:complexType//xs:element";
-                $subElementList = $xpath->query($query,$elementNode);
+                		list($elementTypeLocalname,$elementTypePrefix) = array_reverse(explode(":",$elementType));
+                		$elementTypeNamespace = $doc->lookupNamespaceURI($elementTypePrefix);
+                		if($elementTypeNamespace !== $targetNamespaceNode->nodeValue){
+                    			$e = new mb_warning("Tried to parse FeatureTypeName $featureTypeName : $elementType is not in the targetNamespace");	
+                    			break;
+                		}
 
-            }else{
-
-                // The elementType is now bound to a prefix e.g. topp:housType
-                // if the prefix is in the targetNamespace, changces are good it's defined in this very document
-                // if the prefiox is not in the targetNamespace, it's likely not defined here, and we bail
-
-                list($elementTypeLocalname,$elementTypePrefix) = array_reverse(explode(":",$elementType));
-                $elementTypeNamespace = $doc->lookupNamespaceURI($elementTypePrefix);
-                if($elementTypeNamespace !== $targetNamespaceNode->nodeValue){
-                    $e = new mb_warning("Tried to parse FeatureTypeName $featureTypeName : $elementType is not in the targetNamespace");	
-                    break;
-                }
-
-                // Just querying for complexTypes containing a Sequence - good enough for Simple Features
-                $query = sprintf("//xs:complexType[@name='%s']//xs:element",$elementTypeLocalname);
-                $subElementList = $xpath->query($query);
-
-            }
-			foreach($subElementList as $subElement){
-                // Since this is a rewrite of the old way, it reproduces it quirks
-                // in this case the namespace of the type was cut off for some reason
+                		// Just querying for complexTypes containing a Sequence - good enough for Simple Features
+                		$query = sprintf("//xs:complexType[@name='%s']//xs:element",$elementTypeLocalname);
+                		$subElementList = $xpath->query($query);
+            		}
+	    		foreach ($subElementList as $subElement) {
+            			// Since this is a rewrite of the old way, it reproduces it quirks
+                		// in this case the namespace of the type was cut off for some reason
 				$name = $subElement->getAttribute('name');
-                $typeParts = explode(":",$subElement->getAttribute('type'));
-                if(count($typeParts) == 1){
-                    $type = $typeParts[0];
-                }else{
-                    $type = $typeParts[1];
-                }
-				$newFeatureType->addElement($name,$type);
-			}
+                		$typeParts = explode(":",$subElement->getAttribute('type'));
+				//$e = new mb_exception("element: ".$name." - type: ".$typeParts[0]);
+				if (empty($typeParts[0])) {
+					$e = new mb_warning("No type attribute found in xs:element - test for integrated simpleType!");
+					//it maybe a simple type
+					/*<xs:element name="kennung" nillable="true" minOccurs="0" maxOccurs="1">
+						<xs:simpleType>
+							<xs:restriction base="string">
+								<xs:maxLength value="40"/>
+							</xs:restriction>
+						</xs:simpleType>
+					</xs:element>*/
+					$query = "xs:simpleType/xs:restriction";
+					$restriction = $xpath->query($query,$subElement);
+					$type = $restriction->item(0)->getAttribute('base');
+					//TODO parse further information from xsd like maxLength: <xs:maxLength value="40"/> - add further column in wfs_element!
+				} else {
+					switch (count($typeParts)) {
+						case 1 :
+							$type = $typeParts[0];
+						break;
+						case 2 :
+							$type = $typeParts[1];
+						break;
+					}
+				}
+	    			$newFeatureType->addElement($name,$type);
+	    		}
 
 		}
 		return $newFeatureType;



More information about the Mapbender_commits mailing list