use namespace URI instead of prefix as suggested by @tschaub and discussed with @ahocevar

This commit is contained in:
Bart van den Eijnden
2013-02-13 20:58:48 +01:00
parent f16664cb87
commit 13d95b90a3
8 changed files with 22 additions and 35 deletions
+3 -8
View File
@@ -9,11 +9,6 @@ goog.require('ol.parser.XML');
* @extends {ol.parser.XML} * @extends {ol.parser.XML}
*/ */
ol.parser.ogc.ExceptionReport = function() { 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 exceptionReader = function(node, exceptionReport) {
var exception = { var exception = {
code: node.getAttribute('exceptionCode'), code: node.getAttribute('exceptionCode'),
@@ -28,7 +23,7 @@ ol.parser.ogc.ExceptionReport = function() {
exception.texts.push(text); exception.texts.push(text);
}; };
this.readers = { this.readers = {
'ogc': { 'http://www.opengis.net/ogc': {
'ServiceExceptionReport': function(node, obj) { 'ServiceExceptionReport': function(node, obj) {
obj['exceptionReport'] = {}; obj['exceptionReport'] = {};
obj['exceptionReport']['exceptions'] = []; obj['exceptionReport']['exceptions'] = [];
@@ -42,7 +37,7 @@ ol.parser.ogc.ExceptionReport = function() {
exceptionReport['exceptions'].push(exception); exceptionReport['exceptions'].push(exception);
} }
}, },
'ows': { 'http://www.opengis.net/ows': {
'ExceptionReport': function(node, obj) { 'ExceptionReport': function(node, obj) {
obj.success = false; obj.success = false;
obj.exceptionReport = { obj.exceptionReport = {
@@ -59,7 +54,7 @@ ol.parser.ogc.ExceptionReport = function() {
exceptionTextReader.apply(this, arguments); exceptionTextReader.apply(this, arguments);
} }
}, },
'ows11': { 'http://www.opengis.net/ows/1.1': {
'ExceptionReport': function(node, obj) { 'ExceptionReport': function(node, obj) {
obj.exceptionReport = { obj.exceptionReport = {
version: node.getAttribute('version'), version: node.getAttribute('version'),
+3 -7
View File
@@ -10,14 +10,10 @@ goog.require('ol.parser.XML');
* @extends {ol.parser.XML} * @extends {ol.parser.XML}
*/ */
ol.parser.ogc.WMSCapabilities_v1 = function() { ol.parser.ogc.WMSCapabilities_v1 = function() {
this.defaultPrefix = 'wms'; this.defaultNamespaceURI = 'http://www.opengis.net/wms';
this.errorProperty = 'service'; 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 = { this.readers = {
'wms': { 'http://www.opengis.net/wms': {
'Service': function(node, obj) { 'Service': function(node, obj) {
obj['service'] = {}; obj['service'] = {};
this.readChildNodes(node, obj['service']); this.readChildNodes(node, obj['service']);
@@ -51,7 +47,7 @@ ol.parser.ogc.WMSCapabilities_v1 = function() {
return bbox; return bbox;
}, },
'OnlineResource': function(node, obj) { 'OnlineResource': function(node, obj) {
obj.href = this.getAttributeNS(node, this.namespaces['xlink'], obj.href = this.getAttributeNS(node, 'http://www.w3.org/1999/xlink',
'href'); 'href');
}, },
'ContactInformation': function(node, obj) { 'ContactInformation': function(node, obj) {
+2 -2
View File
@@ -9,8 +9,8 @@ goog.require('ol.parser.ogc.WMSCapabilities_v1');
*/ */
ol.parser.ogc.WMSCapabilities_v1_1 = function() { ol.parser.ogc.WMSCapabilities_v1_1 = function() {
goog.base(this); goog.base(this);
var bboxreader = this.readers['wms']['BoundingBox']; var bboxreader = this.readers['http://www.opengis.net/wms']['BoundingBox'];
goog.object.extend(this.readers['wms'], { goog.object.extend(this.readers['http://www.opengis.net/wms'], {
'WMT_MS_Capabilities': function(node, obj) { 'WMT_MS_Capabilities': function(node, obj) {
this.readChildNodes(node, obj); this.readChildNodes(node, obj);
}, },
+1 -1
View File
@@ -10,7 +10,7 @@ goog.require('ol.parser.ogc.WMSCapabilities_v1_1');
ol.parser.ogc.WMSCapabilities_v1_1_0 = function() { ol.parser.ogc.WMSCapabilities_v1_1_0 = function() {
goog.base(this); goog.base(this);
this.version = '1.1.0'; 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) { 'SRS': function(node, obj) {
var srs = this.getChildValue(node); var srs = this.getChildValue(node);
var values = srs.split(/ +/); var values = srs.split(/ +/);
+1 -1
View File
@@ -10,7 +10,7 @@ goog.require('ol.parser.ogc.WMSCapabilities_v1_1');
ol.parser.ogc.WMSCapabilities_v1_1_1 = function() { ol.parser.ogc.WMSCapabilities_v1_1_1 = function() {
goog.base(this); goog.base(this);
this.version = '1.1.1'; 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) { 'SRS': function(node, obj) {
obj.srs[this.getChildValue(node)] = true; obj.srs[this.getChildValue(node)] = true;
} }
@@ -10,7 +10,7 @@ goog.require('ol.parser.ogc.WMSCapabilities_v1_1_1');
ol.parser.ogc.WMSCapabilities_v1_1_1_WMSC = function() { ol.parser.ogc.WMSCapabilities_v1_1_1_WMSC = function() {
goog.base(this); goog.base(this);
this.profile = 'WMSC'; this.profile = 'WMSC';
goog.object.extend(this.readers['wms'], { goog.object.extend(this.readers['http://www.opengis.net/wms'], {
'VendorSpecificCapabilities': function(node, obj) { 'VendorSpecificCapabilities': function(node, obj) {
obj.vendorSpecific = {tileSets: []}; obj.vendorSpecific = {tileSets: []};
this.readChildNodes(node, obj.vendorSpecific); this.readChildNodes(node, obj.vendorSpecific);
+9 -6
View File
@@ -9,8 +9,8 @@ goog.require('ol.parser.ogc.WMSCapabilities_v1');
*/ */
ol.parser.ogc.WMSCapabilities_v1_3_0 = function() { ol.parser.ogc.WMSCapabilities_v1_3_0 = function() {
goog.base(this); goog.base(this);
var bboxreader = this.readers['wms']['BoundingBox']; var bboxreader = this.readers['http://www.opengis.net/wms']['BoundingBox'];
goog.object.extend(this.readers['wms'], { goog.object.extend(this.readers['http://www.opengis.net/wms'], {
'WMS_Capabilities': function(node, obj) { 'WMS_Capabilities': function(node, obj) {
this.readChildNodes(node, obj); this.readChildNodes(node, obj);
}, },
@@ -30,7 +30,7 @@ ol.parser.ogc.WMSCapabilities_v1_3_0 = function() {
}, },
'CRS': function(node, obj) { 'CRS': function(node, obj) {
// CRS is the synonym of SRS // 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) { 'EX_GeographicBoundingBox': function(node, obj) {
// replacement of LatLonBoundingBox // replacement of LatLonBoundingBox
@@ -87,7 +87,8 @@ ol.parser.ogc.WMSCapabilities_v1_3_0 = function() {
}); });
this.readers['sld'] = { this.readers['sld'] = {
'UserDefinedSymbolization': function(node, obj) { '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 // add the two extra attributes
var value = node.getAttribute('InlineFeature'); var value = node.getAttribute('InlineFeature');
obj['userSymbols'].inlineFeature = parseInt(value, 10) == 1; 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; obj['userSymbols'].remoteWCS = parseInt(value, 10) == 1;
}, },
'DescribeLayer': function(node, obj) { '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) { '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);
} }
}; };
}; };
+2 -9
View File
@@ -1,5 +1,4 @@
goog.provide('ol.parser.XML'); goog.provide('ol.parser.XML');
goog.require('goog.object');
@@ -7,12 +6,6 @@ goog.require('goog.object');
* @constructor * @constructor
*/ */
ol.parser.XML = function() { 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) { if (!obj) {
obj = {}; obj = {};
} }
var group = this.readers[node.namespaceURI ? var group = this.readers[node.namespaceURI] ||
this.namespaceAlias[node.namespaceURI] : this.defaultPrefix]; this.readers[this.defaultNamespaceURI];
if (group) { if (group) {
var local = node.localName || node.nodeName.split(':').pop(); var local = node.localName || node.nodeName.split(':').pop();
var reader = group[local] || group['*']; var reader = group[local] || group['*'];