You are viewing a plain text version of this content. The canonical link for it is here.
Posted to general@xml.apache.org by "Njaka, Chikeobi" <CN...@ndsamericas.com> on 2001/02/01 19:24:57 UTC
Parsing XML Streams
Hi!,
I have an application that produces data in XML format. Clients can connect
using TCP/IP and once connected, the DTD is sent, followed by well formed
and valid (except for the last closing tag) XML data as it is generated. I
have tried using the following code:
***************************************************************************
try {
Parser parser;
//
SAXParserFactory spf = SAXParserFactory.newInstance();
String validation =
System.getProperty("javax.xml.parsers.validation","true");
if (validation.equalsIgnoreCase("true")) spf.setValidating(true);
//
SAXParser sp = spf.newSAXParser();
parser = sp.getParser();
//
XMLParser xmlParser = new XMLParser(this.xmlData);
parser.setDocumentHandler(xmlParser);
parser.setErrorHandler(xmlParser);
//
parser.parse(new InputSource(socket.getInputStream()));
} catch (SAXParseException e) {
System.out.println("***ERROR*** Parsing Error " + " , line " +
e.getLineNumber() +
", uri " + e.getSystemId());
System.out.println(" " + e.getMessage());
System.exit(1);
} catch (SAXException se) {
Exception x = se;
if (se.getException() != null) {
x = se.getException();
x.printStackTrace();
}
System.exit(1);
} catch (Throwable t) {
t.printStackTrace();
System.exit(1);
}
***************************************************************************
While the startDocument event is triggered, nothing else happens. I have
checked and indeed, the data stream is coming through.
Help anyone?
Chikeobi Otuokere Njaka
cnjaka@ndsamericas.com
Re: Parsing XML Streams
Posted by Andy Clark <an...@apache.org>.
"Njaka, Chikeobi" wrote:
> I have an application that produces data in XML format. Clients can
> connect using TCP/IP and once connected, the DTD is sent, followed by
> well formed and valid (except for the last closing tag) XML data as it
> is generated. I have tried using the following code:
Check the xerces-j-dev mailing list archives. There were lots of
requests just like yours where solutions were posted.
--
Andy Clark * IBM, TRL - Japan * andyc@apache.org
Re: Parsing XML Streams
Posted by Dane Foster <df...@equitytg.com>.
Parsing XML StreamsBuffer the stream.
ex: parser.parse( new InputSource( new BufferedInputStream( socket.getInputStream() ) ) );
Dane Foster
Equity Technology Group, Inc
http://www.equitytg.com.
----- Original Message -----
From: Njaka, Chikeobi
To: 'general@xml.apache.org'
Sent: Thursday, February 01, 2001 1:24 PM
Subject: Parsing XML Streams
Hi!,
I have an application that produces data in XML format. Clients can connect using TCP/IP and once connected, the DTD is sent, followed by well formed and valid (except for the last closing tag) XML data as it is generated. I have tried using the following code:
***************************************************************************
try {
Parser parser;
//
SAXParserFactory spf = SAXParserFactory.newInstance();
String validation = System.getProperty("javax.xml.parsers.validation","true");
if (validation.equalsIgnoreCase("true")) spf.setValidating(true);
//
SAXParser sp = spf.newSAXParser();
parser = sp.getParser();
//
XMLParser xmlParser = new XMLParser(this.xmlData);
parser.setDocumentHandler(xmlParser);
parser.setErrorHandler(xmlParser);
//
parser.parse(new InputSource(socket.getInputStream()));
} catch (SAXParseException e) {
System.out.println("***ERROR*** Parsing Error " + " , line " + e.getLineNumber() +
", uri " + e.getSystemId());
System.out.println(" " + e.getMessage());
System.exit(1);
} catch (SAXException se) {
Exception x = se;
if (se.getException() != null) {
x = se.getException();
x.printStackTrace();
}
System.exit(1);
} catch (Throwable t) {
t.printStackTrace();
System.exit(1);
}
***************************************************************************
While the startDocument event is triggered, nothing else happens. I have checked and indeed, the data stream is coming through.
Help anyone?
Chikeobi Otuokere Njaka
cnjaka@ndsamericas.com