From 85e9e309081df23270c7927e9c899f49468e550b Mon Sep 17 00:00:00 2001 From: crschmidt Date: Fri, 21 Sep 2007 01:14:25 +0000 Subject: [PATCH] Extract attributes wrapped in CDATA, by adding an additional nodeType. (See #1007) This closes the last remaining bug for 2.5RC3 -- I'll release that in the morning unless anything new pops up. git-svn-id: http://svn.openlayers.org/trunk/openlayers@4429 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf --- lib/OpenLayers/Format/GML.js | 3 ++- lib/OpenLayers/Format/KML.js | 4 ++-- tests/Format/test_GML.html | 5 +++-- tests/Format/test_KML.html | 9 +++++++++ 4 files changed, 16 insertions(+), 5 deletions(-) diff --git a/lib/OpenLayers/Format/GML.js b/lib/OpenLayers/Format/GML.js index 36d8f5352c..efe1f9ef31 100644 --- a/lib/OpenLayers/Format/GML.js +++ b/lib/OpenLayers/Format/GML.js @@ -453,7 +453,8 @@ OpenLayers.Format.GML = OpenLayers.Class(OpenLayers.Format.XML, { grandchildren = child.childNodes; if(grandchildren.length == 1) { grandchild = grandchildren[0]; - if(grandchild.nodeType == 3) { + if(grandchild.nodeType == 3 || + grandchild.nodeType == 4) { name = (child.prefix) ? child.nodeName.split(":")[1] : child.nodeName; diff --git a/lib/OpenLayers/Format/KML.js b/lib/OpenLayers/Format/KML.js index 3dd4db14b5..2f64c23b3b 100644 --- a/lib/OpenLayers/Format/KML.js +++ b/lib/OpenLayers/Format/KML.js @@ -326,7 +326,7 @@ OpenLayers.Format.KML = OpenLayers.Class(OpenLayers.Format.XML, { grandchildren = child.childNodes; if(grandchildren.length == 1) { grandchild = grandchildren[0]; - if(grandchild.nodeType == 3) { + if(grandchild.nodeType == 3 || grandchild.nodeType == 4) { name = (child.prefix) ? child.nodeName.split(":")[1] : child.nodeName; @@ -638,4 +638,4 @@ OpenLayers.Format.KML = OpenLayers.Class(OpenLayers.Format.XML, { }, CLASS_NAME: "OpenLayers.Format.KML" -}); \ No newline at end of file +}); diff --git a/tests/Format/test_GML.html b/tests/Format/test_GML.html index f142d01e96..601e9c7dc7 100644 --- a/tests/Format/test_GML.html +++ b/tests/Format/test_GML.html @@ -147,13 +147,14 @@ t.eq(data[0].geometry.components.length, 2, "rings length correct"); } function test_Format_GML_read_attributes(t) { - t.plan(1); + t.plan(2); var parser = new OpenLayers.Format.GML(); data = parser.read(test_content[0]); t.eq(data[0].attributes['NAME'], "WY", "Simple Attribute data is read correctly."); + t.eq(data[0].attributes['LONGNAME'], "Wyoming", "Attribute data is read from CDATA node correctly."); } - var test_content = ['\n\n \n \n -1254041.389711702250906.9515983529\n -634517.1199908922762236.2940800377\n \n \n \n \n -634517.11999089224,691849.77929356066,0 -653761.64509297756,471181.53429472551,0 -673343.60852865304,250906.9515983529,0 -1088825.734430399,299284.85108220269,0 -1254041.3897117018,324729.27754874947,0 -1235750.4212498858,434167.33911316615,0 -1190777.7803201093,704392.96327195223,0 -1181607.835811228,762236.29408003774,0 -634517.11999089224,691849.77929356066,0\n WY\n \n \n\n', + var test_content = ['\n\n \n \n -1254041.389711702250906.9515983529\n -634517.1199908922762236.2940800377\n \n \n \n \n -634517.11999089224,691849.77929356066,0 -653761.64509297756,471181.53429472551,0 -673343.60852865304,250906.9515983529,0 -1088825.734430399,299284.85108220269,0 -1254041.3897117018,324729.27754874947,0 -1235750.4212498858,434167.33911316615,0 -1190777.7803201093,704392.96327195223,0 -1181607.835811228,762236.29408003774,0 -634517.11999089224,691849.77929356066,0\n WY\n \n \n \n\n', '