commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "James Strachan" <james_strac...@yahoo.co.uk>
Subject Re: [jelly] Eval complex xml pipline?
Date Tue, 25 Feb 2003 18:08:01 GMT
From: "Sean Brandt" <sean@fuzzymagic.com>
> On Tuesday, February 25, 2003, at 11:45 AM, James Strachan wrote:
>
> > [snip]
>
> > XMLOutput uses aggregation to work with any SAX ContentHandler or
> > LexicalHandler so no need to derive.
> >
> > XMLParser is a ContentHandler and LexicalHandler. So you could do
> > something
> > like this in pseudo code
> >
> > public class EvalTag extends TagSupport {
> >     private String var;
> >
> >     public void doTag(XMLOutput output) throws JellyTagException {
> >         XMLParser parser = new XMLParser();
> >         XMLOutput newOutput = new XMLOutput( parser );
> >
> >         // invoke body, redirecting SAX events into the Jelly parser
> >         invokeBody( newOutput );
> >         Script script = parser.getScript();
> >
> >         if (var != null) {
> >             context.setVariable(var, script);
> >         }
> >         else {
> >             // lets just execute the new script
> >             script.run(context, output);
> >         }
> >     }
> > }
> >
> Pretty much exactly what I'd done with my previous message,

Agreed.

> though I'm
> still having an issue with variables set in the body's script not being
> visible to the parent script.

One thing I missed off is the context should be passed into the XMLParser.
So

    XMLParser parser = new XMLParser();
    parser.setContext(context);
    ...

should do the trick?

BTW have you also got a JDOM tag library? If so do you fancy submitting it
for inclusion in the Jelly project?

James
-------
http://radio.weblogs.com/0112098/

__________________________________________________
Do You Yahoo!?
Everything you'll ever need on one web page
from News and Sport to Email and Music Charts
http://uk.my.yahoo.com

Mime
View raw message