From c667e9a147d6fee3bdcc457f5cbf8d0d3fd29d7f Mon Sep 17 00:00:00 2001 From: Bart van den Eijnden Date: Fri, 13 Jan 2012 13:05:20 +0100 Subject: [PATCH] ignore empty subject tags in CSWGetRecords parser --- lib/OpenLayers/Format/CSWGetRecords/v2_0_2.js | 4 +++- tests/Format/CSWGetRecords/v2_0_2.html | 5 ++++- tests/Format/CSWGetRecords/v2_0_2.js | 2 ++ 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/OpenLayers/Format/CSWGetRecords/v2_0_2.js b/lib/OpenLayers/Format/CSWGetRecords/v2_0_2.js index 8ad98a25aa..9cb6427ff9 100644 --- a/lib/OpenLayers/Format/CSWGetRecords/v2_0_2.js +++ b/lib/OpenLayers/Format/CSWGetRecords/v2_0_2.js @@ -262,7 +262,9 @@ OpenLayers.Format.CSWGetRecords.v2_0_2 = OpenLayers.Class(OpenLayers.Format.XML, dc_element[attrs[i].name] = attrs[i].nodeValue; } dc_element.value = this.getChildValue(node); - obj[name].push(dc_element); + if (dc_element.value != "") { + obj[name].push(dc_element); + } } }, "dct": { diff --git a/tests/Format/CSWGetRecords/v2_0_2.html b/tests/Format/CSWGetRecords/v2_0_2.html index 5fda134bb1..07e1b96ba3 100644 --- a/tests/Format/CSWGetRecords/v2_0_2.html +++ b/tests/Format/CSWGetRecords/v2_0_2.html @@ -41,7 +41,7 @@ function test_read(t) { - t.plan(16); + t.plan(17); var obj = format.read(csw_response); @@ -65,6 +65,9 @@ t.eq(testRecord.type, "BriefRecord", "check value for record.type"); t.eq(testRecord.title, [{value:"Sample title"}], "check value for record.title"); + // test empty subject + t.eq(testRecord.subject, [], "Empty subject tags are ignored"); + //test bbox t.eq(testRecord.BoundingBox.length, 2, "object contains 2 BoundingBoxes"); var bbox = testRecord.BoundingBox[0]; diff --git a/tests/Format/CSWGetRecords/v2_0_2.js b/tests/Format/CSWGetRecords/v2_0_2.js index a7616714ee..6a57e11eeb 100644 --- a/tests/Format/CSWGetRecords/v2_0_2.js +++ b/tests/Format/CSWGetRecords/v2_0_2.js @@ -21,6 +21,8 @@ var csw_response = '' + '895ac38b-7aef-4a21-b593-b35a6fc7bba9' + 'Sample title' + + '' + + '' + '' + '156 -3' + '37 83' +