actually that is stupid.
Your stream should just be
class MultiStream extends FilterStream
{
InputStream[] streams;
int curStream = 0;
public MultiStream(InputStream[] streams)
{
this.streams = streams;
}
public int read()
{
int b;
while ((curStream < streams.length) && (b = streams[curStream].read()
== -1)
{
curStream++;
}
return b;
}
}
and then create this stream like
new MultiStream( new InputStream[] { new StringStream("<root>"), in, new
StringStream("</root>" });
>
>
> Quoting Sogol G <[EMAIL PROTECTED]>:
>
> > Hi, I'm new to Xerces and I'm not sure how I should
> > exactly do that. Can you please give me a litttle
> > code snippet to get me started?
> >
> > Thanks a lot..
> >
> > --- [EMAIL PROTECTED] wrote:
> >
> > > Perhaps create your own stream class that prefixes
> > > and postfixes a valid root,
> > > and pass that to the parser.
> > >
> > > Quoting Sogol G <[EMAIL PROTECTED]>:
> > >
> > > > Hello,
> > > >
> > > > I have an XML document that's not well-formed.
> > > It's
> > > > missing its root element. The rest of it is
> > > > well-formed.
> > > >
> > > > EX: it's like this:
> > > > <blah attr='val'/>
> > > > <blah attr2='val2'/>
> > > > <blah attr3='val2'/>
> > > > .
> > > > .
> > > >
> > > >
> > > > I need to parse this document using Xerces. I
> > > have a
> > > > few ideas of how I should do this, but I wanted to
> > > > also ask you guys to see if there are easier
> > > methods
> > > > of doing this. A small code snippet to clarify
> > > your
> > > > suggestion would be appreciated.
> > > >
> > > > Thanks,
> > > > Sogol
> > > >
> > > > __________________________________________________
> > > > Do You Yahoo!?
> > > > Tired of spam? Yahoo! Mail has the best spam
> > > protection around
> > > > http://mail.yahoo.com
> > > >
> > > >
> > >
> > ---------------------------------------------------------------------
> > > > 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]
> > >
> > >
> >
> >
> > __________________________________________________
> > Do You Yahoo!?
> > Tired of spam? Yahoo! Mail has the best spam protection around
> > http://mail.yahoo.com
> >
>
>
>
>
> ---------------------------------------------------------------------
> 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]