User f34bba65a8
12-07-2006 10:59:30
Hi there
Well i'm trying to load a web page with the marvinsketch, i do a structure search and everything goes smooth. The problem is that then i have to return to the form with the molecule loaded on it. I have the string that marvinsketch created but cannot load on it.
Do I have to create a file with that string in order to load it as in the example?
There is not a way to load straight the string?
Thanks Ignasi
ChemAxon 7c2d26e5cf
12-07-2006 13:49:34
User f34bba65a8
12-07-2006 14:55:09
and this kind cannot load?
<?xml version="1.0" ?>
<MDocument>
<MChemicalStruct>
<molecule molID="m1">
<atomArray
atomID="a1 a2 a3 a4 a5 a6"
elementType="C C C C C C"
x2="-2.2750000953674316 -3.60866943641569 -3.60866943641569 -2.2750000953674316 -0.9413307543191731 -0.9413307543191731"
y2="1.8317005378506401 1.0616835972915997 -0.47835028382648126 -1.2483672243855217 -0.47835028382648126 1.0616835972915997"
/>
<bondArray>
<bond atomRefs2="a1 a2" order="1" />
<bond atomRefs2="a1 a6" order="1" />
<bond atomRefs2="a2 a3" order="2" />
<bond atomRefs2="a3 a4" order="1" />
<bond atomRefs2="a4 a5" order="1" />
<bond atomRefs2="a5 a6" order="2" />
</bondArray>
</molecule>
</MChemicalStruct>
</MDocument>
ChemAxon 7c2d26e5cf
12-07-2006 15:53:58
You have to encode special characters for JavaScript:
' (single quote),
" (double quotes),
\ (backslash) and
\n (end of line).
I have attached a JSP example which demonstrates how to convert these characters.
The converter method (from the example) is copied here:
Code: |
static String replaceString(String input, String query, String replacement) {
StringBuffer sb = new StringBuffer();
int from=0;
int pos;
while((pos = input.indexOf(query, from)) >= 0) {
if(pos > from) {
sb.append(input.substring(from,pos));
}
sb.append(replacement);
from = pos+query.length();
}
if(input.length() > from)
sb.append(input.substring(from,input.length()));
return sb.toString();
}
public static String convertForJavaScript(String input) {
String value = input;
//Converting Windows style string to UNIX style
value = replaceString(value, "\r\n", "\n");
//Converting Macintosh style string to UNIX style
value = replaceString(value, "\r", "\n");
//Converting special characters
value = replaceString(value, "\\", "\\\\");
value = replaceString(value, "\n", "\\n");
value = replaceString(value, "\"", "\\\"");
value = replaceString(value, "'", "\\'");
return value;
}
|
User f34bba65a8
12-07-2006 16:40:20
Thank you very much with the example and your translate solution it has been easy.
You have a really A++ service with this forum to help developers.