Re: [digester] multiple parses from one inputstream

2006-05-24 Thread luc . maisonobe
Selon Simon Kitching [EMAIL PROTECTED]:


 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.

I think such a behaviour would be wrong in the general case, as it would break
detection of malformed documents.

There would also be problems restarting the parser for the next message.

The need here seems to have one data stream holding a sequence of independent
XML documents, I would suggest using some kind of wrapper to split the stream
at messages boundaries and providing each message individually.

Luc


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



Re: [digester] multiple parses from one inputstream

2006-05-23 Thread Simon Kitching
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]