From b61e29d92003e5e2de8f6ddf9f31953131f7514c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Lemoine?= Date: Mon, 9 May 2011 07:52:39 +0000 Subject: [PATCH] CSWGetRecords format additions for parsing GeoNetwork specific fields, p=fvanderbiest, r=bartvde,me (closes #2961) git-svn-id: http://svn.openlayers.org/trunk/openlayers@11959 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf --- lib/OpenLayers/Format/CSWGetRecords/v2_0_2.js | 18 +++++++++++++++--- tests/Format/CSWGetRecords/v2_0_2.html | 8 ++++++-- tests/Format/CSWGetRecords/v2_0_2.js | 4 ++++ 3 files changed, 25 insertions(+), 5 deletions(-) diff --git a/lib/OpenLayers/Format/CSWGetRecords/v2_0_2.js b/lib/OpenLayers/Format/CSWGetRecords/v2_0_2.js index e17c800d03..4c460da44b 100644 --- a/lib/OpenLayers/Format/CSWGetRecords/v2_0_2.js +++ b/lib/OpenLayers/Format/CSWGetRecords/v2_0_2.js @@ -27,13 +27,14 @@ OpenLayers.Format.CSWGetRecords.v2_0_2 = OpenLayers.Class(OpenLayers.Format.XML, * {Object} Mapping of namespace aliases to namespace URIs. */ namespaces: { - xlink: "http://www.w3.org/1999/xlink", - xsi: "http://www.w3.org/2001/XMLSchema-instance", csw: "http://www.opengis.net/cat/csw/2.0.2", dc: "http://purl.org/dc/elements/1.1/", dct: "http://purl.org/dc/terms/", + geonet: "http://www.fao.org/geonetwork", + ogc: "http://www.opengis.net/ogc", ows: "http://www.opengis.net/ows", - ogc: "http://www.opengis.net/ogc" + xlink: "http://www.w3.org/1999/xlink", + xsi: "http://www.w3.org/2001/XMLSchema-instance" }, /** @@ -233,6 +234,17 @@ OpenLayers.Format.CSWGetRecords.v2_0_2 = OpenLayers.Class(OpenLayers.Format.XML, var record = {type: "Record"}; this.readChildNodes(node, record); obj.records.push(record); + }, + "*": function(node, obj) { + var name = node.localName || node.nodeName.split(":").pop(); + obj[name] = this.getChildValue(node); + } + }, + "geonet": { + "info": function(node, obj) { + var gninfo = {}; + this.readChildNodes(node, gninfo); + obj.gninfo = gninfo; } }, "dc": { diff --git a/tests/Format/CSWGetRecords/v2_0_2.html b/tests/Format/CSWGetRecords/v2_0_2.html index 0556ba05c5..5fda134bb1 100644 --- a/tests/Format/CSWGetRecords/v2_0_2.html +++ b/tests/Format/CSWGetRecords/v2_0_2.html @@ -41,10 +41,10 @@ function test_read(t) { - t.plan(14); + t.plan(16); var obj = format.read(csw_response); - + var searchStatus = obj.SearchStatus; var searchResults = obj.SearchResults; var records = obj.records; @@ -72,6 +72,10 @@ t.eq(bbox.crs, "::Lambert Azimuthal Projection", "check value for BoundingBox.crs"); t.eq(bbox.value, [156, -3, 37, 83], "check value for record.BoundingBox"); + // test gninfo + testRecord = records[1]; + t.ok(testRecord.gninfo, "object contains gninfo properties"); + t.eq(testRecord.gninfo.schema, "iso19139", "check value for schema property in record.gninfo"); } diff --git a/tests/Format/CSWGetRecords/v2_0_2.js b/tests/Format/CSWGetRecords/v2_0_2.js index c5fe31b9bd..a7616714ee 100644 --- a/tests/Format/CSWGetRecords/v2_0_2.js +++ b/tests/Format/CSWGetRecords/v2_0_2.js @@ -37,6 +37,10 @@ var csw_response = '51.1 -34.6' + '-17.3 38.2' + '' + + '' + + '859' + + 'iso19139' + + '' + '' + '' + ''