[prev in list] [next in list] [prev in thread] [next in thread]
List: jakarta-commons-dev
Subject: RE: [digester] minor patches for using a Digester as a ContentHandler...
From: "Scott Sanders" <ssanders () nextance ! com>
Date: 2002-07-31 17:15:03
[Download RAW message or body]
Excellent work, James. I like it a lot.
FYI, I have just recently being working on SAX-based 'substreams', and
this will allow Digester to fit right in.
Scott
> -----Original Message-----
> From: James Strachan [mailto:james_strachan@yahoo.co.uk]
> Sent: Wednesday, July 31, 2002 4:05 AM
> To: Jakarta Commons Developers
> Subject: [digester] minor patches for using a Digester as a
> ContentHandler...
>
>
> I've been working on a Betwixt library for Jelly, so that in
> Jelly we can do things like...
>
> <betwixt:parse var="mybean" rootClass="com.acme.Foo">
> <Foo id="123" name="cheese">
> <Bar>abc</Bar>
> <Bar>xyz</Bar>
> </Foo>
> </betwixt:parse>
>
> <j:forEach items="${mybean.bars}">
> ...
>
> Or a URI can be specified like this...
>
> <betwixt:parse var="mybean" rootClass="com.acme.Foo" uri="foo.xml"/>
>
>
> In the first case, I need to be able to use Betwixt's
> BeanReader, which is-a Digester in a new way that I'm not
> sure folks have done before.
>
> Digester implements the SAX ContentHandler interface, so you
> can just stream SAX events into digester rather than calling
> the one of the parse() methods. So in the first example, the
> <betwixt:parse> tag will fire all the SAX events of its body
> (the <Foo> and <Bar> elements) directly into the digester
> rather than calling a parse() method.
>
> I've made 2 minor patches to Digester so that it can be used
> properly as a SAX ContentHandler, rather than via the parse()
> methods...
>
> * ensured that configure() is called in the startDocument()
> to ensure that digester rules are properly configured before
> any XML events are consumed.
>
> * added a getRoot() property, so that after the SAX events
> have been fired into the digester, the calling code can
> extract the root object.
>
> So now folks should be able to use the digester (if they
> wish) like this...
>
> Digester digester = new MyDigester();
>
> // fire SAX events into the digester.
> digester.startDocument();
> ...
> digester.endDocument();
>
> // now retrieve the object that digester parsed
> Object object = digester.getRoot();
>
> James
>
> __________________________________________________
>
> 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
--
To unsubscribe, e-mail:
<mailto:commons-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail:
<mailto:commons-dev-help@jakarta.apache.org>
--
To unsubscribe, e-mail: <mailto:commons-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.org>
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic