Topic
  • 1 reply
  • Latest Post - ‏2012-11-15T09:53:22Z by SystemAdmin
SystemAdmin
SystemAdmin
1138 Posts

Pinned topic Need optimized XSLT recursive template to strip html tags.

‏2012-11-15T09:50:57Z |
Hi Everybody,

I am using the following template for removing the html tags from my xml content. It is working for few of the xmls but failing for few with stack over flow error. Can anybody provide the optimized solutions for the same?

<xsl:template name="strip-tags">
<xsl:param name="text"/>
<xsl:choose>
<xsl:when test="contains($text, '&lt;')">
<xsl:value-of select="substring-before($text, '&lt;')"/>
<xsl:call-template name="strip-tags">
<xsl:with-param name="text" select="substring-after($text, '&gt;')"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$text"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>

Calling the template with below code.

<xsl:call-template name="strip-tags">
<xsl:with-param name="text" select="Test/Htmlcontent"/>
</xsl:call-template>
Can anybody provide the optimized solutions for the same?

Thanks,
Raju
Updated on 2012-11-15T09:53:22Z at 2012-11-15T09:53:22Z by SystemAdmin
  • SystemAdmin
    SystemAdmin
    1138 Posts

    Re: Need optimized XSLT recursive template to strip html tags.

    ‏2012-11-15T09:53:22Z  
    I am using xslt 1.0 version.