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 "Alberto Massari (JIRA)" <xe...@xml.apache.org> on 2008/07/17 16:33:31 UTC

[jira] Resolved: (XERCESC-487) Cannot load after a prior attempt to load fails

     [ https://issues.apache.org/jira/browse/XERCESC-487?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Alberto Massari resolved XERCESC-487.
-------------------------------------

    Resolution: Won't Fix

> Cannot load after a prior attempt to load fails
> -----------------------------------------------
>
>                 Key: XERCESC-487
>                 URL: https://issues.apache.org/jira/browse/XERCESC-487
>             Project: Xerces-C++
>          Issue Type: Bug
>          Components: COM Wrapper
>    Affects Versions: 1.7.0
>         Environment: Operating System: Windows NT/2K
> Platform: PC
>            Reporter: erik.soloveiko
>
> 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;
> }

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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