rewrite WMS GetCapabilities parser, tests now pass in IE, r=ahocevar (closes #2283)

git-svn-id: http://svn.openlayers.org/trunk/openlayers@9883 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
bartvde
2009-12-13 15:43:15 +00:00
parent e6f4a27b93
commit e9264d89eb
4 changed files with 425 additions and 676 deletions
File diff suppressed because it is too large Load Diff
@@ -33,14 +33,23 @@ OpenLayers.Format.WMSCapabilities.v1_1_0 = OpenLayers.Class(
}, },
/** /**
* Method: read_cap_SRS * Property: readers
* Contains public functions, grouped by namespace prefix, that will
* be applied when a namespaced node is found matching the function
* name. The function will be applied in the scope of this parser
* with two arguments: the node being read and a context object passed
* from the parent.
*/ */
read_cap_SRS: function(layer, node) { readers: {
"wms": OpenLayers.Util.applyDefaults({
"SRS": function(node, obj) {
var srs = this.getChildValue(node); var srs = this.getChildValue(node);
var values = srs.split(/ +/); var values = srs.split(/ +/);
for (var i=0, len=values.length; i<len; i++) { for (var i=0, len=values.length; i<len; i++) {
layer.srs[values[i]] = true; obj.srs[values[i]] = true;
} }
}
}, OpenLayers.Format.WMSCapabilities.v1_1.prototype.readers["wms"])
}, },
CLASS_NAME: "OpenLayers.Format.WMSCapabilities.v1_1_0" CLASS_NAME: "OpenLayers.Format.WMSCapabilities.v1_1_0"
@@ -33,19 +33,28 @@ OpenLayers.Format.WMSCapabilities.v1_1_1 = OpenLayers.Class(
}, },
/** /**
* Method: read_cap_SRS * Property: readers
* Contains public functions, grouped by namespace prefix, that will
* be applied when a namespaced node is found matching the function
* name. The function will be applied in the scope of this parser
* with two arguments: the node being read and a context object passed
* from the parent.
*/ */
read_cap_SRS: function(layer, node) { readers: {
"wms": OpenLayers.Util.applyDefaults({
"SRS": function(node, obj) {
var srs = this.getChildValue(node); var srs = this.getChildValue(node);
if (srs.indexOf(" ")) { if (srs.indexOf(" ")) {
// v1.1.0 style SRS // v1.1.0 style SRS
var values = srs.split(/ +/); var values = srs.split(/ +/);
for (var i=0, len=values.length; i<len; i++) { for (var i=0, len=values.length; i<len; i++) {
layer.srs[values[i]] = true; obj.srs[values[i]] = true;
} }
} else { } else {
layer.srs[srs] = true; obj.srs[srs] = true;
} }
}
}, OpenLayers.Format.WMSCapabilities.v1_1.prototype.readers["wms"])
}, },
CLASS_NAME: "OpenLayers.Format.WMSCapabilities.v1_1_1" CLASS_NAME: "OpenLayers.Format.WMSCapabilities.v1_1_1"
+1 -1
View File
@@ -617,7 +617,7 @@ OpenLayers.Format.XML = OpenLayers.Class(OpenLayers.Format, {
if(!obj) { if(!obj) {
obj = {}; obj = {};
} }
var group = this.readers[this.namespaceAlias[node.namespaceURI]]; var group = this.readers[node.namespaceURI ? this.namespaceAlias[node.namespaceURI]: this.defaultPrefix];
if(group) { if(group) {
var local = node.localName || node.nodeName.split(":").pop(); var local = node.localName || node.nodeName.split(":").pop();
var reader = group[local] || group["*"]; var reader = group[local] || group["*"];