views:

29

answers:

2

Well, it's been several hours I'm lost...

IXSLTemplate::putref_stylesheet doesn't document any error except E_FAIL.

However in my case putref_stylesheet returns E_INVALIDARG. GetErrorInfo() is only redundant telling me that the "Argument is invalid". So I am not left with much information.

However my code is pretty close to all examples I found on the web and msdn. And it does something like:

void xsltProcessing(MSXML2::IXMLDOMDocument* pXmlDoc, MSXML2::IXMLDOMDocument * pXslDoc)
{
    IXSLTemplatePtr pTemplate;
    pTemplate.CreateInstance( _T( "Msxml2.XSLTemplate" ));
    pTemplate->putref_stylesheet(pXslDoc);
    //...
}

As there is not much documentation for putref_stylesheet. Do you have any idea what could go wrong for it to return E_INVALIDARG ?

My pXslDoc is a IXMLDOMDocument I have loaded from static const strings with success.

Any clue ? ( I guess it's pretty vague a question, but it's been hours I am searching )

A: 

Are you sure pXslDoc is not NULL?

Cătălin Pitiș
yep, in my traces I test its root node: pNodeRoot=0103D2F8... and anyway, the boilerplate code at the begining of the function that I didn't write in my SO question to make it shorter: `if (pXmlDoc == NULL || pXslDoc == NULL) { ASSERT(0); return E_FAIL; }`
Stephane Rolland
+1  A: 

Are you loading pXslDoc asynchronously perhaps?

The default behaviour for IXMLDOMDocument objects is to load asynchronously, so it is possible that the pXslDoc has not finished loading when you call putref_stylesheet().

Adding the following code before you load pXslDoc would fix this problem, if it is what you are suffering from:

pXslDoc->put_async(VARIANT_FALSE);
Phil Booth
Yes. I did it because I saw it on the examples on the net, but without knowing why. Thanx you for the explanation.
Stephane Rolland