commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Daryl Stultz" <da...@6degrees.com>
Subject Re: Jelly Questions
Date Wed, 12 Nov 2003 13:47:34 GMT
"Jakarta Commons Users List" <commons-user@jakarta.apache.org> writes:
>> More importantly I have a question in regards to the API 
>> JellyContext.runScript.  I would like to dynamically create a Jelly
>script 
>> that I can either pass in as a Document (dom4j or w3c) or a simple
>String to 
>> the JellyContext to execute. 
>
>None at the moment, but it is an often asked for, much desired feature.

Here's a method to do so that someone here helped me with:

	public Script compileScriptFromString(JellyContext context, String
scriptString) throws Throwable {
		XMLParser parser = new XMLParser();
		parser.setContext(context);
		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();
	}
Daryl Stultz
_____________________________________
6 Degrees Software and Consulting, Inc.
http://www.6degrees.com
mailto:daryl@6degrees.com


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Mime
View raw message