diff --git a/lib/OpenLayers/Format/WMSCapabilities/v1_1.js b/lib/OpenLayers/Format/WMSCapabilities/v1_1.js index b548116bdf..170ae68e90 100644 --- a/lib/OpenLayers/Format/WMSCapabilities/v1_1.js +++ b/lib/OpenLayers/Format/WMSCapabilities/v1_1.js @@ -13,6 +13,21 @@ OpenLayers.Format.WMSCapabilities.v1_1 = OpenLayers.Class( OpenLayers.Format.XML, { + /** + * Property: namespaces + * {Object} Mapping of namespace aliases to namespace URIs. + */ + namespaces: { + wms: "http://www.opengis.net/wms", + xlink: "http://www.w3.org/1999/xlink", + xsi: "http://www.w3.org/2001/XMLSchema-instance" + }, + + /** + * Property: defaultPrefix + */ + defaultPrefix: "wms", + /** * Constructor: OpenLayers.Format.WMSCapabilities.v1_1 * Create an instance of one of the subclasses. @@ -23,7 +38,6 @@ OpenLayers.Format.WMSCapabilities.v1_1 = OpenLayers.Class( */ initialize: function(options) { OpenLayers.Format.XML.prototype.initialize.apply(this, [options]); - this.options = options; }, /** @@ -40,372 +54,57 @@ OpenLayers.Format.WMSCapabilities.v1_1 = OpenLayers.Class( if(typeof data == "string") { data = OpenLayers.Format.XML.prototype.read.apply(this, [data]); } + if(data && data.nodeType == 9) { + data = data.documentElement; + } var capabilities = {}; - var root = data.documentElement; - this.runChildNodes(capabilities, root); + this.readNode(data, capabilities); + + // postprocess the layer list + this.postProcessLayers(capabilities); + return capabilities; }, - + /** - * Method: runChildNodes + * Method: postProcessLayers + * Post process the layers, so that the nested layer structure is converted + * to a flat layer list with only named layers. + * + * Parameters: + * capabilities - {Object} The object (structure) returned by the parser with + * all the info from the GetCapabilities response. */ - runChildNodes: function(obj, node) { - var children = node.childNodes; - var childNode, processor; - for(var i=0; i 0) { - this.read_cap_OnlineResource(obj, children[0]); - } - }, - - /** - * Method: read_cap_Exception - */ - read_cap_Exception: function(capability, node) { - var exception = { - formats: [] - }; - this.runChildNodes(exception, node); - capability.exception = exception; - }, - - /** - * Method: read_cap_UserDefinedSymbolization - */ - read_cap_UserDefinedSymbolization: function(capability, node) { - var userSymbols = { - supportSLD: parseInt(node.getAttribute("SupportSLD")) == 1, - userLayer: parseInt(node.getAttribute("UserLayer")) == 1, - userStyle: parseInt(node.getAttribute("UserStyle")) == 1, - remoteWFS: parseInt(node.getAttribute("RemoteWFS")) == 1 - }; - capability.userSymbols = userSymbols; - }, - - /** - * Method: read_cap_Layer - */ - read_cap_Layer: function(capability, node, parentLayer) { - var layer = { - formats: capability.request.getmap.formats || [], - styles: [], - srs: {}, - bbox: {}, - dimensions: {}, - metadataURLs: [], - authorityURLs: {}, - identifiers: {}, - keywords: [] - }; // deal with property inheritance if(parentLayer) { // add style layer.styles = layer.styles.concat(parentLayer.styles); - var attributes = ["queryable", "cascaded", "fixedWidth", @@ -423,330 +122,362 @@ OpenLayers.Format.WMSCapabilities.v1_1 = OpenLayers.Class( "authorityURLs"]; var key; - for (var i=0; i 0) { - layer.prefix = layer.name.substring(0, index); - } + // process sublayers + for (var i=0, len=layer.nestedLayers.length; i