Suppose the data string is stored in certain element like this.
[tt]<data>adamsooleywasheretoaskaquestionaboutxmladamwouldlikearesponse</data>
[/tt]
The way to do it is a standard recursion. Here is a version I sketch---maybe not the best.
[tt]
<xsl:template match="//data">
<xsl:call-template name="substr_count">
<xsl:with-param name="str" select="." />
<xsl:with-param name="sub" select="'adam'" />
<xsl:with-param name="cnt" select="0" />
</xsl:call-template>
<xsl:template name="substr_count">
<xsl

aram name="str" />
<xsl

aram name="sub" />
<xsl

aram name="cnt" />
<xsl:choose>
<xsl:when test="contains($str,$sub)">
<xsl:call-template name="substr_count">
<xsl:with-param name="str" select="substring-after($str,$sub)" />
<xsl:with-param name="sub" select="$sub" />
<xsl:with-param name="cnt" select="$cnt+1" />
</xsl:call-template>
</xsl:when>
<xsl

therwise>
<xsl:text>[</xsl:text>
<xsl:value-of select="$cnt" />
<xsl:text>]</xsl:text>
</xsl

therwise>
</xsl:choose>
</xsl:template>
</xsl:template>
[/tt]
Between xsl:text are for cosmetic, inside it shows the result.
ps: How much study you do on your own? That looks very like assignment though often not obvious at the beginning.