为什么 IXSLTemplate::putref_stylesheet 在传递 IXMLDOMDocument 参数时进行编译
我第一次使用 XSLT 和 MSXML2。当然它不起作用:-) 我有一个我无法解决的错误。
为了修复这个错误,我尝试了解周围的一切:有些事情让我震惊。
void xsltProcessing(IXMLDOMDocument* pXmlDoc, IXMLDOMDocument * pXslDoc)
{
CComPtr<IXSLTemplate> pTemplate;
pTemplate.CoCreateInstance(CLSID_XSLTemplate);
pTemplate->putref_stylesheet(pXslDoc);
//...
}
它编译起来轻而易举,而这是 putref_stylesheet 的定义
virtual HRESULT __stdcall putref_stylesheet (
/*[in]*/ struct IXMLDOMNode * stylesheet ) = 0;
,我还没有找到任何接受 IXMLDOMDocument * 作为参数的定义。
这怎么可能编译?这两种类型根本不匹配!
任何帮助表示赞赏。
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
IXMLDOMDocument
根据 MSDN.因此,它与将派生类指针传递给需要基类指针的类相同。因此它可以编译。IXMLDOMDocument
is derived fromIXMLDOMNode
according to MSDN. Hence it is same as passing a derived class pointer to a class expecting a base class pointer. Hence it compiles.