Re: [xmlpull-user] Can you clone a pull parser? Particularly the xpp3 parser?
Aleksander Slominski <[email protected]> Tue, 10 Feb 2004 13:35:19 -0500
| Newsgroups | gmane.text.xml.xmlpull.devel |
|---|---|
| Message-ID | <[email protected]> |
Nathaniel Hughes wrote:
>Alek, thanks for your response on this, sorry for my delay, I've been out
>of town.
>
>So I suspect you're right, I think my cloneable filereader was the
>problem. Is it even possible to clone a FileReader? It seems that the pull
>parser clone function works properly since it is successful with your
>CloneableCharArrayReader.
>
>It seems that if FileReader isn't cloneable, then there really isn't a bug
>in your xpp3 parser....or am I wrong?
>
>
>
hi Nate,
just write new class something like CloneableFileReader extends Reader
implements Cloneable {
private File ...
private long filepPos;}
and makes sure that its clone() will correctly deal with cloning File.
alek
>On Fri, 6 Feb 2004, Aleksander Slominski wrote:
>
>
>
>>hi Nate,
>>
>>this is now tracked in bugzilla:
>>http://www.extreme.indiana.edu/bugzilla/show_bug.cgi?id=177
>>
>>please login to bugzilla and add files with source code necessary to
>>reproduce the problem.
>>
>>i suspect your cloneable reader did not work correctly so when cloned
>>parser reads input it reads form original file and there is nothing to
>>read ("java.io.EOFException: no more data available").
>>
>>thanks,
>>
>>alek
>>
>>Nathaniel Hughes wrote:
>>
>>
>>
>>>So I'm having one slight problem using my cloned pull parser and I was
>>>wondering if someone could help. Here's what I'm doing:
>>>
>>>I'm parsing a file, and at a certain point in the file, I clone my parser
>>>(I actually do this multiple times) and store it. Then at a later point, I
>>>retrieve that parser and begin parsing again. Well, I'm cloning my parser
>>>like this:
>>>
>>> do {
>>> if(eventType == XmlPullParser.START_DOCUMENT) {
>>> System.out.println("Start document");
>>> } else if(eventType == XmlPullParser.END_DOCUMENT) {
>>> System.out.println("End document");
>>> } else if(eventType == XmlPullParser.START_TAG) {
>>> ...
>>> if(//time to clone) {
>>> try {
>>> clonedParser = (CloneableMXParser) xpp.clone();
>>> }
>>> catch (CloneNotSupportedException e) {
>>> e.printStackTrace();
>>> }
>>> parserVec.add(clonedParser);
>>> }
>>> processStartElement(xpp);
>>> } else if(eventType == XmlPullParser.END_TAG) {
>>> processEndElement(xpp);
>>> } else if(eventType == XmlPullParser.TEXT) {
>>> processText(xpp);
>>> }
>>> eventType = xpp.next();
>>> } while (eventType != XmlPullParser.END_DOCUMENT);
>>>
>>>
>>>When I try to begin parsing with my cloned parser again (running through
>>>the same loop), I get this error (top of the stack trace here):
>>>
>>>java.io.EOFException: no more data available - expected end tags </TAGTWO></TAGONE> to close start tag <TAGTWO> from line 43 and start tag <TAGONE> from line 3, parser stopped on TEXT seen ... blah="366" blah2="34" blah3="this" blah4="2065" ... @43:162
>>> at org.xmlpull.mxp1.MXParser.fillBuf(MXParser.java:2987)
>>> at org.xmlpull.mxp1.MXParser.more(MXParser.java:2996)
>>> at org.xmlpull.mxp1.MXParser.parseStartTag(MXParser.java:1769)
>>> at org.xmlpull.mxp1.MXParser.nextImpl(MXParser.java:1126)
>>> at org.xmlpull.mxp1.MXParser.next(MXParser.java:1092)
>>> at com.watchguard.tests.PullParser.processDocument(PullParser.java:129)
>>>
>>>The parser starts parsing alright, it processes the first start, end and
>>>text elements it pulls, but then, when it does a next and recieves the
>>>next start tag, it throws this error.
>>>
>>>The depth at this point is 1 (which it should be) and the elRawName
>>>contains both the TAGONE and TAGTWO char arrays, but TAGONE is the only
>>>one that is still open, so this shouldn't be an issue.
>>>
>>>Hope this makes a little sense, any help would be great!
>>>
>>>
>>>
>>>
>>>
>>
>>
>
>
>
--
The best way to predict the future is to invent it - Alan Kay
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/xmlpull-dev/
<*> To unsubscribe from this group, send an email to:
[email protected]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/