fixed KML parsing for cases where a line break is only before or after a CDATA block. r=bartvde (closes #2398)
git-svn-id: http://svn.openlayers.org/trunk/openlayers@10138 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -885,12 +885,18 @@ OpenLayers.Format.KML = OpenLayers.Class(OpenLayers.Format.XML, {
|
|||||||
child = children[i];
|
child = children[i];
|
||||||
if(child.nodeType == 1) {
|
if(child.nodeType == 1) {
|
||||||
grandchildren = child.childNodes;
|
grandchildren = child.childNodes;
|
||||||
if(grandchildren.length == 1 || grandchildren.length == 3) {
|
if(grandchildren.length >= 1 || grandchildren.length <= 3) {
|
||||||
var grandchild;
|
var grandchild;
|
||||||
switch (grandchildren.length) {
|
switch (grandchildren.length) {
|
||||||
case 1:
|
case 1:
|
||||||
grandchild = grandchildren[0];
|
grandchild = grandchildren[0];
|
||||||
break;
|
break;
|
||||||
|
case 2:
|
||||||
|
var c1 = grandchildren[0];
|
||||||
|
var c2 = grandchildren[1];
|
||||||
|
grandchild = c1.nodeType == 3 || c1.nodeType == 4 ?
|
||||||
|
c1 : c2;
|
||||||
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
default:
|
default:
|
||||||
grandchild = grandchildren[1];
|
grandchild = grandchildren[1];
|
||||||
|
|||||||
@@ -37,7 +37,7 @@
|
|||||||
|
|
||||||
function test_Format_KML_readCdataAttributes_20(t) {
|
function test_Format_KML_readCdataAttributes_20(t) {
|
||||||
t.plan(2);
|
t.plan(2);
|
||||||
var cdata = '<kml xmlns="http://earth.google.com/kml/2.0"><Document><Placemark><name><![CDATA[Pezinok]]></name><description><![CDATA[Full of text.]]></description><styleUrl>#rel1.0</styleUrl><Point> <coordinates>17.266666, 48.283333</coordinates></Point></Placemark></Document></kml>';
|
var cdata = '<kml xmlns="http://earth.google.com/kml/2.0"><Document><Placemark><name><![CDATA[Pezinok]]> </name><description><![CDATA[Full of text.]]></description><styleUrl>#rel1.0</styleUrl><Point> <coordinates>17.266666, 48.283333</coordinates></Point></Placemark></Document></kml>';
|
||||||
var features = (new OpenLayers.Format.KML()).read(cdata);
|
var features = (new OpenLayers.Format.KML()).read(cdata);
|
||||||
t.eq(features[0].attributes.description, "Full of text.", "Description attribute in cdata read correctly");
|
t.eq(features[0].attributes.description, "Full of text.", "Description attribute in cdata read correctly");
|
||||||
t.eq(features[0].attributes.name, "Pezinok", "title attribute in cdata read correctly");
|
t.eq(features[0].attributes.name, "Pezinok", "title attribute in cdata read correctly");
|
||||||
|
|||||||
Reference in New Issue
Block a user