如何在MSXML6和C ++ / Delphi中检索非终止的xsl:消息? [英] How to retrieve a non-terminating xsl:message in MSXML6 and C++/Delphi?

查看:156
本文介绍了如何在MSXML6和C ++ / Delphi中检索非终止的xsl:消息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用MSXML 6.0解析器进行XSL转换,并要获取< xsl:message terminate =no> 调试消息。从我在网络上发现,这似乎是



有一种方法可以在使用COM接口示例代码会很好)?



更新:



我使用做XSL转换(很简单):

 使用ActiveX,{...} MSXML2_TLB; 

function TransformMsXmlDocument(XmlDoc,XslDoc:iXmlDomDocument2):UnicodeString;
var
XslDoc2:iXmlDomDocument;
XslTemplate:iXslTemplate;
XslProcessor:iXslProcessor;
begin
XslDoc2:= CoFreeThreadedDomDocument60.Create();
XslDoc2.Async:= FALSE;
XslDoc2.Load(XslDoc);

XslTemplate:= CoXslTemplate60.Create();
XslTemplate.Stylesheet:= XslDoc2;
XslProcessor:= XslTemplate.CreateProcessor();
XslProcessor.Input:= XmlDoc;

XslProcessor.Transform();
result:= XslProcessor.Output;
end;


解决方案

我怀疑你能用MS XML 6.0做到这一点。



像你一样,我生成了MSXML2_Tlb.Pas导入文件,并使用类似于yours的代码v进行测试。第一个问题是Delphi包装组件TDomDocument60和
TFreeThreadedDomDocument60的 OnReadyStateChange OnDataAvailable 因此,我为事件接收器写了一个OleVariant包装器,它在运行时通过ConnectionPointContainer接口连接到DomDocument60,以获得一个IConnectionPoint并调用.Advise ()就可以了。我发现这个事件接收器呼叫,四次,作为XML文档加载,每次的DispID为-609,这是 onreadystatechange (XMLDOMDocumentEvents)。但是a)传递给我的包装器的Invoke的Params(PDispParams)为空,并且b)它的Invoke不是为 ondataavailable 而调用的,也不是任何东西,特别是 ontransformnode (其DispID我不知道)。



因此,我首先看到MSXML2_Tlb中的对象的事件是' t工作正常,其次,没有明显的方法捕获被转换的XML文档的 ontransformnode 事件。



Fwiw,您链接的页面上的VB示例,



https://msdn.microsoft.com/en-us/library/system.xml.xsl.xsltmessageen encoeventargs%28v=vs。 110%29.aspx



似乎意味着有一种方法可以从VB中获取 XsltMessageEncomesEventArgs ,但我不足够熟悉导入Net库到一个Delphi项目,知道我需要导入才能访问它。如果有人能告诉我,我很乐意去。


I am using the MSXML 6.0 parser for XSL transformation and want to fetch <xsl:message terminate="no"> debug messages. From what I found on the net this seems to be possible in .NET.

Is there a way to get the message output when using the COM interface (C++ or Delphi example code would be great)?

Update:

This is the code I use to do the XSL transformation (pretty straight forward):

uses ActiveX, {...} MSXML2_TLB;

function TransformMsXmlDocument( XmlDoc, XslDoc: iXmlDomDocument2 ) : UnicodeString;
var
   XslDoc2 : iXmlDomDocument;
   XslTemplate : iXslTemplate;
   XslProcessor : iXslProcessor;
begin
   XslDoc2 := CoFreeThreadedDomDocument60.Create();
   XslDoc2.Async := FALSE;
   XslDoc2.Load(XslDoc);

   XslTemplate := CoXslTemplate60.Create();
   XslTemplate.Stylesheet := XslDoc2;
   XslProcessor := XslTemplate.CreateProcessor();
   XslProcessor.Input := XmlDoc;

   XslProcessor.Transform();
   result := XslProcessor.Output;
end;

解决方案

I doubt you can do this with MS XML 6.0.

Like you, I generated the MSXML2_Tlb.Pas import file and tested with code v. similar to yours. The first problem is that the OnReadyStateChange and OnDataAvailable events of the Delphi wrapper components TDomDocument60 and TFreeThreadedDomDocument60 are never called.

So, then I wrote a OleVariant wrapper for an event sink which connects at run-time to the DomDocument60 via its ConnectionPointContainer interface to get an IConnectionPoint and calling .Advise() on that. I found that this event sink is called, four times, as the XML document loads, each time with a DispID of -609, which is the DispID of onreadystatechange (of XMLDOMDocumentEvents). But a) the Params (PDispParams ) passed to my wrapper's Invoke are empty, and b) its Invoke is not called for ondataavailable nor anything else, in particular ontransformnode (whose DispID I don't know).

So it seems to me firstly that the events of the objects in MSXML2_Tlb aren't working properly and secondly that there is no obvious way of catching the ontransformnode event of the XML document being transformed.

Fwiw, the VB example on the page you linked,

https://msdn.microsoft.com/en-us/library/system.xml.xsl.xsltmessageencounteredeventargs%28v=vs.110%29.aspx

seems to imply that there's a way of getting at XsltMessageEncounteredEventArgs from VB, but I'm not familiar enough with importing the Net libraries into a Delphi project to know what I would need to import to be able to access it. If someone could tell me that, I'd be happy to have a go.

这篇关于如何在MSXML6和C ++ / Delphi中检索非终止的xsl:消息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