On Sat, 14 Feb 2004 20:30:52 -0500, "Thomas DeWeese" <[EMAIL PROTECTED]> said: > Fabio Biscaro wrote: > > > > Is there a way to check (parse) javascript syntax before executing in SVG? > > This is really a rhino question, I believe this possible (I think > it is phrased as 'compiling').
If you have a standalone JS file, you can run it against various JavaScript shells, like Rhino shell which is inculded in JS distribution that comes with Batik, see http://www.mozilla.org/rhino/shell.html, js shell from SpiderMonkey, http://www.mozilla.org/js/ or even jscript executable or something available on Windows. If they report only runtime errors, then your script has the correct syntax. To check syntax of scripts embedded in SVG sources requires to extract all scripts from XML and then run then run them through the shells or call Rhino API directly. But note that such syntax checks would not catch a common source of runtime errors which is mistyped variable names. The compilation phase in JS assumes that all undeclared global properties are names of host objects provided by environment. > If you really just want to check if > some javascript is failing you can eval it in a try catch block > but it will actually run in that case. In JS this can be done through simple var script = null; try { var script = Script(string_with_script); } catch (e) { // report error } if (script) { // run compild script script(); } Regards, Igor --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]