Create your InputStream that extends the stream you are using for the xml retrival. The stream feeds root's starting at begning let it be <root> and than your xml data ... and </root> end. You provide your stream to the SAX parser.
On 8/24/05, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > Sorry, I'm using web mail, and I keep sending responses directly to the > sender by accident. > > Erik > > > -----Forwarded Message----- > From: [EMAIL PROTECTED] > Sent: Aug 24, 2005 4:26 PM > To: "Gilbert, Antoine" <[EMAIL PROTECTED]> > Subject: RE: [OT] Re: xmlparser simple question > > Well, as I said, if you use SAX you won't be loading the entire file into > memory. > > The missing root element is another problem. I think SAX parsers that I have > used require the document to be well-formed, whether it's valid or not. I > think a missing root element means the document is not well-formed, however, > I cannot confirm that with any references right off hand. If it's true, > however, surely you can figure out a way to wrap your document stream, and > add in the mock root element tags, right? > > Also you might want to look at XMLPullParser, which is what some XMPP > (Jabber) packet libraries use (another low-memory alternative to DOM). > However, even the XMPP packets I can think of are all technically well-formed > . . . I don't know of a parser implementation right off that lets you turn > off the well-formed constraint, but there sure oughta be one . . . As someone > else mentioned, perhaps Jakarta Digester can deal with this? > > Erik > > > -----Original Message----- > From: "Gilbert, Antoine" <[EMAIL PROTECTED]> > Sent: Aug 24, 2005 4:09 PM > To: Struts Users Mailing List <user@struts.apache.org>, [EMAIL PROTECTED] > Subject: RE: [OT] Re: xmlparser simple question > > My file is something like that > > <a>x</a> > <b>y</b> > > There is no root tags, and I cant modify this file. I would like to be > able to parse it without loading it entirely in memory (buffer) or > without make a copy of this file to add the root tags... > > -----Original Message----- > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] > Sent: August 24, 2005 4:09 PM > To: Struts Users Mailing List > Subject: [OT] Re: xmlparser simple question > > Gilbert, > > SAX works on an event based model. Memory is not an issue unless *you* > are caching information as you receive events in your parser handler. > > The parser starts reading the stream. Each time it encounters the > beginning of an element or an attribute, or the value of an element or > attribute, or the end of an element or attribute, it simply fires an > event. Your parser handler receives the event. At that point, the parser > forgets that part of the stream and moves on to the next part. At any > one time, the most it's going to cache is a single element or attribute > name or value. > > I'm not sure though what you mean by "add the root in the parsing > processing". Perhaps you could explain further. > > Erik > > > -----Original Message----- > From: "Gilbert, Antoine" <[EMAIL PROTECTED]> > Sent: Aug 24, 2005 3:59 PM > To: Struts Users Mailing List <user@struts.apache.org> > Subject: xmlparser simple question > > Hi > > > > I want to read an xml file using a SAXReader combined with a > ParserHandler. The file have n o XML root, so I have to find how to add > it in the parsing processing. Assuming that the file can be pretty big, > how I can do it without at any time having the entire file in memory ? > > > > > > > > --------------------------------------------------------------------- > 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] > > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]