MiguelEspinozaMedina / javaapiforkml

Automatically exported from code.google.com/p/javaapiforkml
0 stars 0 forks source link

CDATA tag in description problem #37

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
* What steps will reproduce the problem?
Placemark placemark = folder.createAndAddPlacemark();
placemark.withDescription("<![CDATA[The <b>end</b>.]]>");

* What is the expected output? What do you see instead?
Expected : <![CDATA[The <b>end</b>.]]>
What I have instead : &lt;![CDATA[The &lt;b&gt;end&lt;/b&gt;.]]&gt;
...wich output on the placemark's description something like : end.]]>

* What version of the product are you using? On what operating system?
jak 2.2.0-SNAPSHOT using maven and Google Maps Javascript API v3

This issue is quite annoying when you want embed rich HTML in description 
ballons

Original issue reported on code.google.com by inos...@gmail.com on 22 Nov 2011 at 9:05

GoogleCodeExporter commented 9 years ago
Have the same problem. Any solution yet?

Original comment by bor...@gmail.com on 22 Dec 2011 at 10:08

GoogleCodeExporter commented 9 years ago
I have the same problem.  Any solution Yet?

Original comment by John.P.O...@gmail.com on 9 Feb 2012 at 4:08

GoogleCodeExporter commented 9 years ago
Having this problem as well.

Original comment by camj...@gmail.com on 18 Jul 2012 at 10:29

GoogleCodeExporter commented 9 years ago
The cause of this issue is that JAXB is unable to deal CDATA content.
To solve this issues I had to patch the Kml.java source file as specified in 
http://stackoverflow.com/questions/1506663/can-i-force-jaxb-not-to-convert-into-
quot-for-example-when-marshalling-to.

So I added a custom CharacterEscapeHandler and modified the createMarshaller() 
method adding the following lines:

            m.setProperty("jaxb.encoding", "Unicode");
            m.setProperty("com.sun.xml.bind.marshaller.CharacterEscapeHandler", new NullCharacterEscapeHandler());

It works. I do not know if there is any side effect of this patch.

Original comment by alberto....@gmail.com on 16 Nov 2012 at 2:28

GoogleCodeExporter commented 9 years ago
Following on from Alberto's comment, attached is a MyKML.java which overrides 
the needed methods. I used this as I could not be bothered playing with my 
maven repo and modifying the KML.java.
Feel free to use

Original comment by pwat...@gmail.com on 2 Jul 2013 at 5:36

Attachments: