I use param to the outside to control xslt
The first parameter indicates the length of a string
The second parameter is the string being searched
by specifying
and not (preceding-sibling:: Child [substring (.,1,$length) = $alpha]
only the first matching child node appears
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output indent="yes" method="html"/>
<xsl:param name="length" select="1"/>
<xsl:param name="alpha" select="'B'"/>
<xsl:template match="/">
<html>
<body>
<xsl:apply-templates select="Parent"/>
</body>
</html>
</xsl:template>
<xsl:template match="Parent">
<table>
<xsl:apply-templates select="Child"/>
</table>
</xsl:template>
<xsl:template match="Child">
<xsl:if test="(substring(.,1,$length) = $alpha) and not(preceding-sibling::Child[substring(.,1,$length) = $alpha])">
<tr>
<td id="Row{position()}">
<xsl:value-of select="."/>
</td>
</tr>
</xsl:if>
</xsl:template>
</xsl:stylesheet>
result param1=1 param2='B'
<html>
<body>
<table>
<tr>
<td id="Row5">BZA</td>
</tr>
</table>
</body>
</html>