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

View File

@@ -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'),

View File

@@ -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) {

View File

@@ -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);
},

View File

@@ -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(/ +/);

View File

@@ -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;
}

View File

@@ -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);

View File

@@ -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);
}
};
};

View File

@@ -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['*'];