I have an xsl example like this,
<doc>
<para>text . . .text</para>
<para>text . . .text. . . . . .text</para>
</doc>
As you can see, there are several templates in xml, for example, . . .
I need to replace the space between points with *. Therefore, the output should look like this:
<doc>
<para>text .*.*.text</para>
<para>text .*.*.text.*.*.*.*.*.text</para>
</doc>
I wrote the following xslt for this,
<xsl:template match="text()">
<xsl:analyze-string select="." regex="(\.)( )(\.)">
<xsl:matching-substring>
<xsl:value-of select="replace(.,regex-group(2),'*')"/>
</xsl:matching-substring>
<xsl:non-matching-substring>
<xsl:value-of select="."/>
</xsl:non-matching-substring>
</xsl:analyze-string>
</xsl:template>
but it eliminates all other spaces and gives me the following result,
<doc>
<para>text .*. .text</para>
<para>text .*. .text.*. .*. .*.text</para>
</doc>
How can I change my XSLT to get the correct output.
source
share