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

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Tue Apr 5 04:03:56 EDT 2011


Author: kmq
Date: 2011-04-05 01:03:56 -0700 (Tue, 05 Apr 2011)
New Revision: 7744

Modified:
   trunk/mapbender/http/classes/class_wfs_1_0_factory.php
   trunk/mapbender/http/classes/class_wfs_1_1_factory.php
Log:
support for anonymous types in when parsing featuretype xsd

Modified: trunk/mapbender/http/classes/class_wfs_1_0_factory.php
===================================================================
--- trunk/mapbender/http/classes/class_wfs_1_0_factory.php	2011-04-05 07:45:22 UTC (rev 7743)
+++ trunk/mapbender/http/classes/class_wfs_1_0_factory.php	2011-04-05 08:03:56 UTC (rev 7744)
@@ -74,20 +74,30 @@
 			$elementName = $elementNode->getAttribute("name");
 			$elementType = $elementNode->getAttribute("type");
 
-			// 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
+            // 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{
 
-			// 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);
+                // 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

Modified: trunk/mapbender/http/classes/class_wfs_1_1_factory.php
===================================================================
--- trunk/mapbender/http/classes/class_wfs_1_1_factory.php	2011-04-05 07:45:22 UTC (rev 7743)
+++ trunk/mapbender/http/classes/class_wfs_1_1_factory.php	2011-04-05 08:03:56 UTC (rev 7744)
@@ -105,7 +105,6 @@
 			$newFeatureType->addNamespace($namespaceNode->localName, $namespaceNode->nodeValue);
 		}
 	
-
 		list($ftLocalname,$ftTypePrefix) = array_reverse(explode(":",$featureTypeName));
 		// for the sake of simplicity we only care about top level elements. Seems to have worked so far
 		$query = sprintf("/xs:schema/xs:element[@name='%s']",$ftLocalname);
@@ -115,21 +114,30 @@
 			$elementName = $elementNode->getAttribute("name");
 			$elementType = $elementNode->getAttribute("type");
 
-			// 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
+            // 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{
 
-			// 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);
-			$e = new mb_exception("NNN sub $query $subElementList->length");
+                // 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
@@ -144,6 +152,7 @@
 			}
 
 		}
+        echo "<br /><br />  ";
 		return $newFeatureType;
 	}
 



More information about the Mapbender_commits mailing list