<?xml version="1.0" encoding="utf-8"?>

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
   <xsl:output method="html" indent="yes" />

   <xsl:template match="/GridData">
      <html>
         <xsl:if test="/GridData/Header/@RTL = 'True'">
            <xsl:attribute name="dir">RTL</xsl:attribute>
         </xsl:if>

         <head>
            <title><xsl:value-of select="Header/@PageTitle" /></title>
            <style>
               BODY {margin: 10px 10px 10px 10px; cursor: default;}
               TABLE {border: 1px solid #c0c0c0; width: 95%;}
               TH {background: #000088; color: white; font-family: Tahoma; font-size: 10pt; font-weight: bold;}
               TD {font-family: Tahoma; font-size: 10pt; padding : 5 5 5 5;}
               TR.GroupRow {background: #e9e9e9; padding : 5 5 5 5; font-weight: bold;}
               TR.DataRow {background: expression((this.rowIndex % 2 == 0) ? '#f9f9f9' : '');}
               .Footer {font-family: Tahoma; font-size: 9pt; color: #a0a0a0;}
            </style>
            <link rel="shortcut icon" href="/_layouts/15/images/favicon.ico" type="image/vnd.microsoft.icon" />
         </head>
         
         <center>
         <h3><u><xsl:value-of select="Header/@PageTitle" /></u></h3>
         <table rules="cols" cellpadding="0" cellspacing="0">
            <tr>
               <xsl:for-each select="Header/Col">
                  <th>
                     <xsl:if test="@Image">
                        <img><xsl:attribute name="src"><xsl:value-of select="@Image" /></xsl:attribute></img>&#160;
                     </xsl:if>
                     
                     <xsl:value-of select="." />
                  </th>
               </xsl:for-each>
            </tr>
            
            <xsl:for-each select="Rows/Row">
               <tr>
                  <xsl:choose>
                     <xsl:when test="@Group = '1'">
                        <xsl:attribute name="class">GroupRow</xsl:attribute>
                     </xsl:when>
                     <xsl:otherwise>
                        <xsl:attribute name="class">DataRow</xsl:attribute>
                     </xsl:otherwise>
                  </xsl:choose>
               
                  <xsl:for-each select="Col">
                     <td>
                        <xsl:if test="@Indent">
                           <xsl:attribute name="style">padding-left: <xsl:value-of select="@Indent" />px;</xsl:attribute>
                        </xsl:if>
                     
                        <xsl:choose>
                           <xsl:when test="@Type = 'Image'">
                              <xsl:attribute name="align">center</xsl:attribute>
                              <xsl:for-each select="Image">
                                 <img>
                                   <xsl:attribute name="src">
                                     <xsl:value-of select="." />
                                   </xsl:attribute>
                                 </img>&#160;
                              </xsl:for-each>
                              
                              <xsl:if test="text() != ''">
                                 <img>
                                   <xsl:attribute name="src">
                                     <xsl:value-of select="text()" />
                                   </xsl:attribute>
                                 </img>
                              </xsl:if>
                           </xsl:when>
                           <xsl:when test="@Type = 'Checkbox'">
                             <xsl:if test=". = '1' or . = 'True' or . = 'true'">
                                <xsl:attribute name="align">center</xsl:attribute>
                                <img src="/_layouts/15/images/check.gif" />
                             </xsl:if>
                           </xsl:when>
                           <xsl:otherwise>
                              <xsl:if test="@Type = 'Numeric' or @Type = 'Duration' or @Type = 'Percentage'">
                                 <xsl:attribute name="align">right</xsl:attribute>
                              </xsl:if>
                              
                              <xsl:if test=". = ''">&#160;</xsl:if>
                              <xsl:value-of select="." />
                           </xsl:otherwise>
                        </xsl:choose>
                     </td>
                  </xsl:for-each>
               </tr>
            </xsl:for-each>
         </table>
         <div class="Footer"><xsl:value-of select="Header/@User" />&#160;&#160;&#160;&#160;(<xsl:value-of select="Header/@Time" />)</div>
         </center>
      </html>
   </xsl:template>
</xsl:stylesheet> 

