From 8e7c7d552842abc016e834afb6b11bbe80076069 Mon Sep 17 00:00:00 2001 From: ahocevar Date: Sun, 15 Feb 2009 21:58:20 +0000 Subject: [PATCH] Add WFSDescribeFeatureType format. This work is based on bartvde's owsformats sandbox. The unit tests were directly taken from that sandbox and only modified to reflect the slightly modified output format of this rewrite. Thanks to Bart for his initial work and the good discussion on the dev list. r=elemoine (closes #1202) git-svn-id: http://svn.openlayers.org/trunk/openlayers@8858 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf --- lib/OpenLayers.js | 1 + .../Format/WFSDescribeFeatureType.js | 192 +++++++++ tests/Format/WFSDescribeFeatureType.html | 375 ++++++++++++++++++ tests/list-tests.html | 1 + 4 files changed, 569 insertions(+) create mode 100644 lib/OpenLayers/Format/WFSDescribeFeatureType.js create mode 100644 tests/Format/WFSDescribeFeatureType.html diff --git a/lib/OpenLayers.js b/lib/OpenLayers.js index e3803fdbda..783feec5db 100644 --- a/lib/OpenLayers.js +++ b/lib/OpenLayers.js @@ -212,6 +212,7 @@ "OpenLayers/Format/KML.js", "OpenLayers/Format/GeoRSS.js", "OpenLayers/Format/WFS.js", + "OpenLayers/Format/WFSDescribeFeatureType.js", "OpenLayers/Format/WKT.js", "OpenLayers/Format/OSM.js", "OpenLayers/Format/GPX.js", diff --git a/lib/OpenLayers/Format/WFSDescribeFeatureType.js b/lib/OpenLayers/Format/WFSDescribeFeatureType.js new file mode 100644 index 0000000000..abc1c1e557 --- /dev/null +++ b/lib/OpenLayers/Format/WFSDescribeFeatureType.js @@ -0,0 +1,192 @@ +/** + * @requires OpenLayers/Format/XML.js + * + * Class: OpenLayers.Format.WFSDescribeFeatureType + * Read WFS DescribeFeatureType response + * + * Inherits from: + * - + */ +OpenLayers.Format.WFSDescribeFeatureType = OpenLayers.Class( + OpenLayers.Format.XML, { + + /** + * Property: namespaces + * {Object} Mapping of namespace aliases to namespace URIs. + */ + namespaces: { + xsd: "http://www.w3.org/2001/XMLSchema" + }, + + /** + * Constructor: OpenLayers.Format.WFSDescribeFeatureType + * Create a new parser for WFS DescribeFeatureType responses. + * + * Parameters: + * options - {Object} An optional object whose properties will be set on + * this instance. + */ + initialize: function(options) { + OpenLayers.Format.XML.prototype.initialize.apply(this, [options]); + }, + + /** + * Property: readers + * Contains public functions, grouped by namespace prefix, that will + * be applied when a namespaced node is found matching the function + * name. The function will be applied in the scope of this parser + * with two arguments: the node being read and a context object passed + * from the parent. + */ + readers: { + "xsd": { + "schema": function(node, obj) { + var complexTypes = []; + var customTypes = {}; + var schema = { + complexTypes: complexTypes, + customTypes: customTypes + }; + + this.readChildNodes(node, schema); + + var attributes = node.attributes; + var attr, name; + for(var i=0; i + + + + + + + \ No newline at end of file diff --git a/tests/list-tests.html b/tests/list-tests.html index e382618920..790d8077aa 100644 --- a/tests/list-tests.html +++ b/tests/list-tests.html @@ -54,6 +54,7 @@
  • Format/Filter.html
  • Format/Filter/v1_0_0.html
  • Format/Filter/v1_1_0.html
  • +
  • Format/WFSDescribeFeatureType.html
  • Format/WKT.html
  • Format/WMC.html
  • Format/WMC/v1_1_0.html