Dominik Stadler wrote:

On Thu, 23 Jun 2005 10:29:59 +0200, Axel Weiß wrote:

Hi

you could try to make your data stream look like legal xml content, by
preceding the stream with a xml header and an opening root element. It
would then look like

<?xml version="1.0"?>
<data-stream>
<FIRSTMESSAGE>...</FIRSTMESSAGE><SECONDMESSAGE>...</SECONDMESSAGE>

This can be parsed with SAX parser, even if the root element never will
be closed.

Thanks for your suggestion, I forgot to mention that each XML-Message
might contain header-information, so I could have something like

<!DOCTYPE
STREET_REF SYSTEM "fti://repository/dtd/STREET_REF">
<FIRSTMESSAGE>...</FIRSTMESSAGE>
<?xml version="1.0" encoding="UTF-8" standalone="no" ?> <!DOCTYPE
STREET_REF SYSTEM "fti://repository/dtd/STREET_REF">
<SECONDMESSAGE>...</SECONDMESSAGE>

which would not lead to a valid XML-Message, because there are
<?xml...>- and <!DOCTYPE..>-elements somewhere in between...

We know, however, that every XML-Message starts on
a new line, so we might need to concatenate lines until we have a complete
XML-Message and then use that... Also kind of ugly and potentially
time-consuming, but I don't see any other way except to write a small
specialized XML-Grammar and this still wouldn't be able to parse
messages in encodings like UTF-16.

Dominik.
I was in a situation similar to this. I was reading multiple XML messages from a socket. The protcol required that the XML messages were to be delimited by a special character sequence. I implemented a InputSource and a BinInputStream that could determine when the end of each XML message was reached.

The custom BinInputStream have to implement the following methods:
virtual unsigned int curPos() const;
virtual unsigned int readBytes( XMLByte* const toFill, const unsigned int maxToRead);

And the custom InputSource has return the custom BinInputStream in the method:
virtual BinInputStream* makeStream() const;


Hope it helps,
-Alex






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

Reply via email to