Тебе не кажется, что это лучшая логика?
<xsl:variable name="$test_alerts" select="$all_alerts[contains('|MFL|BSL|CCT|NHSL|',concat('|',g:line_abbr,'|')]"/>
<xsl:if test="$test_alerts">
<b>Subway</b><br /><br />
<xsl:for-each select="$test_alerts">
<xsl:sort select="g:line_abbr">
<xsl:if test="g:problem != 'normal_service'">
<xsl:value-of select="concat(g:line,' | ')"/>
<a href="/m/alert/{translate(g:line_abbr,'MFLBSCTNH','mflbsctnh')}.html">
<xsl:call-template name="capitalize">
<xsl:with-param name="string" select="g:problem"/>
<xsl:call-template>
</xsl:if>
</xsl:for-each>
</xsl:if>
............................................
<xsl:template name="capitalize">
<xsl:param name="string"/>
<xsl:param name="norm-string" select="concat($string,'_')"/>
<xsl:if test="$norm-string != ''">
<xsl:value-of select="concat(translate(substring($norm-string,1,1),
'qwertyuiopasdfghjklzxcvbnm',
'QWERTYUIOPASDFGHJKLZXCVBNM'),
substring(substring-before($norm-string,'_'),2),
' ')"/>
<xsl:call-template name="capitalize">
<xsl:with-param name="norm-string"
select="substring-after($norm-string,'_')"/>
<xsl:call-template>
</xsl:if>
</xsl:template>