Technical Article

SQL Server 2005 Upgrade Analysis Report Stylesheet

,

XSLT Stylesheet to produce developer/object oriented html report from SQL Server 2005 Upgrade Advisor xml report file. Name the script sqlupad.xsl and insert the following  as the first line in the xml Upgrade Advisor report file. Place sqlupad.xsl file in same directory as the xml report. This stylesheet works against Database Server component reportonly, does not work against the DTS xml report

<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:strip-space elements="*" />
<!-- stylesheet to produce developer/object oriented html report from SQL Server 2005 Upgrade Advisor xml report
insert "<?xml-stylesheet type="text/xsl" href="sqlupad.xsl"?>" as first line in the xml file and place sqlupad.xsl
in same directory. Database Server component stylesheet only, does not work against DTS xml report -->

<xsl:template match="/">
  <html>
    <head>
    <title>SQL Server 2005 Upgrade Analysis</title>

<style type="text/css">
body {
background-color: #BED2E9;
}
table {
font-family: Tahoma, Arial, sans-serif;
font-size: 12px;
background-color: #FFFFFF;
}
.titlediv {
background-color: #FFFFFF;
}
</style>
    
</head>

    <body>
    <div class="titlediv" width="100%">
      <p align="center">
SQL Server 2005 Upgrade Analysis:<br /><strong><xsl:value-of select="/AnalysisResults/ExecutionSummary/Server" /></strong>
<br /><xsl:value-of select="/AnalysisResults/TimeStamp" />
  </p>
</div>
<p align="left">
<strong>Objects</strong>
<table width="100%" border="1" cellpadding="0" cellspacing="0">
<tr bgcolor="#DDDDDD">
          <td width="10%">
<strong>When to fix</strong>
          </td>
          <td width="32%">
            <strong>Description</strong>
          </td>
          <td width="7%">
            <strong>Database</strong>
          </td>
          <td width="23%">
            <strong>Object</strong>
          </td>
<td width="2%">
<strong>Type</strong>
          </td>
          <td width="25%">
            <strong>Comment</strong>
          </td>
        </tr>
<xsl:apply-templates select="/AnalysisResults/Reports/Report" />
</table>
</p>

    </body>
  </html>
</xsl:template>

<xsl:template match="Report">
<xsl:variable name="issueId" select="IssueId" />
<xsl:variable name="itemId" select="ItemId" />
<xsl:if test="/AnalysisResults/Items/Item[ItemId = $itemId]/ItemAttributes/ItemAttribute/Value[1] = 'Database'">
<tr bgcolor="#FFFFFF"><xsl:apply-templates select="/AnalysisResults/Issues/Issue[IssueId = $issueId]" />
<xsl:apply-templates select="/AnalysisResults/Items/Item[ItemId = $itemId]" /></tr>
</xsl:if>
 </xsl:template>

<xsl:template match="Issue">
<td><xsl:value-of select="IssueType" /></td>
<td><xsl:value-of select="IssueDescription" /></td>
</xsl:template>

<xsl:template match="Item">
<xsl:apply-templates select="ItemAttributes" />
</xsl:template>

<xsl:template match="ItemAttributes">
<!-- Database -->
<td><xsl:value-of select="ItemAttribute[2]/Value" /></td>
<xsl:choose>
<!-- Workaround for xml format where object and object type are in different columns -->
<xsl:when test="normalize-space(ItemAttribute[3]/Value) = 'P'">
<!-- Object -->
<td><xsl:value-of select="ItemAttribute[4]/Value" /></td>
<!-- Object type -->
<td><xsl:value-of select="ItemAttribute[3]/Value" /></td>
</xsl:when>
<xsl:otherwise>
<!-- Object -->
<td><xsl:value-of select="ItemAttribute[3]/Value" /></td>
<!-- Object type -->
<td><xsl:value-of select="ItemAttribute[4]/Value" /></td>
</xsl:otherwise>
</xsl:choose>
<xsl:choose>
<xsl:when test="string(ItemAttribute[5]/Value)">
<!-- Comments -->
<td><xsl:value-of select="concat(ItemAttribute[5]/Value, ' ', ItemAttribute[6]/Value)" /></td>
</xsl:when>
<xsl:otherwise>
<td><xsl:text>-</xsl:text></td>
</xsl:otherwise>
</xsl:choose>
</xsl:template>

</xsl:stylesheet>

Rate

You rated this post out of 5. Change rating

Share

Share

Rate

You rated this post out of 5. Change rating