A couple of things I would point out that you are doing the hard way.
1. There is no need for all those <xsl:element> instructions. You can enter xml elements into your output by simply typing them as literals.
2. The hard way to do attributes is to use the <xsl:attribute> instruction.
3. The east way it to use attribute value templates, e.g. field="{xpath}".
So your entire XSLT would look something like this:
Code:
<xsl:template match="catalog">
<add><xsl:apply-templates/></add>
</xsl:template>
<xsl:template match="document">
<doc><xsl:apply-templates/></doc>
</xsl:template>
<xsl:template match="document/*">
<field name="{name()}"><xsl:value-of select="."/></field>
</xsl:template>