-1

I am using the JAK library to generate some KML and creating a style. For some reason the URL is being malformed and its turning '&' into '&amp'

document.createAndAddStyle().withId("styleTest").createAndSetIconStyle().withScale(1.399999976158142).withIcon(new Icon().withHref("http://chart.apis.google.com/chart?chst=d_map_pin_letter&chld=%E2%80%A2|" + ffffff ));

Result

http://chart.apis.google.com/chart?chst=d_map_pin_letter&chld=%E2%80%A2|

What I need

http://chart.apis.google.com/chart?chst=d_map_pin_letter&chld=%E2%80%A2|

I didnt think it was java causing the problem but I could be wrong.

The value seems to be correct all the way up until its written using .marshall()

I dont think cdata will work

 <Style id="randomColorIcon">
            <IconStyle>
                <scale>1.399999976158142</scale>
                <heading>0.0</heading>
                <Icon>
                    <href>http://chart.apis.google.com/chart?chst=d_map_pin_letter&amp;chld=%E2%80%A2|ff0000</href>
                    <refreshInterval>0.0</refreshInterval>
                    <viewRefreshTime>0.0</viewRefreshTime>
                    <viewBoundScale>0.0</viewBoundScale>
                </Icon>
            </IconStyle>
        </Style>

Cdata approach results in

 <href>&lt;![CDATA[http://chart.apis.google.com/chart?chst=d_map_pin_letter&amp;chld=%E2%80%A2|ff0000]]&gt;</href>


String high = "<![CDATA[http://chart.apis.google.com/chart?chst=d_map_pin_letter&chld=%E2%80%A2|" + ((PropertiesObj)this.prop.get(2)).maxColor;
user3032973
  • 415
  • 2
  • 8
  • 26
  • 1
    Bare ampersands are invalid in XML, they need to be escaped to `&` http://stackoverflow.com/questions/1328538/how-do-i-escape-ampersands-in-xml/1328557#1328557 – geocodezip Dec 05 '13 at 22:01
  • 1
    [CDATA might work also](http://stackoverflow.com/questions/1328538/how-do-i-escape-ampersands-in-xml/1328563#1328563) – geocodezip Dec 05 '13 at 22:06
  • updated with kml value. I dont think cdata will work for an href – user3032973 Dec 05 '13 at 22:10
  • I attempting to replace the & in the url to & but it just replaced it with &amp;. I also tried just amp; but that didnt work either. Nor did &amp;... – user3032973 Dec 05 '13 at 22:13
  • Does anyone have ideas on why I cannot put an & in the href on a XML – user3032973 Dec 09 '13 at 14:46

1 Answers1

0

This seems to work with JAK->KML

document.createAndAddStyle().withId("highPin").createAndSetIconStyle().withScale(1.399999976158142).withIcon(new Icon().withHref("http://chart.apis.google.com/chart?chst=d_map_pin_letter&chld=%E2%80%A2|" + ((PropertiesObj)this.prop.get(2)).maxColor));
user3032973
  • 415
  • 2
  • 8
  • 26