Thanks jiang,

I'm not doing anything with DOM but your bullets 1. and 2. below describe
exactly what I want to do.  That gives me a place to start.  I'm just
wondering why the xerces samples dont include an example of creating a new
BinINputStream class from a tcp socket and then using that stream class in
an InputSource.  I'd like to see an "official" example of that, but what
you've told me gets me started.  Thanks!

-----Original Message-----
From: jiang lei [mailto:[EMAIL PROTECTED]
Sent: Tuesday, July 29, 2003 1:04 AM
To: [EMAIL PROTECTED]
Subject: Re: sax2 parser reading from a tcp socket


Hi Daniel,

I wonder if you mean by "Handling SAX events while parsing as  DOM".


Here is what I did:

1. Derive a class from BinInputStream, implementing the readBytes() and
curPos() methods.
2. Derive a class from  InputSource, implementing the only virtual function
makeStream(). Just create a new stream object on the heap and return its
pointer. It will be automatically destructed by Xerces, don't delete it.

3. Derive an error handler class from HandlerBase(I think this is optional)
4. Derive your own paser class from XercesDOMParser, override those virtual
functions you're interested in. For me, I care about endElement() only.
Inside those virtual  functions, you have full access to the DOM tree and
current element. One thing to remember is, never forget to call their
ancestors, if you want the parser to function normally.

5. After the parse finished, you can get the DOMDocument by calling
getDocument() method of the parser.

regards

Lei
----- Original Message -----
From: "Daniel Grillo" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, July 28, 2003 11:09 PM
Subject: sax2 parser reading from a tcp socket


> Hi Folks,
>
> I've been browsing through the archives and it seems a few people have had
> some experience with creating input sources for their sax2 parsers from
tcp
> sockets.  I'm looking to do the same thing but I'm having trouble with
where
> to start.  I've looked at the Memparse example as a start, but it seems to
> want the complete document in the buffer which gets fed to the ".parse()"
> function.  I'm not going to have the complete document in a buffer, it
will
> be continually streamed in from the socket.  I thought receiving XML
through
> tcp would be a fairly common task but there doesn't seem to be any native
> support for it in the xerces inputsource objects.  Could anyone point me
at
> any code examples of tcp input being done with a sax2 parser?
>
> Thanks!
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
>


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

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

Reply via email to