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 2002/06/05 01:47:02 UTC
DO NOT REPLY [Bug 9610] New: -
Cannot load after a prior attempt to load fails
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=9610>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND
INSERTED IN THE BUG DATABASE.
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=9610
Cannot load after a prior attempt to load fails
Summary: Cannot load after a prior attempt to load fails
Product: Xerces-C++
Version: 1.7.0
Platform: PC
OS/Version: Windows NT/2K
Status: NEW
Severity: Major
Priority: Other
Component: DOM
AssignedTo: xerces-c-dev@xml.apache.org
ReportedBy: erik.soloveiko@conexant.com
Regarding IXMLDOMDocument...
If a document is set to load asynchronously (thru a call to the put_async
(false) method)...
If a call to the load method fails (because of a non-existent file, a poorly-
formatted XML file, etc.), any subsequent call to the load method fails, even
on an attempt to load a valid XML file.
One must actually release (thru the Release method) the instance of the
document, create another, and call the load method with the valid XML file, if
one wishes to successfully load a document after an unsuccessful attempt.
sample code...
Call this function first passing in the name of a file containing invalid XML
and, then, again passing in the name of a file containing valid XML. Even
though it should succeed the second time, it fails!
bool
CXML_Document_Adapter_Xerces_DOM::loadFromFile(const std::string& r_file_name)
{
// _p_actual_document is of type ptr to IXMLDOMDocument
// if we do not have an actual document, indicate failure and bail
if (_p_actual_document == 0)
{
return false;
}
// we have an actual document!; continue...
// properly set the "asynchronous load" flag of this operation
_variant_t load_asynchronously_variant(_load_asynchronously);
HRESULT
result_set_asynchronous_mode =
_p_actual_document->put_async(load_asynchronously_variant);
assert(SUCCEEDED(result_set_asynchronous_mode));
// attempt to load the actual document, with the contents of the named file
_variant_t file_name_variant(r_file_name.c_str());
VARIANT_BOOL load_successful;
HRESULT
result_load_successful =
_p_actual_document->load(file_name_variant, &load_successful);
// did load attempt complete gracefully?
if (SUCCEEDED(result_load_successful))
// ...load attempt completed gracefully
{
// were the contents of the named file successfully loaded into the
document?
_variant_t load_successful_variant(load_successful, VT_BOOL);
if(((bool)load_successful_variant) == true)
{
// indicate success!
return true;
}
}
// at this point we know that either the load attempt did NOT complete
gracefully or
// the contents of the named file were not successfully loaded into the
document!;
// continue...
// Xerces will give the false impression that a root element exists after
an attempt
// of a load operation fails. At least until Apache fixes this or we add
support to
// track this scenario and prevent the erroneous result, the following
assertion will
// not be made. (different Bugzilla bug -- #9555)
#if 0
// ensure that there exists no root element
assert(rootElementExists() == false);
#endif
// indicate failure, at this point
return false;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org