Merge pull request #7973 from fredj/rm_setAttributeNS
Remove setAttributeNS function from ol/xml
This commit is contained in:
@@ -17,7 +17,7 @@ import {assign} from '../obj.js';
|
|||||||
import {get as getProjection, transformExtent} from '../proj.js';
|
import {get as getProjection, transformExtent} from '../proj.js';
|
||||||
import {createElementNS, getAllTextContent, makeArrayPusher, makeChildAppender,
|
import {createElementNS, getAllTextContent, makeArrayPusher, makeChildAppender,
|
||||||
makeReplacer, makeSimpleNodeFactory, OBJECT_PROPERTY_NODE_FACTORY, parseNode,
|
makeReplacer, makeSimpleNodeFactory, OBJECT_PROPERTY_NODE_FACTORY, parseNode,
|
||||||
pushParseAndPop, pushSerializeAndPop, setAttributeNS} from '../xml.js';
|
pushParseAndPop, pushSerializeAndPop, XML_SCHEMA_INSTANCE_URI} from '../xml.js';
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1139,10 +1139,8 @@ GML3.prototype.writeFeatures;
|
|||||||
*/
|
*/
|
||||||
GML3.prototype.writeFeaturesNode = function(features, opt_options) {
|
GML3.prototype.writeFeaturesNode = function(features, opt_options) {
|
||||||
opt_options = this.adaptOptions(opt_options);
|
opt_options = this.adaptOptions(opt_options);
|
||||||
const node = createElementNS('http://www.opengis.net/gml',
|
const node = createElementNS('http://www.opengis.net/gml', 'featureMembers');
|
||||||
'featureMembers');
|
node.setAttributeNS(XML_SCHEMA_INSTANCE_URI, 'xsi:schemaLocation', this.schemaLocation);
|
||||||
setAttributeNS(node, 'http://www.w3.org/2001/XMLSchema-instance',
|
|
||||||
'xsi:schemaLocation', this.schemaLocation);
|
|
||||||
const context = {
|
const context = {
|
||||||
srsName: this.srsName,
|
srsName: this.srsName,
|
||||||
hasZ: this.hasZ,
|
hasZ: this.hasZ,
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ import {get as getProjection} from '../proj.js';
|
|||||||
import {createElementNS, makeArrayPusher, makeArraySerializer, makeChildAppender,
|
import {createElementNS, makeArrayPusher, makeArraySerializer, makeChildAppender,
|
||||||
makeObjectPropertySetter, makeSequence, makeSimpleNodeFactory, makeStructureNS,
|
makeObjectPropertySetter, makeSequence, makeSimpleNodeFactory, makeStructureNS,
|
||||||
OBJECT_PROPERTY_NODE_FACTORY, parseNode, pushParseAndPop, pushSerializeAndPop,
|
OBJECT_PROPERTY_NODE_FACTORY, parseNode, pushParseAndPop, pushSerializeAndPop,
|
||||||
setAttributeNS} from '../xml.js';
|
XML_SCHEMA_INSTANCE_URI} from '../xml.js';
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -741,8 +741,8 @@ function writeWptType(node, coordinate, objectStack) {
|
|||||||
const namespaceURI = parentNode.namespaceURI;
|
const namespaceURI = parentNode.namespaceURI;
|
||||||
const properties = context['properties'];
|
const properties = context['properties'];
|
||||||
//FIXME Projection handling
|
//FIXME Projection handling
|
||||||
setAttributeNS(node, null, 'lat', coordinate[1]);
|
node.setAttributeNS(null, 'lat', coordinate[1]);
|
||||||
setAttributeNS(node, null, 'lon', coordinate[0]);
|
node.setAttributeNS(null, 'lon', coordinate[0]);
|
||||||
const geometryLayout = context['geometryLayout'];
|
const geometryLayout = context['geometryLayout'];
|
||||||
switch (geometryLayout) {
|
switch (geometryLayout) {
|
||||||
case GeometryLayout.XYZM:
|
case GeometryLayout.XYZM:
|
||||||
@@ -887,9 +887,8 @@ GPX.prototype.writeFeaturesNode = function(features, opt_options) {
|
|||||||
//FIXME Serialize metadata
|
//FIXME Serialize metadata
|
||||||
const gpx = createElementNS('http://www.topografix.com/GPX/1/1', 'gpx');
|
const gpx = createElementNS('http://www.topografix.com/GPX/1/1', 'gpx');
|
||||||
const xmlnsUri = 'http://www.w3.org/2000/xmlns/';
|
const xmlnsUri = 'http://www.w3.org/2000/xmlns/';
|
||||||
const xmlSchemaInstanceUri = 'http://www.w3.org/2001/XMLSchema-instance';
|
gpx.setAttributeNS(xmlnsUri, 'xmlns:xsi', XML_SCHEMA_INSTANCE_URI);
|
||||||
setAttributeNS(gpx, xmlnsUri, 'xmlns:xsi', xmlSchemaInstanceUri);
|
gpx.setAttributeNS(XML_SCHEMA_INSTANCE_URI, 'xsi:schemaLocation', SCHEMA_LOCATION);
|
||||||
setAttributeNS(gpx, xmlSchemaInstanceUri, 'xsi:schemaLocation', SCHEMA_LOCATION);
|
|
||||||
gpx.setAttribute('version', '1.1');
|
gpx.setAttribute('version', '1.1');
|
||||||
gpx.setAttribute('creator', 'OpenLayers');
|
gpx.setAttribute('creator', 'OpenLayers');
|
||||||
|
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ import {createElementNS, getAllTextContent, isDocument, isNode, makeArrayExtende
|
|||||||
makeArrayPusher, makeChildAppender, makeObjectPropertySetter,
|
makeArrayPusher, makeChildAppender, makeObjectPropertySetter,
|
||||||
makeReplacer, makeSequence, makeSimpleNodeFactory, makeStructureNS,
|
makeReplacer, makeSequence, makeSimpleNodeFactory, makeStructureNS,
|
||||||
OBJECT_PROPERTY_NODE_FACTORY, parse, parseNode, pushParseAndPop,
|
OBJECT_PROPERTY_NODE_FACTORY, parse, parseNode, pushParseAndPop,
|
||||||
pushSerializeAndPop, setAttributeNS} from '../xml.js';
|
pushSerializeAndPop, XML_SCHEMA_INSTANCE_URI} from '../xml.js';
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -2974,12 +2974,9 @@ KML.prototype.writeFeaturesNode = function(features, opt_options) {
|
|||||||
opt_options = this.adaptOptions(opt_options);
|
opt_options = this.adaptOptions(opt_options);
|
||||||
const kml = createElementNS(NAMESPACE_URIS[4], 'kml');
|
const kml = createElementNS(NAMESPACE_URIS[4], 'kml');
|
||||||
const xmlnsUri = 'http://www.w3.org/2000/xmlns/';
|
const xmlnsUri = 'http://www.w3.org/2000/xmlns/';
|
||||||
const xmlSchemaInstanceUri = 'http://www.w3.org/2001/XMLSchema-instance';
|
kml.setAttributeNS(xmlnsUri, 'xmlns:gx', GX_NAMESPACE_URIS[0]);
|
||||||
setAttributeNS(kml, xmlnsUri, 'xmlns:gx',
|
kml.setAttributeNS(xmlnsUri, 'xmlns:xsi', XML_SCHEMA_INSTANCE_URI);
|
||||||
GX_NAMESPACE_URIS[0]);
|
kml.setAttributeNS(XML_SCHEMA_INSTANCE_URI, 'xsi:schemaLocation', SCHEMA_LOCATION);
|
||||||
setAttributeNS(kml, xmlnsUri, 'xmlns:xsi', xmlSchemaInstanceUri);
|
|
||||||
setAttributeNS(kml, xmlSchemaInstanceUri, 'xsi:schemaLocation',
|
|
||||||
SCHEMA_LOCATION);
|
|
||||||
|
|
||||||
const /** @type {module:ol/xml~NodeStackItem} */ context = {node: kml};
|
const /** @type {module:ol/xml~NodeStackItem} */ context = {node: kml};
|
||||||
const properties = {};
|
const properties = {};
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ import {assign} from '../obj.js';
|
|||||||
import {get as getProjection} from '../proj.js';
|
import {get as getProjection} from '../proj.js';
|
||||||
import {createElementNS, isDocument, isNode, makeArrayPusher, makeChildAppender,
|
import {createElementNS, isDocument, isNode, makeArrayPusher, makeChildAppender,
|
||||||
makeObjectPropertySetter, makeSimpleNodeFactory, parse, parseNode,
|
makeObjectPropertySetter, makeSimpleNodeFactory, parse, parseNode,
|
||||||
pushParseAndPop, pushSerializeAndPop, setAttributeNS} from '../xml.js';
|
pushParseAndPop, pushSerializeAndPop, XML_SCHEMA_INSTANCE_URI} from '../xml.js';
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -487,7 +487,7 @@ function writeDelete(node, feature, objectStack) {
|
|||||||
const featureNS = context['featureNS'];
|
const featureNS = context['featureNS'];
|
||||||
const typeName = getTypeName(featurePrefix, featureType);
|
const typeName = getTypeName(featurePrefix, featureType);
|
||||||
node.setAttribute('typeName', typeName);
|
node.setAttribute('typeName', typeName);
|
||||||
setAttributeNS(node, XMLNS, 'xmlns:' + featurePrefix, featureNS);
|
node.setAttributeNS(XMLNS, 'xmlns:' + featurePrefix, featureNS);
|
||||||
const fid = feature.getId();
|
const fid = feature.getId();
|
||||||
if (fid !== undefined) {
|
if (fid !== undefined) {
|
||||||
writeOgcFidFilter(node, fid, objectStack);
|
writeOgcFidFilter(node, fid, objectStack);
|
||||||
@@ -523,7 +523,7 @@ function writeUpdate(node, feature, objectStack) {
|
|||||||
const typeName = getTypeName(featurePrefix, featureType);
|
const typeName = getTypeName(featurePrefix, featureType);
|
||||||
const geometryName = feature.getGeometryName();
|
const geometryName = feature.getGeometryName();
|
||||||
node.setAttribute('typeName', typeName);
|
node.setAttribute('typeName', typeName);
|
||||||
setAttributeNS(node, XMLNS, 'xmlns:' + featurePrefix, featureNS);
|
node.setAttributeNS(XMLNS, 'xmlns:' + featurePrefix, featureNS);
|
||||||
const fid = feature.getId();
|
const fid = feature.getId();
|
||||||
if (fid !== undefined) {
|
if (fid !== undefined) {
|
||||||
const keys = feature.getKeys();
|
const keys = feature.getKeys();
|
||||||
@@ -649,7 +649,7 @@ function writeQuery(node, featureType, objectStack) {
|
|||||||
node.setAttribute('srsName', srsName);
|
node.setAttribute('srsName', srsName);
|
||||||
}
|
}
|
||||||
if (featureNS) {
|
if (featureNS) {
|
||||||
setAttributeNS(node, XMLNS, 'xmlns:' + featurePrefix, featureNS);
|
node.setAttributeNS(XMLNS, 'xmlns:' + featurePrefix, featureNS);
|
||||||
}
|
}
|
||||||
const item = /** @type {module:ol/xml~NodeStackItem} */ (assign({}, context));
|
const item = /** @type {module:ol/xml~NodeStackItem} */ (assign({}, context));
|
||||||
item.node = node;
|
item.node = node;
|
||||||
@@ -975,8 +975,7 @@ WFS.prototype.writeGetFeature = function(options) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
setAttributeNS(node, 'http://www.w3.org/2001/XMLSchema-instance',
|
node.setAttributeNS(XML_SCHEMA_INSTANCE_URI, 'xsi:schemaLocation', this.schemaLocation_);
|
||||||
'xsi:schemaLocation', this.schemaLocation_);
|
|
||||||
/** @type {module:ol/xml~NodeStackItem} */
|
/** @type {module:ol/xml~NodeStackItem} */
|
||||||
const context = {
|
const context = {
|
||||||
node: node,
|
node: node,
|
||||||
@@ -1021,8 +1020,7 @@ WFS.prototype.writeTransaction = function(inserts, updates, deletes, options) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
const schemaLocation = SCHEMA_LOCATIONS[version];
|
const schemaLocation = SCHEMA_LOCATIONS[version];
|
||||||
setAttributeNS(node, 'http://www.w3.org/2001/XMLSchema-instance',
|
node.setAttributeNS(XML_SCHEMA_INSTANCE_URI, 'xsi:schemaLocation', schemaLocation);
|
||||||
'xsi:schemaLocation', schemaLocation);
|
|
||||||
const featurePrefix = options.featurePrefix ? options.featurePrefix : FEATURE_PREFIX;
|
const featurePrefix = options.featurePrefix ? options.featurePrefix : FEATURE_PREFIX;
|
||||||
if (inserts) {
|
if (inserts) {
|
||||||
obj = {node: node, 'featureNS': options.featureNS,
|
obj = {node: node, 'featureNS': options.featureNS,
|
||||||
|
|||||||
@@ -25,14 +25,19 @@ import {extend} from './array.js';
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* This document should be used when creating nodes for XML serializations. This
|
* This document should be used when creating nodes for XML serializations. This
|
||||||
* document is also used by {@link module:ol/xml~createElementNS} and
|
* document is also used by {@link module:ol/xml~createElementNS}
|
||||||
* {@link module:ol/xml~setAttributeNS}
|
|
||||||
* @const
|
* @const
|
||||||
* @type {Document}
|
* @type {Document}
|
||||||
*/
|
*/
|
||||||
export const DOCUMENT = document.implementation.createDocument('', '', null);
|
export const DOCUMENT = document.implementation.createDocument('', '', null);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @type {string}
|
||||||
|
*/
|
||||||
|
export const XML_SCHEMA_INSTANCE_URI = 'http://www.w3.org/2001/XMLSchema-instance';
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {string} namespaceURI Namespace URI.
|
* @param {string} namespaceURI Namespace URI.
|
||||||
* @param {string} qualifiedName Qualified name.
|
* @param {string} qualifiedName Qualified name.
|
||||||
@@ -112,17 +117,6 @@ export function getAttributeNS(node, namespaceURI, name) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {Node} node Node.
|
|
||||||
* @param {?string} namespaceURI Namespace URI.
|
|
||||||
* @param {string} name Attribute name.
|
|
||||||
* @param {string|number} value Value.
|
|
||||||
*/
|
|
||||||
export function setAttributeNS(node, namespaceURI, name, value) {
|
|
||||||
node.setAttributeNS(namespaceURI, name, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parse an XML string to an XML Document.
|
* Parse an XML string to an XML Document.
|
||||||
* @param {string} xml XML.
|
* @param {string} xml XML.
|
||||||
|
|||||||
Reference in New Issue
Block a user