If you wrote an InputSource, then you would have had to write your own
input stream to go with it (or you should have :-) Given that, you will
have to have your input stream understand when the end of the file is
reached. The parser cannot do that, since it is legal to have lots of stuff
after the end of the root element. If there is some marker in the stream
that will indicate that the end of the document is reached, your input
stream class can indicate an end of input and cause everything to work
normally. The next time parse() is called, your input source just creates
another stream with the same socket handle.

But, there isn't any way that the parser can legally just assume that the
end of the root element is the end of the file. You will have to have some
identifier in the stream, which the input stream object will see, eat, and
report an end of file because of.

----------------------------------------
Dean Roddey
Software Weenie
IBM Center for Java Technology - Silicon Valley
[EMAIL PROTECTED]



Joe Futrelle <[EMAIL PROTECTED]> on 04/03/2000 03:02:07 PM

Please respond to [EMAIL PROTECTED]

To:   [EMAIL PROTECTED]
cc:
Subject:  reading multiple top-level elements from persistent socket
      connection



Hello,

Apologies if this has already been asked.  My application is based on
a stateful protocol whose messages are encoded in XML.  In other
words, multiple top-level XML elements are sent between the server and
client over a single connection.  I want to use Xerces-c's DOM parser
to read these elements.  I've written an InputSource based on our
socket library, but Xerces-c's DOM parser expects an end-of-file
before it will return the top-level element.  Can this parser be
extended to optionally return the top-level element immediately after
reading the end tag, or is this behavior inconsistent with DOM itself?

It appears that internal/XMLScanner would have to be modified to
include a flag for this behavior.

------------------------------------------------------------------------
Joe Futrelle                  | "You guffawed, but for Ethel." --
Team Leader, Emerge           | Malcolm St Helens
Scientific Data Tech. / NCSA  |
http://emerge.ncsa.uiuc.edu/  |



Reply via email to