|
Problem with quotes in image map |
Posted by Michael Opitz on Jun-10-2010 16:18 |
|
Hi Peter,
I have a problem with image-map creation.
I want to create my own tooltip for my layer but when this tooltip contains a double quote (") then my image map breaks and the tooltip ends with this quote. But if I mask this quote with " then I see """ in the tooltip. How do I have to mask this quote?
I found out, that I have to urlEncode this for the href-part, but what do I have to do for the title="..."?
Regards,
Michael |
Re: Problem with quotes in image map |
Posted by Peter Kwan on Jun-11-2010 00:02 |
|
Hi Michael,
If the text in the image map is inserted by ChartDirector with template substitution, ChartDirector will automatically escape the double quotes. For example, suppose you have title="{xLabel}", and some of the x-axis labels contain double quotes, the tooltip will continue to work normally, because ChartDirector will escape the double quotes in the x-axis label when substituted into {xLabel}.
However, if your code specify the text directly, your code would need to escape any characters that need to be escaped.
For example, suppose you use:
title="bbb" aaa="{xLabel}"
It is impossible to know if the double quotes in the above should be escaped. The above can mean two attributes "title" and "aaa". It can also mean one title attribute only, with the "aaa=" being part of the tooltip text. ChartDirector will simply pass your text directly to the output. If some of the double quotes should be escape, you would need to escape it with your own code. You may refer to the HTML documentation on which characters need to be escaped and how to escape them. For example, you may use:
title="bbb" aaa="{xLabel}"
Hope this can help.
Regards
Peter Kwan |
Re: Problem with quotes in image map |
Posted by Michael Opitz on Jun-11-2010 15:02 |
|
Thank you for your answert. But I know this already. The problem I have is how would I have to escape something like this:
title="ChartDirector is "cool" & "hot"" ? If I escape the " with " then my tooltip looks like this:
ChartDirector is "cool" & "hot"".
And even worse, if I would put this into the href part for hotSpot data It will spoil the hotSpot data completely because & is the divider for parameters. The question is not: do I have to mask them, but how do I have to mask them. How does ChartDirector does the masking for ", '&' and '=' ? I tried to urlEncode my values, but then ChartDirector will decode the characters, but spaces will remain '+'.
Thank you for your patience,
Michael |
Re: Problem with quotes in image map |
Posted by Michael Opitz on Jun-11-2010 15:14 |
|
Hi Peter,
another Problem is, that your forum-software converts the masks, so you will not be able to see the difference, as your explanation also looks exactly the same.
so I try again (please ignore the _ character):
title="ChartDirector is "cool" & "hot"" ? If I escape the " with &_quot_; then my tooltip looks like this:
ChartDirector is &_quot_;cool&_quot_; & &_quot_;hot&_quot_;.
And even worse, if I would put this into the href part for hotSpot data It will spoil the hotSpot data completely because & is the divider for parameters. The question is not: do I have to mask them, but how do I have to mask them. How does ChartDirector does the masking for ", '&' and '=' ? I tried to urlEncode my values, but then ChartDirector will decode the characters, but spaces will remain '+'.
Thank you for your patience,
Michael |
Re: Problem with quotes in image map |
Posted by Peter Kwan on Jun-12-2010 00:16 |
|
Hi Michael,
To understand how to escape the text correctly, you would need to know what is URL and what is HTML.
A URL is something you enter in the browser address bar. For example, when you access this forum, you may type "http://www.chartdir.com" in the browser address bar. That part is the URL. Some characters are not valid in URL. They must be escaped according to URL rules.
If you write a HTML web page, you need to be aware that some characters are not legal in HTML. They should be escaped according to HTML rules.
If you create a URL as a href attribute in HTML, you should escape your URL according to URL rules. This ensures the URL is valid. Then you should be escape the already escaped URL using HTML rules. This make sure the HTML is valid.
If you enter something in the title attribute, it is in HTML, but not a URL. (The title attribute is not an URL. The href attribute is an URL.) So you should only escape it using HTML rules, not with URL rules.
For your information, an isolated '&' is an invalid character in HTML, although a lot of browsers will tolerate it. If you use [ChartDirector is "cool" & "hot"] in the title attribute, it should be escaped to:
ChartDirector is &_quot_;cool&_quot_; &_amp_; &_quot_;hot&_quot_;.
However, I think the following will also work, as many browsers can tolerate the illegal HTML.
ChartDirector is &_quot_;cool&_quot_; & &_quot_;hot&_quot_;.
The above is normal for a tooltip. If it is used in HTML and interpreted by a browser, the browser will understand what these escape sequences mean and will display the tooltips correctly.
On the other hand, if you use [ChartDirector is "cool" & "hot"] in the href attribute, you should escape it with URL rules first, so it becomes:
ChartDirector%20is%20"cool"%20%26%20"hot"
(Some people may use a '+' character to escape the space instead of %20.)
Then you should escape it in HTML, so it becomes:
ChartDirector%20is%20&_quot_;cool&_quot_;%20%26%20&_quot_;hot&_quot_;
Note that the above assumes you are writing a web application, and you are using HTML, and the image map and the URL is handled by a browser. If it is not a HTML application, the above may not apply.
Hope this can help.
Regards
Peter Kwan |
Re: Problem with quotes in image map |
Posted by Michael Opitz on Dec-01-2010 18:26 |
|
Hi Peter,
sorry to warm this thread up, but I ran into this problem again:
If I write "ChartDirector is &_quot_;cool&_quot_; &_amp_; &_quot_;hot&_quot_;" into the title attribute, then the ChartViewer will display the same in java. Do I have to convert it back manually?
Regards,
Michael |
Re: Problem with quotes in image map |
Posted by Peter Kwan on Dec-02-2010 01:20 |
|
Hi Michael,
Since you mentioned about the "ChartViewer", I assume you are writing a Java desktop application.
The &_quot_; is HTML, and is handled by the browser. In a desktop application, the &_quot_; is handled by the standard Java tooltip feature, which may or may not support HTML depends on know you set up the tooltip.
Anyway, ChartDirector needs a way to escape special charaters (like the double quote character), so it does support a limited method to escape characters. The syntax ChartDirector support is &_#34_;. You may use &_#xxxx_; in general, in which xxx is the unicode code point of the character.
So for your case, there are two methods:
(a) You may &_#xxx_; to escape the characters. This method works is supported by ChartViewer in desktop applications, and also supported by browsers.
(b) You may configure the Java tooltip to support HTML by using "<html>.... myTooltip ....</html>". Please refer to Java documentation for details.
Hope this can help.
Regards
Peter Kwan |
|