You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-dev@xerces.apache.org by bu...@apache.org on 2001/06/27 19:44:25 UTC
[Bug 2311] - parseReset throws exception if parseFirst returns false
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=2311
*** shadow/2311 Mon Jun 25 10:33:22 2001
--- shadow/2311.tmp.6555 Wed Jun 27 10:44:25 2001
***************
*** 2,9 ****
| parseReset throws exception if parseFirst returns false |
+----------------------------------------------------------------------------+
| Bug #: 2311 Product: Xerces-C |
! | Status: NEW Version: 1.5 |
! | Resolution: Platform: PC |
| Severity: Normal OS/Version: Windows NT/2K |
| Priority: Other Component: SAX/SAX2 |
+----------------------------------------------------------------------------+
--- 2,9 ----
| parseReset throws exception if parseFirst returns false |
+----------------------------------------------------------------------------+
| Bug #: 2311 Product: Xerces-C |
! | Status: RESOLVED Version: 1.5 |
! | Resolution: INVALID Platform: PC |
| Severity: Normal OS/Version: Windows NT/2K |
| Priority: Other Component: SAX/SAX2 |
+----------------------------------------------------------------------------+
***************
*** 28,30 ****
--- 28,67 ----
//...
}
parser.parseReset(token);
+
+ ------- Additional Comments From tng@ca.ibm.com 2001-06-27 10:44 -------
+ If parseFirst returns false, then it means the scan of the prolog failed and the
+ token is not going to work on subsequent progressive parse calls which include
+ both parseNext and parseReset.
+
+ As documented in parseReset API, parseReset is for you to reset the parser if
+ you exit the loop early before the end of the document is reached. Call
+ parseReset when you exit the file prematurely of your own accord, because you've
+ found what you wanted in the file most likely.
+
+ If you exited because of an error (e.g. parseFirst fails), then cleanup will be
+ done for you automatically and thus it's no need to call parseReset.
+
+ So in your code, it's better do something like this (copied from sample PParse):
+
+ // Create a progressive scan token
+ XMLPScanToken token;
+
+ if (!parser.parseFirst(xmlFile, token))
+ {
+ cerr << "scanFirst() failed\n" << endl;
+ return 1;
+ }
+
+ //
+ // We started ok, so lets call scanNext() until we find what we want
+ // or hit the end.
+ //
+ bool gotMore = true;
+ while (gotMore)
+ gotMore = parser.parseNext(token);
+
+ //
+ // Reset the parser.
+ //
+ parser.parseReset(token);
\ No newline at end of file
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org