tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Paul Wallace <pwall...@twowaytv.com.au>
Subject RE: Input stream
Date Tue, 16 Aug 2005 02:12:51 GMT
Hi & thanks,
	Parsing a file would not normally be a problem, but as it is a
stream, there is no EOF and when I parse the stream into:

DocumentBuilder db =
DocumentBuilderFactory.newInstance().newDocumentBuilder();
db.parse(in);

I get: 

org.xml.sax.SAXParseException: The processing instruction target matching
"[xX][mM][lL]" is not allowed.

What I have read on this message means invalid XML. And if there were no EOF
that would be expected? I have tried parsing the simplest of XML files. This
is my dirty hack - I can delimit the 'packet' with some obscure character
while populating say a StringBuffer, write it to File, and re-parse it (I
did say it was dirty;). A packet is the contents of a complete XML file
which are sent randomly. 

So my problem is not the parsing, but capturing the fragment of an
inputstream that will parse as valid XML.

All input appreciated

rgds

Paul.

You can use different things, but directly programming you can use SAX2,
XMLReader, and XMLReaderFactory.createXMLReader....see JDK javax.xml package
documentation.  You could use a DOM object, but I wouldn't recommend it
because of memory usage. 
You can change the underlying XML parser impls for your JDK as well.

Hope it helps,

Wade

--- Chris Lamprecht <clamprecht@gmail.com> wrote:

> See XmlPull:
> 
> http://www.xmlpull.org/
> 
> On 8/15/05, Paul Wallace <pwallace@twowaytv.com.au>
> wrote:
> > Hi All,
> >        I have a socket receiving streams of XML. I
> receive an InputStream,
> > but short of a dirty hack, do not know when (or
> how) I pass the
> > stream/contents to be parsed. Any
> thoughts/resources on parsing streaming
> > XML please?
> > 
> > Thanks
> > 
> > Paul.
> > 
> >
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> tomcat-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail:
> tomcat-dev-help@jakarta.apache.org
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message