<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet 
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
    xmlns:h="http://iharder.net/xmlizable"
    version="1.0" >


  <xsl:template match="/">
    <html>
      <head>
        <title><xsl:value-of select="name(/*)"/></title>
        <style type="text/css">
          <xsl:comment>
            <![CDATA[

 *       { font-family: Arial, sans-serif }
 li      { padding: 0.5ex; }
 td, th  { font-size: smaller; font-family: Verdana; padding: 1ex; vertical-align: top; }
 .arr_0  { background-color: #FFFFFF; }
 .arr_1  { background-color: #FAFAFA; }
 caption { font-style: italic; font-family: Times, serif; }

            ]]>
          </xsl:comment>
        </style>
      </head>
      <body>
        <xsl:apply-templates />
      </body>
    </html>
  </xsl:template>



 <xsl:template match="false">
  <span class="false">false</span>
 </xsl:template>

 <xsl:template match="true">
  <span class="true">true</span>
 </xsl:template>




  <xsl:template match="array">
    <!-- Enclose entire array in a 'div' and give it a distinctive id. -->
    <div class="array" >
        <ul>
          <xsl:for-each select="*">
            <li title="Array Element {position()} of {last()}" 
                class="arr_{(position()-1) mod 2}">

              <xsl:apply-templates select="." />

            </li>
          </xsl:for-each>
        </ul>
    </div>
  </xsl:template>




  <xsl:template match="dict">
      <table border="1" class="dict" >
        <!-- Table header with optional legends -->
        <thead>
          <th>key</th>
          <th>value</th>
        </thead>

        <!-- Table body -->
        <tbody>

          <xsl:choose>
            <!--
                When the map is empty.
              -->
            <xsl:when test="not(*)">
              <tr>
                <td colspan="2" style="text-align:center">
                  <xsl:text>Empty</xsl:text>
                </td>
              </tr>
            </xsl:when>

            <!--
                When there's something in the map.
              -->
            <xsl:otherwise>
              <xsl:for-each select="key">
               <tr>
                <td><xsl:value-of select="." /></td>
                <td><xsl:apply-templates select="following-sibling::*[1]" /></td>
               </tr>
              </xsl:for-each>
            </xsl:otherwise>
          </xsl:choose>
        </tbody>
      </table>
  </xsl:template>


</xsl:stylesheet>