views:

24

answers:

1

hello

I am playing with XSLT with MSXML2 for the first time. And of course it doesn't work :-) I have a bug which I cannot figure to solve.

So as to fix the bug, I try to understand everything around: and something shocks me.

void xsltProcessing(IXMLDOMDocument* pXmlDoc, IXMLDOMDocument * pXslDoc)
{
    CComPtr<IXSLTemplate> pTemplate;
    pTemplate.CoCreateInstance(CLSID_XSLTemplate);
    pTemplate->putref_stylesheet(pXslDoc);
    //...
}

it compiles like a breeze whereas this is the definition of putref_stylesheet

  virtual HRESULT __stdcall putref_stylesheet (
    /*[in]*/ struct IXMLDOMNode * stylesheet ) = 0;

and I haven't found any definition that would accept a IXMLDOMDocument * as a parameter.

How is that possible to compile ? the two types simply don't match !

any help appreciated.

I have found these two links that also pass xmldocuments in their code !: Example One Example Two

+1  A: 

IXMLDOMDocument is derived from IXMLDOMNode according to MSDN. Hence it is same as passing a derived class pointer to a class expecting a base class pointer. Hence it compiles.

Naveen
mama mia... that essential fact, I didn't know. Glad I have asked this obvious question. thx. I don't know how many times I have used ::QueryInterface to switch between the two... I dare not think about it.
Stephane Rolland