<?xml version="1.0" encoding="UTF-8"?> 
<xsl:stylesheet version = '1.0'
     xmlns:xsl='http://www.w3.org/1999/XSL/Transform'>


<xsl:output method="xhtml"/>

<xsl:template match="*[not(@id)]">
      <xsl:element name="{name()}">
            <xsl:for-each select="attribute::*">
             <xsl:attribute name="{name()}">
                <xsl:value-of select="."/>
            </xsl:attribute>                
            </xsl:for-each>

            <xsl:attribute name="id">
                <xsl:value-of select="name()"/>
                <xsl:text>-#position#</xsl:text>
            </xsl:attribute> 
           <xsl:apply-templates/>
      </xsl:element>
</xsl:template>

<xsl:template match="*">
        <xsl:element name="{name()}">
             <xsl:for-each select="attribute::*">
             <xsl:attribute name="{name()}">
                <xsl:value-of select="."/>
            </xsl:attribute>                
            </xsl:for-each>
           <xsl:apply-templates/>
      </xsl:element>
</xsl:template>

</xsl:stylesheet>
