Look at your variable setup - it should be select="'789'"
if you want to assign the literal '789'
:
<xsl:template match="/">
<xsl:variable name="myVar" select="'789'" />
<xsl:value-of select="row[field1 = 'HEAD'
and contains(field3, $myVar)]/field4"/>
</xsl:template>
Edit : To Clarify
<xsl:variable name="myVar" select="z123" />
Will assign the value of the element z123
(i.e. 789
if the document looked as follows)
<row>
<z123>789</z123>
<field1>HEAD</field1>
Whereas
<xsl:variable name="myVar" select="'z123'" />
Assigns the literal z123
. I'm guessing the reason why a raw See @michael's explanation on WHY the numeric literal works.789
works is because xml elements cannot start with a number and the parser is assuming a literal instead.