On Tue, 2006-05-23 at 18:12 -0500, David Durham wrote:
> Hi all,
> 
> I'd like to use Digester to parse multiple XML messsages being passed 
> from a server to a client.  The parse method hangs until I close the 
> server output stream.
> 
> Anyway to signal to Digester.parse(InputStream) that it should return 
> without having reached the end of an inputstream?  Or do I have chose a 
> different parse method?

Digester just calls someXmlParser.parse(). If you can find an xml parser
that invokes endDocument then returns when it reaches the end of the
root element then Digester should work fine with that. I'm not aware of
any such parser though.

Maybe you could try writing some kind of filter for a standard xml
parser to make a parser act like that.

There might be a way to modify Digester itself to detect the end of the
root element (fairly simple), then to forcibly terminate the xml parser
(tricky). I'm not sure it's a stable solution, though, because there is
no rule against a SAX parser reading its input in chunks, then firing
off the relevant SAX events. Stopping the parser when the endElement
occurs for the root element therefore doesn't guarantee that no
"read-ahead" has occurred.

I would suggest using some other kind of string sequence in your input
stream to separate xml documents. You could then read a document into a
string buffer and run the parser on that. If the docs are large, you
could alternatively write a custom InputStream that indicates EOF when
it reaches your custom marker.

If you do come up with a clever solution for this, please let us know as
it's something that has been asked a few times.

Regards,

Simon



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

Reply via email to