<?xml version="1.0"?>
<xslt:stylesheet xmlns:xslt="http://www.w3.org/1999/XSL/Transform"
    xmlns:rs="urn:schemas-microsoft-com:rowset"
    xmlns:s="uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882"
    xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882"
    xmlns:z="#RowsetSchema"
    xmlns:ms="urn:schemas-microsoft-com:xslt"
    version="1.0"
    exclude-result-prefixes="rs s dt z xslt ms">
  <xslt:output method="html" version="4.0" encoding="UTF-8" />
  <xslt:template match="/">
  <html>
    <body>
      <TABLE BORDER="0" width="25%" cellpadding="4" align="center" noWrap="True">
        <THEAD>
          <!-- Output the name of the row. -->
          <xslt:for-each select="/xml/s:Schema/s:ElementType[@name='row']/s:AttributeType">
            <xslt:sort select="@name" />
            <th bgcolor="0000A0" align="center">
              <font color="ffffff" face="arial,helvetica" size="2">
                <b><xslt:value-of select="@name" /></b>
              </font>
            </th>
          </xslt:for-each>
        </THEAD>

        <TBODY CLASS="TableBody" id="tableBody">
          <xslt:apply-templates select="/xml/rs:data/z:row">
            <xslt:sort select="@CustomerID" />
          </xslt:apply-templates>
        </TBODY>
      </TABLE>
    </body>
  </html>
  </xslt:template>

BEGIN CALLOUT A
  <xslt:template match="z:row">
    <TR>
      <xslt:variable name="current_row" select="." />
      <xslt:for-each select="/xml/s:Schema/s:ElementType[@name='row']/s:AttributeType">
        <xslt:sort select="@name" />
        <xslt:variable name="attrName" select="@name" />

        <TD bgcolor="F47809" align="center" noWrap="True">
          <font color="ffffff" face="arial,helvetica" size="2">

BEGIN CALLOUT B
            <xslt:choose>
              <xslt:when test="s:datatype/@dt:type='dateTime'">
                <xslt:value-of select="ms:format-
date($current_row/@*[name()=$attrName],'MM/dd/yyyy')" />
              </xslt:when>
              <xslt:otherwise>
                <xslt:value-of select="$current_row/@*[name()=$attrName]" />
              </xslt:otherwise>
            </xslt:choose>
END CALLOUT B

          </font>
        </TD>
      </xslt:for-each>
    </TR>
  </xslt:template>
END CALLOUT A
</xslt:stylesheet>