Well, each ROW has one element child, so the for-each select="*" selects one node, and the position of that node is always 1. So $pos is always 1. $ItemIndex is a sequence of integers of length 1 (specifically, a singleton integer whose value is zero), so $ItemIndex[$pos] is the first integer in this sequence, which is zero. I've no idea what you had in mind when you wrote this code.
Try:
Code:
<xsl:template match="ROW">
<xsl:number/>
<xsl:value-of select="ERROR_MESSAGE"/>
</xsl:template>