commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Paul Libbrecht <p...@ags.uni-sb.de>
Subject Re: [jelly] Jelly: run script from string
Date Mon, 15 Sep 2003 15:30:51 GMT
Daryl,

Not too sure how it was in beta 3. I would encourage you to check-out 
the latest version. It's pretty much un-moving these days.

Here is what I just managed to compile and which, if you test it, Dary, 
would feel perfect in the tree presumably (there's a few comitters on 
this list).
(ideally, a unit-test would be welcome).

On line 67 (or so), add import java.io.Reader;
(big deal)

On line 474, have added the following method:
     public Script compileScriptFromString(String scriptString)
		throws JellyException {
         XMLParser parser = getXMLParser();
         parser.setContext(this);
         Reader in = new java.io.StringReader(scriptString);
         Script script = null;
         try {
             script = parser.parse(in);
         } catch (IOException e) {
             throw new JellyException("Could not parse Jelly script",e);
         } catch (SAXException e) {
             throw new JellyException("Could not parse Jelly script",e);
         }
         try {in.close();} catch (IOException ex) {}
         return script.compile();
     }

which should be the one you need.

If people allow, I have also put try/catch around 
"System.getProperties()" put in the context-initialization... Will 
continue striving for applet runnability of commons things....
All in all, it gives the diff attached prodcued with:
"cvs diff src/java/org/apache/commons/jelly/JellyContext.java"
(would look forward to better instructions to make a "uni" diff)

Paul


On Lundi, sept 15, 2003, at 15:19 Europe/Paris, Daryl Stultz wrote:

> "Jakarta Commons Users List" <commons-user@jakarta.apache.org> writes:
>> Why not use all things with "Characters" ? (i.e. a StringReader ? A
>> reader is also accepted for an InputSource).
>
> That's what I was looking for but I can't seem to find it. Can you 
> give me
> an example of it? I'm using Jelly 1.0 beta 3. Is it in this version? I
> can't imaging them not providing an InputStream or InputSource, but
> nonetheless I can't find it (in Jelly, JellyContext or Script).
>
> This is probably asking too much: is there a way to make use of an 
> already
> parsed stream and compile the script from that? IOW, a SOAP service has
> already parsed the XML. Can I get a hold of that and compile is as a 
> Jelly
> script? Just an optimization - not really necessary.
>
> Daryl Stultz


Mime
View raw message