<?xml version="1.0" encoding="utf-8" ?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>
<xsl:template match="/">
<xsl:call-template name="visit" >
<xsl:with-param name="depth" select="0" />
</xsl:call-template>
</xsl:template>
<xsl:template name="visit">
<xsl:param name="depth" />
<xsl:value-of select="concat( name(), ':', $depth, ' ')" />
<xsl:variable name="i" select="$depth + 1" />
<xsl:for-each select="child::*">
<xsl:call-template name="visit" >
<xsl:with-param name="depth" select="$i" />
</xsl:call-template>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>