Skip to content

Commit

Permalink
Merge pull request #15197 from arekgotfryd/main
Browse files Browse the repository at this point in the history
#14554: WFS 2.0.0 writeTransaction UPDATE missing ValueReference - fix
  • Loading branch information
ahocevar committed Oct 23, 2023
2 parents e005ed5 + 89b07b9 commit 228145b
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/ol/format/WFS.js
Expand Up @@ -912,7 +912,8 @@ function writeProperty(node, pair, objectStack) {
const context = objectStack[objectStack.length - 1];
const version = context['version'];
const ns = WFSNS[version];
const name = createElementNS(ns, 'Name');
const tagName = version === '2.0.0' ? 'ValueReference' : 'Name';
const name = createElementNS(ns, tagName);
const gmlVersion = context['gmlVersion'];
node.appendChild(name);
writeStringTextNode(name, pair.name);
Expand Down
49 changes: 49 additions & 0 deletions test/browser/spec/ol/format/wfs.test.js
Expand Up @@ -1318,6 +1318,30 @@ describe('ol.format.WFS', function () {
});
expect(serialized).to.xmleql(parse(text));
});

it('should use <Name> tag for property names', () => {
const testFeature = new Feature();
testFeature.setId('12345');
testFeature.setProperties({
name: 'SampleFeature',
});
const testOptions = {
featureNS: 'http://foo',
featureType: 'FAULTS',
featurePrefix: 'foo',
gmlOptions: {srsName: 'EPSG:900913'},
};
const wfs = new WFS({version: '1.1.0'});
const serialized = wfs.writeTransaction(
[],
[testFeature],
[],
testOptions
);
const xmlSerializer = new XMLSerializer();
const xmlString = xmlSerializer.serializeToString(serialized);
expect(xmlString).contain('<Name>');
});
});

describe('when writing out a GetFeature request', function () {
Expand Down Expand Up @@ -1938,5 +1962,30 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
});
expect(serialized.firstElementChild).to.xmleql(parse(text));
});

it('should use <ValueReference> tag for property names', () => {
const testFeature = new Feature();
testFeature.setId('12345');
testFeature.setProperties({
name: 'SampleFeature',
});
const testOptions = {
featureNS: 'http://foo',
featureType: 'FAULTS',
featurePrefix: 'foo',
gmlOptions: {srsName: 'EPSG:900913'},
};
const wfs = new WFS({version: '2.0.0'});
const serialized = wfs.writeTransaction(
[],
[testFeature],
[],
testOptions
);
const xmlSerializer = new XMLSerializer();
const xmlString = xmlSerializer.serializeToString(serialized);
expect(xmlString).contain('<ValueReference>');
expect(xmlString).not.contain('<Name>');
});
});
});

0 comments on commit 228145b

Please sign in to comment.