The following issue has been updated:

    Updater: Alberto Massari (mailto:[EMAIL PROTECTED])
       Date: Mon, 4 Oct 2004 3:14 AM
    Changes:
             assignee changed from Xerces-C Developers Mailing List
             description changed from 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 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;
}
             environment changed from Operating System: Windows NT/2K
Platform: PC to Operating System: Windows NT/2K
Platform: PC
             priority changed to Major
             Component changed to COM Wrapper
             Component changed from DOM
    ---------------------------------------------------------------------
For a full history of the issue, see:

  http://issues.apache.org/jira/browse/XERCESC-487?page=history

---------------------------------------------------------------------
View the issue:
  http://issues.apache.org/jira/browse/XERCESC-487

Here is an overview of the issue:
---------------------------------------------------------------------
        Key: XERCESC-487
    Summary: Cannot load after a prior attempt to load fails
       Type: Bug

     Status: Unassigned
   Priority: Major

    Project: Xerces-C++
 Components: 
             COM Wrapper
   Versions:
             1.7.0

   Assignee: 
   Reporter: erik.soloveiko

    Created: Tue, 4 Jun 2002 11:47 PM
    Updated: Mon, 4 Oct 2004 3:14 AM
Environment: Operating System: Windows NT/2K
Platform: PC

Description:
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;
}


---------------------------------------------------------------------
JIRA INFORMATION:
This message is automatically generated by JIRA.

If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa

If you want more information on JIRA, or have a bug to report see:
   http://www.atlassian.com/software/jira


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to