xerces-j-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dbros...@qis.net
Subject Re: Parsing an XML document without a root element
Date Wed, 17 Aug 2005 22:37:44 GMT
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 <sgl_g@yahoo.com>:
> 
> > 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..
> > 
> > --- dbrosius@qis.net wrote:
> > 
> > > Perhaps create your own stream class that prefixes
> > > and postfixes a valid root,
> > > and pass that to the parser.
> > > 
> > > Quoting Sogol G <sgl_g@yahoo.com>:
> > > 
> > > > 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:
> > > j-users-unsubscribe@xerces.apache.org
> > > > For additional commands, e-mail:
> > > j-users-help@xerces.apache.org
> > > > 
> > > 
> > > 
> > > 
> > > 
> > >
> > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail:
> > > j-users-unsubscribe@xerces.apache.org
> > > For additional commands, e-mail:
> > > j-users-help@xerces.apache.org
> > > 
> > > 
> > 
> > 
> > __________________________________________________
> > Do You Yahoo!?
> > Tired of spam?  Yahoo! Mail has the best spam protection around 
> > http://mail.yahoo.com 
> > 
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
> For additional commands, e-mail: j-users-help@xerces.apache.org
> 




---------------------------------------------------------------------
To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
For additional commands, e-mail: j-users-help@xerces.apache.org


Mime
View raw message