My objective is analyze the text() node of a given XML document and identify the upper case words and if that word length > 3 add '*' character in between 3,4 characters (6,7 and 9,10.....)
example,
input XML :
<chap>
<para>The BEGINNING of this COLUMN shows the INPUT and output</para>
</chap>
desired output:
<chap>
<para>The BEG*INN*ING of this COL*UMN shows the INP*UT and output</para>
</chap>
I've written following xsl to do this task,
<xsl:template match="para">
<xsl:analyze-string select="." regex="[(A-Z)]">
<xsl:matching-substring>
<xsl:variable name="reg" select="string(regex-group(0))"/>
<xsl:call-template name="add-star">
<xsl:with-param name="str" select="$reg"/>
</xsl:call-template>
</xsl:matching-substring>
<xsl:non-matching-substring>
<xsl:value-of select="."/>
</xsl:non-matching-substring>
</xsl:analyze-string>
</xsl:template>
<xsl:template name="add-star">
<xsl:param name="str" as="xs:string"/>
<xsl:if test="string-length($str)>3">
<xsl:call-template name="add-star">
<xsl:with-param name="str" select="substring($str,4,200)"/>
</xsl:call-template>
</xsl:if>
<xsl:sequence select="string-join(substring($str,1,3),'*')"/>
</xsl:template>
but it does not work as expected.since there is no variables like oop languages I'm struggling to to this task in XSLT, could anyone suggest me how can I modify my code to do this task?