On Lundi, sept 15, 2003, at 09:47 Europe/Paris, Sylvain Chambon wrote:

On Fri, 12 Sep 2003 14:18:46 -0400, Daryl Stultz <[EMAIL PROTECTED]> wrote:

I'd like to execute a script from a raw string (perhaps it comes from a
database). How can I do this? It seems all the runScript methods take a
url or a file.

If there's an easy way I didn't find it... What I did was extend JellyContext in order to have a compileScript method that can use a String (which is fairly easy as what the parser really needs is an InputStream -- give it a ByteArrayInputStream taken from your String's bytes).

Why not use all things with "Characters" ? (i.e. a StringReader ? A reader is also accepted for an InputSource).


Then you have a Script object which you can call the run(JellyContext, XMLOutput) method on.

I use this hack extensively (in a presentation framework that is made of myriads of tiny scripts assembled together at runtime) and have done for a few months now; it may not be the "cleanest" way to do it but it works fine so far. The major problem would be keeping track of changes to the Jelly APIs, in particular JellyContext and Script.

There hasn't been much changes since March so it might be good you submit the addition of the named method as a patch ?


Paul


--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to