Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MSXML: How does one programmatically get the error text for failed transforms?

Tags:

xslt

winapi

msxml

XMLNotepad provides the following text (for example) when a transform fails:

Error Transforming XML
The variable or parameter 'saturated-background-color' was duplicated with the same import precedence.

How would I go about getting this error text programmatically? My code looks like this:

CComPtr<IXSLTemplate> tmpl;
HRESULT hr = CoCreateInstance(CLSID_XSLTemplate, NULL, CLSCTX_INPROC_SERVER, IID_IXSLTemplate, (void**)&tmpl);
if (SUCCEEDED(hr)) {
    hr = tmpl->putref_stylesheet(xslt_doc);
    if (SUCCEEDED(hr)) {
    // Huzzah; do stuff.
    } else {
    // How do I get the error text?  I want to log it!
    }
}
like image 782
i_am_jorf Avatar asked Feb 01 '26 08:02

i_am_jorf


1 Answers

If IXSLTemplate supports IErrorInfo (AFAIK, it does), then you can query that for additional information.

(jeffamaphone clued me in on the proper way to get this - using the GetErrorInfo() API:)

CComPtr<IErrorInfo> error;
if (SUCCEEDED( GetErrorInfo(0, &error) ) && error)
{
   // call IErrorInfo::GetDescription(), etc.
}
like image 162
Shog9 Avatar answered Feb 03 '26 09:02

Shog9



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!