Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/xslt/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在PowerShell中使用Saxon XSLT transformer捕获xsl:message输出_Powershell_Xslt_Saxon - Fatal编程技术网

如何在PowerShell中使用Saxon XSLT transformer捕获xsl:message输出

如何在PowerShell中使用Saxon XSLT transformer捕获xsl:message输出,powershell,xslt,saxon,Powershell,Xslt,Saxon,在通过PowerShell运行时,我找不到捕获.NET Saxon XSLT转换器的输出的方法 我尝试了各种PowerShell捕获输出的方法,以及告诉Saxon输出数据的各种方法,但都没有成功。我需要使用Saxon XSLT库,因为我们公司致力于此 尝试 Transformer.MessageListener。问题:PowerShell不支持创建用于捕获MessageListener.Message事件的接口 Transformer.TraceFunctionDestination。问题:无法

在通过PowerShell运行时,我找不到捕获.NET Saxon XSLT转换器的
输出的方法

我尝试了各种PowerShell捕获输出的方法,以及告诉Saxon输出数据的各种方法,但都没有成功。我需要使用Saxon XSLT库,因为我们公司致力于此

尝试

  • Transformer.MessageListener
    。问题:PowerShell不支持创建用于捕获
    MessageListener.Message
    事件的接口

  • Transformer.TraceFunctionDestination
    。问题:无法使用构造函数实例化
    StandardLogger

    $outLogger=新对象Saxon.Api.StandardLogger-参数列表$outLogger
    $outLogger.UnderylingTextWriter=$outLogFile
    $SAXSTransform.TraceFunctionDestination=$outLogger
    
  • 各种PowerShell输出重定向方法。我不认为撒克逊人玩得很好

    $out=$saxTransform.Run($outSerializer)*>“c:\eric\log.txt”
    写入输出“nada->$out”
    
  • XSLT:


    我们对你的要求有些同情。但是使用XslTransformer.MessageListener是拦截xsl:message输出的唯一原因。设置TraceFunctionDestination将不会捕获xsl:message输出


    我不是Powershell方面的专家,但作为一种解决方法,我认为您可以在C#类中编写IMessageListener的实现,并将其构建为在Powershell中使用的程序集。

    我认为您可以使用PS调用构造函数。只需给它一个数组作为参数即可。谢谢你的回复。实际上,我相信PowerShell正确地向StandardLogger的构造函数提供了参数,但由于某些原因,构造函数可能不会暴露于PowerShell。下面是我从PowerShell得到的响应:新对象:找不到“StandardLogger”的重载,参数计数为:“1”$outLogWriter=[System.IO.File]::OpenWrite(“c:\eric\log.txt”)$outLogger=新对象Saxon.Api.StandardLogger-ArgumentList@($outLogWriter)$SAXSTransform.TraceFunctionDestination=$outLogger我链接到的答案是:必须将数组传递给
    -ArgumentList
    。你这样做了吗?是的,下面是我使用的参数列表作为数组$outLogWriter=[System.IO.File]::OpenWrite(“c:\eric\log.txt”)$outLogger=New Object Saxon.Api.StandardLogger-ArgumentList@($outLogWriter)$saxTransform.TraceFunctionDestination=$outLoggerAs一般提示:不要在注释中发布大量代码,这总是很难理解。最好编辑你的问题,或者——万一你自己找到了答案——把它作为一个真实的答案贴出来。
    <xsl:template match="/">
      <xsl:message>I want to see this in a file</xsl:message>
    </xsl:template>