1 /* Copyright (c) 2006-2008 MetaCarta, Inc., published under the Clear BSD
2 * license. See http://svn.openlayers.org/trunk/openlayers/license.txt for the
3 * full text of the license. */
6 * @requires OpenLayers/Format/XML.js
10 * Class: OpenLayers.Format.WMSDescribeLayer
11 * Read SLD WMS DescribeLayer response
12 * DescribeLayer is meant to couple WMS to WFS and WCS
15 * - <OpenLayers.Format.XML>
17 OpenLayers.Format.WMSDescribeLayer = OpenLayers.Class(OpenLayers.Format.XML, {
20 * APIProperty: defaultVersion
21 * {String} Version number to assume if none found. Default is "1.1.1".
23 defaultVersion: "1.1.1",
26 * APIProperty: version
27 * {String} Specify a version string if one is known.
32 * Constructor: OpenLayers.Format.WMSDescribeLayer
33 * Create a new parser for WMS DescribeLayer responses.
36 * options - {Object} An optional object whose properties will be set on
39 initialize: function(options) {
40 OpenLayers.Format.XML.prototype.initialize.apply(this, [options]);
41 this.options = options;
46 * Read DescribeLayer data from a string, and return the response.
47 * The OGC currently defines 2 formats which are allowed for output,
48 * so we need to parse these 2 types
51 * data - {String} or {DOMElement} data to read/parse.
54 * {Array} Array of {<LayerDescription>} objects which have:
55 * - {String} owsType: WFS/WCS
56 * - {String} owsURL: the online resource
57 * - {String} typeName: the name of the typename on the service
59 read: function(data) {
60 if(typeof data == "string") {
61 data = OpenLayers.Format.XML.prototype.read.apply(this, [data]);
63 var root = data.documentElement;
64 var version = this.version;
66 version = root.getAttribute("version");
68 version = this.defaultVersion;
71 // these are identical to us, but some WMS use 1.1.1 and some use 1.1.0
72 if (version == "1.1.1" || version == "1.1.0") {
75 var constructor = OpenLayers.Format.WMSDescribeLayer[
76 "v" + version.replace(/\./g, "_")
79 throw "Can't find a WMS DescribeLayer parser for version " +
82 var parser = new constructor(this.options);
83 var describelayer = parser.read(data);
84 describelayer.version = version;
88 CLASS_NAME: "OpenLayers.Format.WMSDescribeLayer"