From 13d95b90a34364307803c77425e5ad970f82503b Mon Sep 17 00:00:00 2001 From: Bart van den Eijnden Date: Wed, 13 Feb 2013 20:58:48 +0100 Subject: [PATCH] use namespace URI instead of prefix as suggested by @tschaub and discussed with @ahocevar --- src/ol/parser/ogc/exceptionreport.js | 11 +++-------- src/ol/parser/ogc/wmscapabilities_v1.js | 10 +++------- src/ol/parser/ogc/wmscapabilities_v1_1.js | 4 ++-- src/ol/parser/ogc/wmscapabilities_v1_1_0.js | 2 +- src/ol/parser/ogc/wmscapabilities_v1_1_1.js | 2 +- src/ol/parser/ogc/wmscapabilities_v1_1_1_WMSC.js | 2 +- src/ol/parser/ogc/wmscapabilities_v1_3_0.js | 15 +++++++++------ src/ol/parser/xml.js | 11 ++--------- 8 files changed, 22 insertions(+), 35 deletions(-) diff --git a/src/ol/parser/ogc/exceptionreport.js b/src/ol/parser/ogc/exceptionreport.js index 45f53b2226..ce2e4990c1 100644 --- a/src/ol/parser/ogc/exceptionreport.js +++ b/src/ol/parser/ogc/exceptionreport.js @@ -9,11 +9,6 @@ goog.require('ol.parser.XML'); * @extends {ol.parser.XML} */ ol.parser.ogc.ExceptionReport = function() { - this.defaultPrefix = 'ogc'; - this.namespaces = {}; - this.namespaces['ogc'] = 'http://www.opengis.net/ogc'; - this.namespaces['ows'] = 'http://www.opengis.net/ows'; - this.namespaces['ows11'] = 'http://www.opengis.net/ows/1.1'; var exceptionReader = function(node, exceptionReport) { var exception = { code: node.getAttribute('exceptionCode'), @@ -28,7 +23,7 @@ ol.parser.ogc.ExceptionReport = function() { exception.texts.push(text); }; this.readers = { - 'ogc': { + 'http://www.opengis.net/ogc': { 'ServiceExceptionReport': function(node, obj) { obj['exceptionReport'] = {}; obj['exceptionReport']['exceptions'] = []; @@ -42,7 +37,7 @@ ol.parser.ogc.ExceptionReport = function() { exceptionReport['exceptions'].push(exception); } }, - 'ows': { + 'http://www.opengis.net/ows': { 'ExceptionReport': function(node, obj) { obj.success = false; obj.exceptionReport = { @@ -59,7 +54,7 @@ ol.parser.ogc.ExceptionReport = function() { exceptionTextReader.apply(this, arguments); } }, - 'ows11': { + 'http://www.opengis.net/ows/1.1': { 'ExceptionReport': function(node, obj) { obj.exceptionReport = { version: node.getAttribute('version'), diff --git a/src/ol/parser/ogc/wmscapabilities_v1.js b/src/ol/parser/ogc/wmscapabilities_v1.js index 02fedc289b..f1fe0ca815 100644 --- a/src/ol/parser/ogc/wmscapabilities_v1.js +++ b/src/ol/parser/ogc/wmscapabilities_v1.js @@ -10,14 +10,10 @@ goog.require('ol.parser.XML'); * @extends {ol.parser.XML} */ ol.parser.ogc.WMSCapabilities_v1 = function() { - this.defaultPrefix = 'wms'; + this.defaultNamespaceURI = 'http://www.opengis.net/wms'; this.errorProperty = 'service'; - this.namespaces = {}; - this.namespaces['wms'] = 'http://www.opengis.net/wms'; - this.namespaces['xlink'] = 'http://www.w3.org/1999/xlink'; - this.namespaces['xsi'] = 'http://www.w3.org/2001/XMLSchema-instance'; this.readers = { - 'wms': { + 'http://www.opengis.net/wms': { 'Service': function(node, obj) { obj['service'] = {}; this.readChildNodes(node, obj['service']); @@ -51,7 +47,7 @@ ol.parser.ogc.WMSCapabilities_v1 = function() { return bbox; }, 'OnlineResource': function(node, obj) { - obj.href = this.getAttributeNS(node, this.namespaces['xlink'], + obj.href = this.getAttributeNS(node, 'http://www.w3.org/1999/xlink', 'href'); }, 'ContactInformation': function(node, obj) { diff --git a/src/ol/parser/ogc/wmscapabilities_v1_1.js b/src/ol/parser/ogc/wmscapabilities_v1_1.js index c451e73955..a4cb628b52 100644 --- a/src/ol/parser/ogc/wmscapabilities_v1_1.js +++ b/src/ol/parser/ogc/wmscapabilities_v1_1.js @@ -9,8 +9,8 @@ goog.require('ol.parser.ogc.WMSCapabilities_v1'); */ ol.parser.ogc.WMSCapabilities_v1_1 = function() { goog.base(this); - var bboxreader = this.readers['wms']['BoundingBox']; - goog.object.extend(this.readers['wms'], { + var bboxreader = this.readers['http://www.opengis.net/wms']['BoundingBox']; + goog.object.extend(this.readers['http://www.opengis.net/wms'], { 'WMT_MS_Capabilities': function(node, obj) { this.readChildNodes(node, obj); }, diff --git a/src/ol/parser/ogc/wmscapabilities_v1_1_0.js b/src/ol/parser/ogc/wmscapabilities_v1_1_0.js index 56f5e6c973..9aaea77ba5 100644 --- a/src/ol/parser/ogc/wmscapabilities_v1_1_0.js +++ b/src/ol/parser/ogc/wmscapabilities_v1_1_0.js @@ -10,7 +10,7 @@ goog.require('ol.parser.ogc.WMSCapabilities_v1_1'); ol.parser.ogc.WMSCapabilities_v1_1_0 = function() { goog.base(this); this.version = '1.1.0'; - goog.object.extend(this.readers['wms'], { + goog.object.extend(this.readers['http://www.opengis.net/wms'], { 'SRS': function(node, obj) { var srs = this.getChildValue(node); var values = srs.split(/ +/); diff --git a/src/ol/parser/ogc/wmscapabilities_v1_1_1.js b/src/ol/parser/ogc/wmscapabilities_v1_1_1.js index 9dc0db672b..a8c23c2e3f 100644 --- a/src/ol/parser/ogc/wmscapabilities_v1_1_1.js +++ b/src/ol/parser/ogc/wmscapabilities_v1_1_1.js @@ -10,7 +10,7 @@ goog.require('ol.parser.ogc.WMSCapabilities_v1_1'); ol.parser.ogc.WMSCapabilities_v1_1_1 = function() { goog.base(this); this.version = '1.1.1'; - goog.object.extend(this.readers['wms'], { + goog.object.extend(this.readers['http://www.opengis.net/wms'], { 'SRS': function(node, obj) { obj.srs[this.getChildValue(node)] = true; } diff --git a/src/ol/parser/ogc/wmscapabilities_v1_1_1_WMSC.js b/src/ol/parser/ogc/wmscapabilities_v1_1_1_WMSC.js index eca49226e6..246babafc3 100644 --- a/src/ol/parser/ogc/wmscapabilities_v1_1_1_WMSC.js +++ b/src/ol/parser/ogc/wmscapabilities_v1_1_1_WMSC.js @@ -10,7 +10,7 @@ goog.require('ol.parser.ogc.WMSCapabilities_v1_1_1'); ol.parser.ogc.WMSCapabilities_v1_1_1_WMSC = function() { goog.base(this); this.profile = 'WMSC'; - goog.object.extend(this.readers['wms'], { + goog.object.extend(this.readers['http://www.opengis.net/wms'], { 'VendorSpecificCapabilities': function(node, obj) { obj.vendorSpecific = {tileSets: []}; this.readChildNodes(node, obj.vendorSpecific); diff --git a/src/ol/parser/ogc/wmscapabilities_v1_3_0.js b/src/ol/parser/ogc/wmscapabilities_v1_3_0.js index e3ac7ea2a0..c17ab9acea 100644 --- a/src/ol/parser/ogc/wmscapabilities_v1_3_0.js +++ b/src/ol/parser/ogc/wmscapabilities_v1_3_0.js @@ -9,8 +9,8 @@ goog.require('ol.parser.ogc.WMSCapabilities_v1'); */ ol.parser.ogc.WMSCapabilities_v1_3_0 = function() { goog.base(this); - var bboxreader = this.readers['wms']['BoundingBox']; - goog.object.extend(this.readers['wms'], { + var bboxreader = this.readers['http://www.opengis.net/wms']['BoundingBox']; + goog.object.extend(this.readers['http://www.opengis.net/wms'], { 'WMS_Capabilities': function(node, obj) { this.readChildNodes(node, obj); }, @@ -30,7 +30,7 @@ ol.parser.ogc.WMSCapabilities_v1_3_0 = function() { }, 'CRS': function(node, obj) { // CRS is the synonym of SRS - this.readers['wms']['SRS'].apply(this, arguments); + this.readers['http://www.opengis.net/wms']['SRS'].apply(this, arguments); }, 'EX_GeographicBoundingBox': function(node, obj) { // replacement of LatLonBoundingBox @@ -87,7 +87,8 @@ ol.parser.ogc.WMSCapabilities_v1_3_0 = function() { }); this.readers['sld'] = { 'UserDefinedSymbolization': function(node, obj) { - this.readers.wms.UserDefinedSymbolization.apply(this, arguments); + var readers = this.readers['http://www.opengis.net/wms']; + readers.UserDefinedSymbolization.apply(this, arguments); // add the two extra attributes var value = node.getAttribute('InlineFeature'); obj['userSymbols'].inlineFeature = parseInt(value, 10) == 1; @@ -95,10 +96,12 @@ ol.parser.ogc.WMSCapabilities_v1_3_0 = function() { obj['userSymbols'].remoteWCS = parseInt(value, 10) == 1; }, 'DescribeLayer': function(node, obj) { - this.readers.wms.DescribeLayer.apply(this, arguments); + var readers = this.readers['http://www.opengis.net/wms']; + readers.DescribeLayer.apply(this, arguments); }, 'GetLegendGraphic': function(node, obj) { - this.readers.wms.GetLegendGraphic.apply(this, arguments); + var readers = this.readers['http://www.opengis.net/wms']; + readers.GetLegendGraphic.apply(this, arguments); } }; }; diff --git a/src/ol/parser/xml.js b/src/ol/parser/xml.js index 269efff7ed..d0df3ab763 100644 --- a/src/ol/parser/xml.js +++ b/src/ol/parser/xml.js @@ -1,5 +1,4 @@ goog.provide('ol.parser.XML'); -goog.require('goog.object'); @@ -7,12 +6,6 @@ goog.require('goog.object'); * @constructor */ ol.parser.XML = function() { - // clone the namespaces object and set all namespace aliases - this.namespaces = goog.object.clone(this.namespaces); - this.namespaceAlias = {}; - for (var alias in this.namespaces) { - this.namespaceAlias[this.namespaces[alias]] = alias; - } }; @@ -30,8 +23,8 @@ ol.parser.XML.prototype.readNode = function(node, obj) { if (!obj) { obj = {}; } - var group = this.readers[node.namespaceURI ? - this.namespaceAlias[node.namespaceURI] : this.defaultPrefix]; + var group = this.readers[node.namespaceURI] || + this.readers[this.defaultNamespaceURI]; if (group) { var local = node.localName || node.nodeName.split(':').pop(); var reader = group[local] || group['*'];