Not really, reading from a socket you do not know whan the document is finished
You really need to use a SAXDriver to parse the data stream logically and 
detect the logical end of file.
As far as I understand this is the only option available.


At 10.18 21/06/2002 +0100, James Strachan wrote:
>Thanks for your mail; thats nice to know.
>
>Another way is to read the entire document buffer into memory first then use
>a StringReader or ByteArrayInputStream to parse the document.
>
>James
>----- Original Message -----
>From: "Ing. Damiano Bolla" <[EMAIL PROTECTED]>
>To: <[EMAIL PROTECTED]>
>Sent: Friday, June 21, 2002 7:03 AM
>Subject: [dom4j-dev] XML java server - reading + writing XML to socket
>
>
> > In my quest to write a java server that parses XML, do something, write
>the
> > result on the very same socket I have come across to a few problems.
> >
> > In my previous mail I did congratulate dom4j for its excellent job and
> > exmplained a few tricks I have come across.
> > I was suggesting a simple patch to avoid closing the inputStream on
> > SAXDriver parser termination, but there is a "cleaner" solution.
> >
> > Just write a class like this.
> >
> > class NocloseReader extends BufferedReader
> >    {
> >    public NocloseReader(InputStreamReader dataIn ) { super ( dataIn ); }
> >    public void close () { /* System.out.println ("Not Closing"); */  }
> >    }
> >
> >
> > and the use it as this.
> >    public void parse ( InputStream dataIn ) throws
>IOException,SAXException
> >      {
> >      InputStreamReader inReader = new InputStreamReader ( dataIn );
> >      NocloseReader    inNoclose = new NocloseReader (inReader);
> >      InputSource      inSource  = new InputSource (inNoclose);
> >      saxParser.parse( inSource );
> >      }
> >
> > A neat solution I come across in my wandenring in the net, maybe you also
> > find it useful.
> >
> >
> >
> > Damiano Bolla, Director R&D, Infotech S.r.l
> >
> >
> >
> >
> >
> > -------------------------------------------------------
> > Sponsored by:
> > ThinkGeek at http://www.ThinkGeek.com/
> > _______________________________________________
> > dom4j-dev mailing list
> > [EMAIL PROTECTED]
> > https://lists.sourceforge.net/lists/listinfo/dom4j-dev
> >
>
>
>_________________________________________________________
>Do You Yahoo!?
>Get your free @yahoo.com address at http://mail.yahoo.com

Damiano Bolla, Director R&D, Infotech S.r.l





-------------------------------------------------------
Sponsored by:
ThinkGeek at http://www.ThinkGeek.com/
_______________________________________________
dom4j-dev mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/dom4j-dev

Reply via email to