<xsl:stylesheet version="1.0">

  <xsl:output method="html"/>

  <xsl:variable name="color-ele-name" select="'red'"/>
  <xsl:variable name="color-attr-name" select="'green'"/>
  <xsl:variable name="color-attr-value" select="'blue'"/>
  <xsl:variable name="color-comment" select="'blue'"/>

  <xsl:template match="/">
      <html>
          <body>
	          <pre>
                  <xsl:apply-templates/>
	          </pre>
          </body>
      </html>
  </xsl:template>

  <--
| Match ELEMENTs
-->
<xsl:template match="*"> <xsl:param name="indent"/> <xsl:value-of select="$indent"/> <xsl:text/> <FONT COLOR="{$color-ele-name}"> <xsl:value-of select="name()"/> </FONT> <xsl:apply-templates select="@*"/> <xsl:choose> <xsl:when test="child::*"> <xsl:text/> <xsl:apply-templates select="*|text()|comment()"> <xsl:with-param name="indent" select="concat($indent, ' ')"/> </xsl:apply-templates> <xsl:value-of select="$indent"/> <xsl:text/> <FONT COLOR="{$color-ele-name}"> <xsl:value-of select="name()"/> </FONT> <xsl:text/> </xsl:when> <xsl:otherwise> <xsl:text/> </xsl:otherwise> </xsl:choose> </xsl:template> <--
| Match ATTRIBUTEs
-->
<xsl:template match="@*"> <xsl:text/> <FONT COLOR="{$color-attr-name}"> <xsl:value-of select="name()"/> </FONT> <xsl:text/> <FONT COLOR="{$color-attr-value}"> <xsl:value-of select="."/> </FONT> <xsl:text/> </xsl:template> <--
| Match COMMENT
-->
<xsl:template match="comment()"> <xsl:param name="indent"/> <xsl:value-of select="$indent"/> <xsl:text/> <BR/> <xsl:value-of select="$indent"/> <FONT COLOR="{$color-comment}"> <xsl:value-of select="."/> </FONT> <BR/> <xsl:value-of select="$indent"/> <xsl:text/> <BR/> </xsl:template> <--
| Match TEXT
-->
<xsl:template match="text()"> <xsl:param name="indent"/> <xsl:choose> <xsl:when test="normalize-space(.)"> <BR/> <xsl:value-of select="$indent"/> <xsl:value-of select="."/> <BR/> </xsl:when> <xsl:otherwise> <xsl:value-of select="."/> </xsl:otherwise> </xsl:choose> </xsl:template> </xsl:stylesheet>