2 * @requires OpenLayers/Format.js
6 * Class: OpenLayers.Format.WMSCapabilities
7 * Read WMS Capabilities.
10 * - <OpenLayers.Format>
12 OpenLayers.Format.WMSCapabilities = OpenLayers.Class(OpenLayers.Format.XML, {
15 * APIProperty: defaultVersion
16 * {String} Version number to assume if none found. Default is "1.1.1".
18 defaultVersion: "1.1.1",
21 * APIProperty: version
22 * {String} Specify a version string if one is known.
28 * {<OpenLayers.Format>} A cached versioned format used for reading.
33 * Constructor: OpenLayers.Format.WMSCapabilities
34 * Create a new parser for WMS capabilities.
37 * options - {Object} An optional object whose properties will be set on
40 initialize: function(options) {
41 OpenLayers.Format.prototype.initialize.apply(this, [options]);
42 this.options = options;
47 * Read capabilities data from a string, and return a list of layers.
50 * data - {String} or {DOMElement} data to read/parse.
53 * {Array} List of named layers.
55 read: function(data) {
56 if(typeof data == "string") {
57 data = OpenLayers.Format.XML.prototype.read.apply(this, [data]);
59 var root = data.documentElement;
60 var version = this.version || root.getAttribute("version") || this.defaultVersion;
61 if(!this.parser || this.parser.version !== version) {
62 var constr = OpenLayers.Format.WMSCapabilities[
63 "v" + version.replace(/\./g, "_")
66 throw "Can't find a WMS capabilities parser for version " + version;
68 var parser = new constr(this.options);
70 var capabilities = parser.read(data);
71 capabilities.version = version;
75 CLASS_NAME: "OpenLayers.Format.WMSCapabilities"