使用VS Project的检查代码xslt将XML转换为html [英] Xml to html using xslt of inspect code of VS Projects

查看:69
本文介绍了使用VS Project的检查代码xslt将XML转换为html的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个InspectionResults.xml,当我从JetbrainsCommandLine Tool Analysis运行inspectcode.exe时会生成该InspectionResults.xml. Jetbrains提供的任何xslt文件是否可以将此xml转换为html.我能够使用它们提供的xsltDuplicateReport.xml转换为html. Jetbrains是否为此转换提供一个.如果没有,请帮帮我.

我的xml文件如下:

<?xml version="1.0" encoding="utf-8"?>
<!-- Generated by JetBrains Inspect Code 9.1 -->
<Report ToolsVersion="102.0">
<Information>
<Solution>Server\Server.sln</Solution>
<InspectionScope>
 <Element>Solution</Element>
</InspectionScope>
</Information>
<IssueTypes>
<IssueType Id="ArrangeStaticMemberQualifier" Category="Code Style" Description="Add/remove qualifier for static members" Severity="WARNING" />
<IssueType Id="ArrangeThisQualifier" Category="Code Style" Description="Add/remove 'this.' qualifier" Severity="WARNING" />
 <IssueType Id="CSharpErrors" Category="C# Compiler Errors" Description="" Severity="ERROR" />
 </IssueTypes>

  <Issues>
  <Project Name="Common">
  <Issue TypeId="RedundantUsingDirective" File="Common\AdapterAuthorizationException.cs" Offset="15-48" Line="2" Message="Using directive is not required by the code and can be safely removed" />
  <Issue TypeId="RedundantUsingDirective" File="Common\AdapterAuthorizationException.cs" Offset="50-68" Line="3" Message="Using directive is not required by the code and can be safely removed" />
  <Issue TypeId="CSharpErrors" File="Common\AdapterAuthorizationException.cs" Offset="63-67" Line="3" Message="Cannot resolve symbol 'Linq'" />
  </Project>
  </Issues>
  </Report>

解决方案

我发现Resharper命令行工具的概述功能中提到的 inspectcode.xslt 正常运行

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl">
  <xsl:key name="ISSUETYPES" match="/Report/Issues/Project/Issue" use="@TypeId"/>
  <xsl:output method="html" indent="yes"/>

  <xsl:template match="/" name="TopLevelReport">
    <html>
      <head>
        <title>Resharper InspectCode Report</title>

        <style>
        body { font-family: Arial; }
        th, td { text-align: left; }
        .severity { font-weight: bold; }
        </style>
      </head>
      <body>
        <h1>Resharper InspectCode Report</h1>

        <xsl:for-each select="/Report/IssueTypes/IssueType">
          <h2>
            <span class="severity"><xsl:value-of select="@Severity"/></span>: <xsl:value-of select="@Description"/>
          </h2>
          <table style="width:100%">
            <tr>
              <th>File</th>
              <th>Line Number</th>
              <th>Message</th>
            </tr>
            <xsl:for-each select="key('ISSUETYPES',@Id)">
              <tr>
                <td>
                  <xsl:value-of select="@File"/>
                </td>
                <td>
                  <xsl:value-of select="@Line"/>
                </td>
                <td>
                  <xsl:value-of select="@Message"/>
                </td>
              </tr>
            </xsl:for-each>
          </table>
          <br />
          <hr />
          <br />
        </xsl:for-each>
      </body>
    </html>
  </xsl:template>
</xsl:stylesheet>

此内容来自:

https://gist.github.com/maartenba/b7b1866d11a54cf3bc9f04316afa1a9e>a

功能概述在这里:

https://www.jetbrains.com/help/resharper/ReSharper_Command_Line_Tools.html 在该视频中提到了xslt

如果您需要使用工具来应用此XSLT,请参阅此问题和答案

是否有任何XSLT处理命令行工具?

I have a an InspectionResults.xml which gets generated when I run inspectcode.exe from JetbrainsCommandLine Tool Analysis. Is there any xslt file provided by the Jetbrains to convert this xml to html. I was able to convert DuplicateReport.xml to html using the xslt provided by them. Does Jetbrains provide one for this conversion. If not please help me out.

My xml file is as follows:

<?xml version="1.0" encoding="utf-8"?>
<!-- Generated by JetBrains Inspect Code 9.1 -->
<Report ToolsVersion="102.0">
<Information>
<Solution>Server\Server.sln</Solution>
<InspectionScope>
 <Element>Solution</Element>
</InspectionScope>
</Information>
<IssueTypes>
<IssueType Id="ArrangeStaticMemberQualifier" Category="Code Style" Description="Add/remove qualifier for static members" Severity="WARNING" />
<IssueType Id="ArrangeThisQualifier" Category="Code Style" Description="Add/remove 'this.' qualifier" Severity="WARNING" />
 <IssueType Id="CSharpErrors" Category="C# Compiler Errors" Description="" Severity="ERROR" />
 </IssueTypes>

  <Issues>
  <Project Name="Common">
  <Issue TypeId="RedundantUsingDirective" File="Common\AdapterAuthorizationException.cs" Offset="15-48" Line="2" Message="Using directive is not required by the code and can be safely removed" />
  <Issue TypeId="RedundantUsingDirective" File="Common\AdapterAuthorizationException.cs" Offset="50-68" Line="3" Message="Using directive is not required by the code and can be safely removed" />
  <Issue TypeId="CSharpErrors" File="Common\AdapterAuthorizationException.cs" Offset="63-67" Line="3" Message="Cannot resolve symbol 'Linq'" />
  </Project>
  </Issues>
  </Report>

解决方案

I have found this inspectcode.xslt that is mentioned in the overview features of the Resharper Command Line Tools, and is working just fine.

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl">
  <xsl:key name="ISSUETYPES" match="/Report/Issues/Project/Issue" use="@TypeId"/>
  <xsl:output method="html" indent="yes"/>

  <xsl:template match="/" name="TopLevelReport">
    <html>
      <head>
        <title>Resharper InspectCode Report</title>

        <style>
        body { font-family: Arial; }
        th, td { text-align: left; }
        .severity { font-weight: bold; }
        </style>
      </head>
      <body>
        <h1>Resharper InspectCode Report</h1>

        <xsl:for-each select="/Report/IssueTypes/IssueType">
          <h2>
            <span class="severity"><xsl:value-of select="@Severity"/></span>: <xsl:value-of select="@Description"/>
          </h2>
          <table style="width:100%">
            <tr>
              <th>File</th>
              <th>Line Number</th>
              <th>Message</th>
            </tr>
            <xsl:for-each select="key('ISSUETYPES',@Id)">
              <tr>
                <td>
                  <xsl:value-of select="@File"/>
                </td>
                <td>
                  <xsl:value-of select="@Line"/>
                </td>
                <td>
                  <xsl:value-of select="@Message"/>
                </td>
              </tr>
            </xsl:for-each>
          </table>
          <br />
          <hr />
          <br />
        </xsl:for-each>
      </body>
    </html>
  </xsl:template>
</xsl:stylesheet>

This content was taken from:

https://gist.github.com/maartenba/b7b1866d11a54cf3bc9f04316afa1a9e

The overview of the features is here:

https://www.jetbrains.com/help/resharper/ReSharper_Command_Line_Tools.html and in that video is where this xslt is mentioned

And in case you need a Tools to apply this XSLT see this question and answers

Are there any XSLT processing command line tools?

这篇关于使用VS Project的检查代码xslt将XML转换为html的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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