From e3deb03e71a79ae3891661bbe89006360c14be9e Mon Sep 17 00:00:00 2001 From: Frederic Junod Date: Mon, 10 Feb 2014 16:13:12 +0100 Subject: [PATCH 1/3] Add ol.format.XSD.readBooleanString function --- src/ol/format/xsdformat.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/ol/format/xsdformat.js b/src/ol/format/xsdformat.js index 9d52f36d38..cf38bb5ab7 100644 --- a/src/ol/format/xsdformat.js +++ b/src/ol/format/xsdformat.js @@ -17,7 +17,16 @@ ol.format.XSD.NAMESPACE_URI = 'http://www.w3.org/2001/XMLSchema'; */ ol.format.XSD.readBoolean = function(node) { var s = ol.xml.getAllTextContent(node, false); - var m = /^\s*(true|1)|(false|0)\s*$/.exec(s); + return ol.format.XSD.readBooleanString(s); +}; + + +/** + * @param {string} string String. + * @return {boolean|undefined} Boolean. + */ +ol.format.XSD.readBooleanString = function(string) { + var m = /^\s*(true|1)|(false|0)\s*$/.exec(string); if (m) { return goog.isDef(m[1]) || false; } else { From f6629fae6c92566b654ae6216e12f31949919a8e Mon Sep 17 00:00:00 2001 From: Frederic Junod Date: Mon, 10 Feb 2014 16:13:34 +0100 Subject: [PATCH 2/3] Add ol.format.XSD.readDecimalString function --- src/ol/format/xsdformat.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/ol/format/xsdformat.js b/src/ol/format/xsdformat.js index cf38bb5ab7..69056e2dc5 100644 --- a/src/ol/format/xsdformat.js +++ b/src/ol/format/xsdformat.js @@ -71,9 +71,18 @@ ol.format.XSD.readDateTime = function(node) { * @return {number|undefined} Decimal. */ ol.format.XSD.readDecimal = function(node) { - // FIXME check spec var s = ol.xml.getAllTextContent(node, false); - var m = /^\s*([+\-]?\d*\.?\d+(?:e[+\-]?\d+)?)\s*$/i.exec(s); + return ol.format.XSD.readDecimalString(s); +}; + + +/** + * @param {string} string String. + * @return {number|undefined} Decimal. + */ +ol.format.XSD.readDecimalString = function(string) { + // FIXME check spec + var m = /^\s*([+\-]?\d*\.?\d+(?:e[+\-]?\d+)?)\s*$/i.exec(string); if (m) { return parseFloat(m[1]); } else { From f06adff56c2af0300847e21107b7d8fb08719358 Mon Sep 17 00:00:00 2001 From: Frederic Junod Date: Mon, 10 Feb 2014 16:13:46 +0100 Subject: [PATCH 3/3] Add ol.format.XSD.readNonNegativeIntegerString function --- src/ol/format/xsdformat.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/ol/format/xsdformat.js b/src/ol/format/xsdformat.js index 69056e2dc5..058cedd1f9 100644 --- a/src/ol/format/xsdformat.js +++ b/src/ol/format/xsdformat.js @@ -97,7 +97,16 @@ ol.format.XSD.readDecimalString = function(string) { */ ol.format.XSD.readNonNegativeInteger = function(node) { var s = ol.xml.getAllTextContent(node, false); - var m = /^\s*(\d+)\s*$/.exec(s); + return ol.format.XSD.readNonNegativeIntegerString(s); +}; + + +/** + * @param {string} string String. + * @return {number|undefined} Non negative integer. + */ +ol.format.XSD.readNonNegativeIntegerString = function(string) { + var m = /^\s*(\d+)\s*$/.exec(string); if (m) { return parseInt(m[1], 10); } else {