This is how my source file looks like:
It's a bit ugly but it does what you want and sorry if the first time did not understand well.
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:jndi="urn:jboss:jndi-binding-service:1.0" >
<xsl:output method="xml" version="1.0" encoding="utf-8" indent="yes" />
<xsl:template match="book/book">
<book>
<mbean code="org.book.mybooks" name="mycompany.props.jndi:name=mybookprops">
<attribute name="bookprops">
<xsl:copy-of select="mbean/attribute/text()"/>
<xsl:call-template name="Mbean">
<xsl:with-param name="bindings" select="mbean/attribute"/>
<xsl:with-param name="bindingsP" select="/book/mbean/attribute/text()"/>
</xsl:call-template>
</attribute>
</mbean>
</book>
</xsl:template>
<xsl:template name="Mbean">
<xsl:param name="bindings"/>
<xsl:param name="bindingsP"/>
<xsl:choose>
<xsl:when test="contains($bindingsP,'@Value@')">
<xsl:if test="not(contains(substring-before($bindingsP,'@Value@'),'@Value@')) and not(contains(substring-before($bindingsP,'@Value@'),'@New_Value@')) and not(contains($bindings,concat(substring-before($bindingsP,'@Value@'),'@Value@')))">
<xsl:copy-of select="concat(substring-before($bindingsP,'@Value@'),'@Value@')"/>
<xsl:call-template name="Mbean">
<xsl:with-param name="bindings" select="$bindings"/>
<xsl:with-param name="bindingsP" select="substring-after($bindingsP,'@Value@')"/>
</xsl:call-template>
</xsl:if>
</xsl:when>
<xsl:when test="contains($bindingsP,'@New_Value@')">
<xsl:if test="not(contains(substring-before($bindingsP,'@Value@'),'@Value@')) and not(contains(substring-before($bindingsP,'@Value@'),'@New_Value@')) and not(contains($bindings,concat(substring-before($bindingsP,'@New_Value@'),'@New_Value@')))">
<xsl:copy-of select="concat(substring-before($bindingsP,'@New_Value@'),'@New_Value@')"/>
<xsl:call-template name="Mbean">
<xsl:with-param name="bindings" select="$bindings"/>
<xsl:with-param name="bindingsP" select="substring-after($bindingsP,'@New_Value@')"/>
</xsl:call-template>
</xsl:if>
</xsl:when>
</xsl:choose>
</xsl:template>
<xsl:template match="text()"/>
</xsl:stylesheet>