 <xsl:value-of select="."/>
    </td>
  </tr>
</table>
</xsl:when>
<xsl:otherwise>
<!-- Not a pure text node-->

<xsl:choose>
  <!-- Does this node contains attributes? -->
  <xsl:when test="count(./@*)">
    <!-- Yes, contains attributes, we need to make it collapsable -->

    <xsl:choose>

      <!-- Does this node contains only text like "<node>inner text</node>"? -->
      <xsl:when test="count(node())=1 and text()">
        <!-- Yes, only inner text -->
        <table onClick="Toggle(this)" style="cursor: hand;">
          <tr>
            <td style="{$FontStyle} {$VerticalAlignStyle}" width="{$SignColumnWidth}" nowrap="true">
              <b>-</b>
            </td>
            <xsl:text>&#x09;</xsl:text>
            <td style="{$FontStyle} {$VerticalAlignStyle}" width="{$ElementNameColumnWidth}" nowrap="true">
              <b>
                <xsl:value-of select="name()"/>
              </b>
            </td>
            <td style="{$FontStyle} {$VerticalAlignStyle}">
              <xsl:value-of select="text()"/>
            </td>
          </tr>
        </table>
        <div>
          <!-- This div will be hided upon handling the above "onclick" event -->
          <xsl:for-each select='./@*'>
            <table border="0" cellspacing="0">
              <tr>
                <td width="{$SignColumnWidth}" nowrap="true"></td>
                <td width="{$SignColumnWidth}" nowrap="true"></td>
                <!-- We do need 2 sign widths for nice formatting -->
                <td width="{$AttributeIndent}" nowrap="true"></td>
                <td style="{$FontStyle} {$VerticalAlignStyle}" width="{$AttributeNameColumnWidth}" nowrap="true">
                  [ <b>
                    <xsl:value-of select="name()"/>
                  </b>]
                </td>
                <td style="{$FontStyle} {$VerticalAlignStyle}">
                  <xsl:value-of select="."/>
                </td>
              </tr>
            </table>
          </xsl:for-each>
        </div>
      </xsl:when>
      <xsl:otherwise>
        <!-- Not "only inner text -->
        <table onClick="Toggle(this)" style="cursor: hand;">
          <tr>
            <td style="{$FontStyle} {$VerticalAlignStyle}" width="{$SignColumnWidth}" nowrap="true">
              <b>-</b>
            </td>
            <xsl:text>&#x09;</xsl:text>
            <td style="{$FontStyle} {$VerticalAlignStyle}" width="{$ElementNameColumnWidth}" nowrap="true">
              <b>
                <xsl:value-of select="name()"/>
              </b>
            </td>
          </tr>
        </table>
        <div>
          <!-- Deal with attributes -->
          <xsl:for-each select='./@*'>
            <table border="0" cellspacing="0">
              <tr>
                <td width="{$SignColumnWidth}" nowrap="true"></td>
                <td width="{$SignColumnWidth}" nowrap="true"></td>
                <!-- We do need 2 sign widths for nice formatting -->
                <td width="{$AttributeIndent}" nowrap="true"></td>
                <td style="{$FontStyle} {$VerticalAlignStyle}" width="{$AttributeNameColumnWidth}" nowrap="true">
                  [ <b>
                    <xsl:value-of select="name()"/>
                  </b>]
                </td>
                <td style="{$FontStyle} {$VerticalAlignStyle}">
                  <xsl:value-of select="."/>
                </td>
              </tr>
            </table>
          </xsl:for-each>

          <!-- Deal with sub-nodes -->
          <xsl:for-each select="node()">
            <table border="0" cellspacing="0">
              <tr>
                <td width="{$SignColumnWidth}" nowrap="true"></td>
                <td width="{$indent}" nowrap="true"></td>
                <td style="{$FontStyle} {$VerticalAlignStyle}">
                  <xsl:call-template name="node"/>
                </td>
              </tr>
            </table>
          </xsl:for-each>
        </div>
      </xsl:otherwise>
    </xsl:choose>

  </xsl:when>
  <xsl:otherwise>
    <!-- Contains no attributes. Whether to be collapsable depends on whether it has children. -->
    <!-- Does this node contains only text like "<node>inner text</node>"? -->
    <xsl:choose>
      <xsl:when test="count(node())=1 and text()">
        <!-- Only has inner text -->
        <table>
          <tr>
            <td style="{$FontStyle} {$VerticalAlignStyle}" width="{$SignColumnWidth}" nowrap="true"></td>
            <td style="{$FontStyle} {$VerticalAlignStyle}" width="{$ElementNameColumnWidth}" nowrap="true">
              <b>
                <xsl:value-of select="name()"/>
              </b>
            </td>
            <td style="{$FontStyle} {$VerticalAlignStyle}">
              <xsl:value-of select="text()"/>
            </td>
          </tr>
        </table>
      </xsl:when>
      <xsl:otherwise>
        <!-- Not "only inner text" -->

        <!-- Does this node have children? -->
        <xsl:choose>
          <xsl:when test="count(node())">
            <table onClick="Toggle(this)" style="cursor: hand;">
              <tr>
                <td style="{$FontStyle} {$VerticalAlignStyle}" width="{$SignColumnWidth}" nowrap="true">
                  <b>-</b>
                </td>
                <xsl:text>&#x09;</xsl:text>
                <td style="{$FontStyle} {$VerticalAlignStyle}" width="{$ElementNameColumnWidth}" nowrap="true">
                  <b>
                    <xsl:value-of select="name()"/>
                  </b>
                </td>
              </tr>
            </table>
            <div>
              <xsl:for-each select="node()">
                <table border="0" cellspacing="0">
                  <tr>
                    <td width="{$SignColumnWidth}" nowrap="true"></td>
                    <td width="{$indent}" nowrap="true"></td>
                    <td style="{$FontStyle} {$VerticalAlignStyle}">
                      <xsl:call-template name="node"/>
                    </td>
                  </tr>
                </table>
              </xsl:for-each>
            </div>
          </xsl:when>
          <xsl:otherwise>
            <!-- No children -->
            <table>
              <tr>
                <td style="{$FontStyle} {$VerticalAlignStyle}" width="{$SignColumnWidth}" nowrap="true"></td>
                <td style="{$FontStyle}">
                  <b>
                    <xsl:value-of select="name()"/>
                  </b>
                </td>
              </tr>
            </table>
          </xsl:otherwise>
        </xsl:choose>
      </xsl:otherwise>
    </xsl:choose>

  </xsl:otherwise>
