Just use this template to override the identity rule:
<xsl:template match="UserDefinedField[key('kFieldByName', Name, $vDoc2)]/Value/text()">
<xsl:value-of select="key('kFieldByName', ../../Name, $vDoc2)[1]"/>
</xsl:template>
Here I assume that the second document has a document element (top element) and can contain many UserDefinedField elements at different depth. For convenience only, the second document is inlined in the transformation -- in a real case the doc() function can be used. I also declare an <xsl:key> to efficiently find a new value using the Name child's value of a UserDefinedField in the second document.
Here is the complete transformation:
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output omit-xml-declaration="yes" indent="yes"/>
<xsl:key name="kFieldByName" match="Value" use="../Name"/>
<xsl:variable name="vDoc2">
<patterns>
<UserDefinedField>
<Name>XYZ</Name>
<Value>NEWVALUE!</Value>
</UserDefinedField>
</patterns>
</xsl:variable>
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>
<xsl:template match="UserDefinedField[key('kFieldByName', Name, $vDoc2)]/Value/text()">
<xsl:value-of select="key('kFieldByName', ../../Name, $vDoc2)[1]"/>
</xsl:template>
</xsl:stylesheet>
When this transformation is applied on the provided XML document:
<UserDefinedFields>
<UserDefinedField>
<Name>ABC</Name>
<Value>123</Value>
</UserDefinedField>
<UserDefinedField>
<Name>XYZ</Name>
<Value>645q3245</Value>
</UserDefinedField>
</UserDefinedFields>
the wanted, correct result is produced:
<UserDefinedFields>
<UserDefinedField>
<Name>ABC</Name>
<Value>123</Value>
</UserDefinedField>
<UserDefinedField>
<Name>XYZ</Name>
<Value>NEWVALUE!</Value>
</UserDefinedField>
</UserDefinedFields>