Beside Dimitre excellent answer and recomendation, you could something like this stylesheet:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:myNs="myNs"
exclude-result-prefixes="myNs">
<myNs:tr name="data1"/>
<myNs:tr name="data2"/>
<xsl:template match="root">
<root>
<xsl:apply-templates/>
</root>
</xsl:template>
<xsl:template match="data">
<data>
<macro>
<xsl:apply-templates select="document('')/*/myNs:*
[@name=current()]"/>
</macro>
<inline>
<xsl:call-template name="do_job">
<xsl:with-param name="str" select="."/>
</xsl:call-template>
</inline>
</data>
</xsl:template>
<xsl:template match="myNs:tr">
<xsl:call-template name="do_job">
<xsl:with-param name="str" select="@name"/>
</xsl:call-template>
</xsl:template>
<xsl:template name="do_job">
<xsl:param name="str"/>
<xsl:value-of select="translate($str,'data','DATA')"/>
</xsl:template>
</xsl:stylesheet>
With this input:
<root>
<data>data1</data>
<data>data2</data>
<data>data3</data>
</root>
Output:
<root>
<data>
<macro>DATA1</macro>
<inline>DATA1</inline>
</data>
<data>
<macro>DATA2</macro>
<inline>DATA2</inline>
</data>
<data>
<macro></macro>
<inline>DATA3</inline>
</data>
</root>
Note: Also I recomend to you to read Dimitre Novatchev's FXSL in http://fxsl.sf.net/