11-29-2012 12:43 AM
Hi every one
I am displaying multiple pin point on Blackberry map and adding the label and description for the pin point,
in that sentence I am putting apostrophe (') symbols (ex- today's) so after that map is not displaying.
Please help me how to display that.
Thanks.
Solved! Go to Solution.
11-29-2012 02:48 AM
11-29-2012 04:47 AM
Hi I checked with \ it is not working
and how to use Unicode?
actually the description string I am getting from web services and in that I am getting the word like(today's) so I have to pass it as pin point description, how to do?
11-29-2012 05:47 AM
Can you give us a code snippet that demonstrates a failing case and a working case? Obviously we don't need to data from the Server, just debug that process and create a test that has the data hard coded in.
11-29-2012 06:27 AM
Hi Peter
Thanks for reply See this code is not working
for(int loca=0;loca<dealDetail1.locationcount;loca++)
{
String centerLt=(String) dealDetail1.lattitude.elementAt(loca);
String centerLon=(String) dealDetail1.longitude.elementAt(loca);
double longitude=Double.parseDouble(centerLon);
longitude=longitude*100000;
double latitude=Double.parseDouble(centerLt);
latitude=latitude*100000;
doc +="<location x='"+(int)longitude+"' y='"+(int)latitude+"' label='title' description='Today's' zoom='10' />";
}
doc +="</lbs>";
MapsArguments marg=new MapsArguments(MapsArguments.ARG_LOCATION_DOCUMENT, doc);
Invoke.invokeApplication(Invoke.APP_TYPE_MAPS, marg);
See Here
description='Today's' -> not working
description='Today\'s' -> not working
description='Todays' -> working
please help me what to do to work below code
description='Today's'
Thanks.
11-29-2012 08:37 AM
I am not familiar with this processing, but I strongly suspect your problem is related to XML handling of text strings.
You are in effect, passing in an XML document:
doc +="<location x='"+(int)longitude+"' y='"+(int)latitude+"' label='title' description='Today's' zoom='10' />";
The way this will look, when this code is actually executed, is that you will get a String like the following:
<location x='1234' y='3456' label='title' description='Today's' zoom='10' />
The problem is clear - the apostrophe in "Today's" is being used to delimit the description attribute, so now you have badly formed XML. The XML parser can't figure out that the first apostrophe is not actually the end of the string that you want to use as the description.
You have to change text that could confuse in XML in a similar way as you escape special characters when you code strings. For a String, to get a double apostrophe in a String, you have to code
String stringWithDoubleApostrophe = "\"";
So the "\" is being used to tell the compiler that the following character should be treated as is and not processed. .
In XML, you use a different mechanism, and in this case you would replace the apostrophe with (from memory) ""e;" (without the surrounding "). But the principle is the same. By converting the single apostrophe to ""e;" you are making sure that it is treated as part of the attribute and not processed.
Anyway, here is not the appropriate place for an XML lesson. Do some research yourself on this. But the short answer to your problem is that you need to encode any text you use as an XML attribute, to make sure that the XML parser can process it correctly when it contains characters that are treated specially in XML parsing.
11-29-2012 10:41 AM - edited 11-29-2012 10:43 AM
You would have to use entities.
var = "... description='Today\'s' zoom=..." means that var contains:
... description='Today's' zoom=...
This naturally leads to malformed XML.
Do this instead:
var = "... description='Today's' zoom=..."
Like all my posts, and mark them as the solution if it solved your problem.
My Website: Paolo Rodriguez