3 <script src="../../lib/OpenLayers.js"></script>
5 function test_wfs_update_node(t) {
7 var expected = readXML("Update");
8 var updateFeature = new OpenLayers.Feature.Vector(
9 new OpenLayers.Geometry.Point(1,2),
11 updateFeature.fid = "fid.42";
12 updateFeature.state = OpenLayers.State.UPDATE;
13 var format = new OpenLayers.Format.WFS({
14 'featureNS':'http://www.openplans.org/topp',
15 'featureName': 'states',
16 'geometryName': 'the_geom',
17 'featurePrefix': 'topp'
19 var updateNode = format.update(updateFeature);
20 t.xml_eq(updateNode, expected, "update node matches expected XML value.");
21 var format = new OpenLayers.Format.WFS({
22 'featurePrefix': 'topp'
23 }, {options:{typename: 'states', 'featureNS': 'http://www.openplans.org/topp', 'geometry_column': 'the_geom' }});
24 var updateNode = format.update(updateFeature);
25 t.xml_eq(updateNode, expected, "update node matches expected XML value.");
27 function test_wfs_delete_node(t) {
29 var expected = readXML("Delete");
30 var feature = new OpenLayers.Feature.Vector(new OpenLayers.Geometry.Point(0,0));
31 feature.state = OpenLayers.State.DELETE;
32 feature.fid = "fid.37";
33 var format = new OpenLayers.Format.WFS({
34 'featureNS':'http://www.openplans.org/topp',
35 'featureName': 'states',
36 'featurePrefix': 'topp'
38 var deleteNode = format.remove(feature);
39 t.xml_eq(deleteNode, expected, "delete node matches expected XML value.");
40 var format = new OpenLayers.Format.WFS({
41 'featurePrefix': 'topp'
42 }, {options:{typename: 'states', 'featureNS': 'http://www.openplans.org/topp'}});
43 var deleteNode = format.remove(feature);
44 t.xml_eq(deleteNode, expected, "delete node matches expected XML value.");
46 function readXML(id) {
47 var xml = document.getElementById(id).firstChild.nodeValue;
48 return new OpenLayers.Format.XML().read(xml).documentElement;
55 <wfs:Update xmlns:wfs="http://www.opengis.net/wfs" typeName="topp:states" xmlns:topp="http://www.openplans.org/topp">
57 <wfs:Name>the_geom</wfs:Name>
59 <gml:Point xmlns:gml="http://www.opengis.net/gml">
60 <gml:coordinates decimal="." cs="," ts=" ">1,2</gml:coordinates>
65 <wfs:Name>foo</wfs:Name>
66 <wfs:Value>bar</wfs:Value>
68 <ogc:Filter xmlns:ogc="http://www.opengis.net/ogc">
69 <ogc:FeatureId fid="fid.42"/>
74 <wfs:Delete xmlns:wfs="http://www.opengis.net/wfs" typeName="topp:states" xmlns:topp="http://www.openplans.org/topp">
75 <ogc:Filter xmlns:ogc="http://www.opengis.net/ogc">
76 <ogc:FeatureId fid="fid.37"/>