GML parser.
This adds a parser (read/write) for GML v2 and v3. GML v3 is limited to the simple features profile of GML 3.1.1, just like OpenLayers 2 was. This will be the basis for the WFS parser, but it only makes sense to continue this work once feature modification (insert, update, delete) is in place in ol3. So the WFS parser will be another pull request.
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
goog.provide('ol.parser.XML');
|
||||
|
||||
goog.require('goog.dom.xml');
|
||||
goog.require('ol.parser.Parser');
|
||||
|
||||
|
||||
@@ -246,3 +247,27 @@ ol.parser.XML.prototype.setAttributeNS = function(node, uri, name, value) {
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Serializes a node.
|
||||
*
|
||||
* @param {Element} node Element node to serialize.
|
||||
* @return {string} The serialized XML string.
|
||||
*/
|
||||
ol.parser.XML.prototype.serialize = function(node) {
|
||||
if (node.nodeType == 1) {
|
||||
// Add nodes to a document before serializing. Everything else
|
||||
// is serialized as is. This is also needed to get all namespaces
|
||||
// defined in some browsers such as Chrome (xmlns attributes).
|
||||
var doc = document.implementation.createDocument('', '', null);
|
||||
if (doc.importNode) {
|
||||
doc.appendChild(doc.importNode(node, true));
|
||||
} else {
|
||||
doc.appendChild(node);
|
||||
}
|
||||
return goog.dom.xml.serialize(doc);
|
||||
} else {
|
||||
return goog.dom.xml.serialize(node);
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user