OWSCommon.js 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for
  2. * full list of contributors). Published under the 2-clause BSD license.
  3. * See license.txt in the OpenLayers distribution or repository for the
  4. * full text of the license. */
  5. /**
  6. * @requires OpenLayers/Format/XML/VersionedOGC.js
  7. */
  8. /**
  9. * Class: OpenLayers.Format.OWSCommon
  10. * Read OWSCommon. Create a new instance with the <OpenLayers.Format.OWSCommon>
  11. * constructor.
  12. *
  13. * Inherits from:
  14. * - <OpenLayers.Format.XML.VersionedOGC>
  15. */
  16. OpenLayers.Format.OWSCommon = OpenLayers.Class(OpenLayers.Format.XML.VersionedOGC, {
  17. /**
  18. * APIProperty: defaultVersion
  19. * {String} Version number to assume if none found. Default is "1.0.0".
  20. */
  21. defaultVersion: "1.0.0",
  22. /**
  23. * Constructor: OpenLayers.Format.OWSCommon
  24. * Create a new parser for OWSCommon.
  25. *
  26. * Parameters:
  27. * options - {Object} An optional object whose properties will be set on
  28. * this instance.
  29. */
  30. /**
  31. * Method: getVersion
  32. * Returns the version to use. Subclasses can override this function
  33. * if a different version detection is needed.
  34. *
  35. * Parameters:
  36. * root - {DOMElement}
  37. * options - {Object} Optional configuration object.
  38. *
  39. * Returns:
  40. * {String} The version to use.
  41. */
  42. getVersion: function(root, options) {
  43. var version = this.version;
  44. if(!version) {
  45. // remember version does not correspond to the OWS version
  46. // it corresponds to the WMS/WFS/WCS etc. request version
  47. var uri = root.getAttribute("xmlns:ows");
  48. // the above will fail if the namespace prefix is different than
  49. // ows and if the namespace is declared on a different element
  50. if (uri && uri.substring(uri.lastIndexOf("/")+1) === "1.1") {
  51. version ="1.1.0";
  52. }
  53. if(!version) {
  54. version = this.defaultVersion;
  55. }
  56. }
  57. return version;
  58. },
  59. /**
  60. * APIMethod: read
  61. * Read an OWSCommon document and return an object.
  62. *
  63. * Parameters:
  64. * data - {String | DOMElement} Data to read.
  65. * options - {Object} Options for the reader.
  66. *
  67. * Returns:
  68. * {Object} An object representing the structure of the document.
  69. */
  70. CLASS_NAME: "OpenLayers.Format.OWSCommon"
  71. });