</xsl:choose>

</xsl:otherwise>
</xsl:choose>
</xsl:template>

<!-- Template for "EventData". This is used for "System\EventData" only. -->
<xsl:template name="EventDataNode">
  <!-- Does this node have children? -->
  <xsl:choose>
    <xsl:when test="count(node())">
      <table onClick="Toggle(this)" style="cursor: hand;">
        <tr>
          <td style="{$FontStyle} {$VerticalAlignStyle}" width="{$SignColumnWidth}" nowrap="true">
            <b>-</b>
          </td>
          <!-- &#&#x09; is tab -->
          <xsl:text>&#x09;</xsl:text>
          <td style="{$FontStyle} {$VerticalAlignStyle}" width="{$ElementNameColumnWidth}" nowrap="true">
            <b>
              <xsl:value-of select="name()"/>
            </b>
          </td>
        </tr>
      </table>
      <div>
        <xsl:for-each select="node()">
          <table border="0" cellspacing="0">
            <tr>
              <td width="{$SignColumnWidth}" nowrap="true"></td>
              <td width="{$indent}" nowrap="true"></td>
              <td style="{$FontStyle} {$VerticalAlignStyle}" width="{$ElementNameColumnWidth}" nowrap="true">
                <b>
                  <xsl:value-of select="./@Name"/>
                </b>
              </td>
              <td style="{$FontStyle} {$VerticalAlignStyle}">
                <xsl:value-of select="text()"/>
              </td>
            </tr>
          </table>
        </xsl:for-each>
      </div>
    </xsl:when>
    <xsl:otherwise>
      <!-- No children -->
      <table>
        <tr>
          <td style="{$FontStyle} {$VerticalAlignStyle}" width="{$SignColumnWidth}" nowrap="true"></td>
          <td style="{$FontStyle}">
            <b>
              <xsl:value-of select="name()"/>
            </b>
          </td>
        </tr>
      </table>
    </xsl:otherwise>
  </xsl:choose>
</xsl:template>  

</xsl:stylesheet>
