Add ol.format.XSD.readBoolean function

This commit is contained in:
Frederic Junod
2014-01-23 10:54:40 +01:00
parent 827ae44a5f
commit cb25267341

View File

@@ -11,6 +11,21 @@ goog.require('ol.xml');
ol.format.XSD.NAMESPACE_URI = 'http://www.w3.org/2001/XMLSchema';
/**
* @param {Node} node Node.
* @return {boolean|undefined} Boolean.
*/
ol.format.XSD.readBoolean = function(node) {
var s = ol.xml.getAllTextContent(node, false);
var m = /^\s*(true|1)|(false|0)\s*$/.exec(s);
if (m) {
return goog.isDef(m[1]) || false;
} else {
return undefined;
}
};
/**
* @param {Node} node Node.
* @return {number|undefined} DateTime.