使用xslt以html显示图像/链接

时间:2017-04-13 15:22:44

标签: html xml maven xslt

我使用tesng-xslt库生成HTML报告,输入" testng-results.xml"这是由Maven surefire-reports生成的。我使用Reporter.log进行报告。在这里,我还使用reporter.log附加截图,如下所示

Reporter.log("<img src=\"file:///" + screenshotAbsolutePath + "\" alt=\"\"/><br />");

因此图像显示在报告输出中由maven surefire插件生成的报告中。现在,当我通过带有build.xml的testng-xslt库生成HTML报告时,图像不会显示在HTML

请找到使用过的xml

<?xml version="1.0" encoding="UTF-8"?>
<testng-results skipped="0" failed="2" total="2" passed="0">
  <reporter-output>
    <line>
      <![CDATA[Successfully Launced the Url - https://stg.xxxxx.com/asp/gateway/discovery]]>
    </line>
    <line>
      <![CDATA[Successfully Entered email 'qatest2850@test.com' in UserName Field]]>
    </line>
    <line>
      <![CDATA[Successfully Clicked on Next Button]]>
    </line>
    <line>
      <![CDATA[Successfully clicked on Forgot Password]]>
    </line>
    <line>
      <![CDATA[<img src="file:///D:\CertMetric\cspweb\screenshots\1492095605697.png" alt=""/><br />]]>
    </line>
    <line>
      <![CDATA[Failed to send Email]]>
    </line>
</reporter-output>
<suite>
<test>
<class>
<test-method>
</test-method>
</class>
</test>
</suite>
</testng-results>

数据在和xslt用于报告输出

 <xsl:result-document href="{testng:absolutePath('reporterOutput.html')}" format="xhtml">
            <html xmlns="http://www.w3.org/1999/xhtml">
                <xsl:call-template name="htmlHead"/>
                <body>
                    <h2>Reporter output</h2>
                    <xsl:for-each select="reporter-output/line">
                        <div>
                            <code>
                              <xsl:value-of select="." disable-output-escaping="yes"/>
                            </code>
                        </div>
                    </xsl:for-each>
                    <xsl:call-template name="powered-by"/>
                </body>
            </html>
          </xsl:result-document>
        </xsl:result-document>
    </xsl:template

有人可以帮助我吗?我想用HTML显示图像或超链接。

提前致谢。

0 个答案:

没有答案