all files / ol/format/ xml.js

85.71% Statements 12/14
66.67% Branches 4/6
50% Functions 2/4
85.71% Lines 12/14
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50                                                                            
goog.provide('ol.format.XML');
 
goog.require('ol.xml');
 
 
/**
 * @classdesc
 * Generic format for reading non-feature XML data
 *
 * @constructor
 * @abstract
 * @struct
 */
ol.format.XML = function() {
};
 
 
/**
 * @param {Document|Node|string} source Source.
 * @return {Object} The parsed result.
 */
ol.format.XML.prototype.read = function(source) {
  if (ol.xml.isDocument(source)) {
    return this.readFromDocument(/** @type {Document} */ (source));
  } else Iif (ol.xml.isNode(source)) {
    return this.readFromNode(/** @type {Node} */ (source));
  } else Eif (typeof source === 'string') {
    var doc = ol.xml.parse(source);
    return this.readFromDocument(doc);
  } else {
    return null;
  }
};
 
 
/**
 * @abstract
 * @param {Document} doc Document.
 * @return {Object} Object
 */
ol.format.XML.prototype.readFromDocument = function(doc) {};
 
 
/**
 * @abstract
 * @param {Node} node Node.
 * @return {Object} Object
 */
ol.format.XML.prototype.readFromNode = function(node) {};