Try it this way:
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main"
xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships"
xmlns:rel="http://schemas.openxmlformats.org/package/2006/relationships"
exclude-result-prefixes="w r rel">
<xsl:template match="w:hyperlink">
<a>
<xsl:variable name="rId">
<xsl:value-of select="@r:id"/>
</xsl:variable>
<xsl:if test="/mergeddocx/rel:Relationships">
<xsl:attribute name="href">
<xsl:value-of select="$rId"/>
</xsl:attribute>
</xsl:if>
<xsl:attribute name="target">
<xsl:text>_blank</xsl:text>
</xsl:attribute>
</a>
</xsl:template>
</xsl:stylesheet>
Note the difference between the xmlns:r and xmlns:rel namespaces.They are not the same.