Использовать Muechian группирование с XSLT 1.0:
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:key name="k1" match="element" use="translate(@Key, translate(@Key, '0123456789', ''), '')"/>
<xsl:output method="html" indent="yes"/>
<xsl:template match="root">
<div>
<xsl:apply-templates select="element[generate-id() = generate-id(key('k1', translate(@Key, translate(@Key, '0123456789', ''), ''))[1])]" mode="group"/>
</div>
</xsl:template>
<xsl:template match="element" mode="group">
<b>Card <xsl:value-of select="translate(@Key, translate(@Key, '0123456789', ''), '')"/>:</b>
<xsl:apply-templates select="key('k1', translate(@Key, translate(@Key, '0123456789', ''), ''))"/>
</xsl:template>
<xsl:template match="element">
<xsl:value-of select="concat(substring-after(., '_'), ': ', .)"/>
<br/>
</xsl:template>
</xsl:stylesheet>
С этой таблицей стилей Saxon 6.5.5 преобразует
<root>
<element Key="card1_id">123</element>
<element Key="card1_balance">500</element>
<element Key="card2_id">456</element>
<element Key="card2_balance">800</element>
.............................................
<element Key="card3_id">999</element>
<element Key="card3_balance">8000</element>
</root>
в
<div><b>Card 1:</b>: 123<br>: 500<br><b>Card 2:</b>: 456<br>: 800<br><b>Card 3:</b>: 999<br>: 8000<br></div>