« XSLT to get the possessive of a noun | Home | XSLT to escape single quotes and double quotes »
XSLT to strip HTML tags
This template will URL escape the following special charaters:
>
<
"
'
&
(white space)
-
_
@
The escaped text string is returned by the template.
Feel free to add more characters as needed.
-->
<xsl:template name="common_url_escape">
<!-- required -->
<xsl:param name="text"/>
<xsl:variable name="tmp">
<xsl:call-template name="replace-substring">
<xsl:with-param name="from" select="'>'"/>
<xsl:with-param name="to"><![CDATA[%3E]]></xsl:with-param>
<xsl:with-param name="value">
<xsl:call-template name="replace-substring">
<xsl:with-param name="from" select="'<'"/>
<xsl:with-param name="to"><![CDATA[%3C]]></xsl:with-param>
<xsl:with-param name="value">
<xsl:call-template name="replace-substring">
<xsl:with-param name="from" select="'"'"/>
<xsl:with-param name="to"><![CDATA[%22]]></xsl:with-param>
<xsl:with-param name="value">
<xsl:call-template name="replace-substring">
<xsl:with-param name="from">'</xsl:with-param>
<xsl:with-param name="to"><![CDATA[%60]]></xsl:with-param>ame="value">
<xsl:call-template name="replace-substring">
<xsl:with-param name="from" select="'&'"/>
<xsl:with-param name="to"><![CDATA[%26]]></xsl:with-param>ame="value">
<xsl:call-template name="replace-substring">
<xsl:with-param name="from" select="' '"/>
<xsl:with-param name="to"><![CDATA[%20]]></xsl:with-param>
<xsl:with-param name="value">
<xsl:call-template name="replace-substring">
<xsl:with-param name="from" select="'-'"/>
<xsl:with-param name="to"><![CDATA[%2D]]></xsl:with-param>
<xsl:with-param name="value">
<xsl:call-template name="replace-substring">
<xsl:with-param name="from" select="'_'"/>
<xsl:with-param name="to"><![CDATA[%5F]]></xsl:with-param>
<xsl:with-param name="value">
<xsl:call-template name="replace-substring">
<xsl:with-param name="from" select="'#'"/>
<xsl:with-param name="to"><![CDATA[%23]]></xsl:with-param>
<xsl:with-param name="value">
<xsl:call-template name="replace-substring">
<xsl:with-param name="from" select="'?'"/>
<xsl:with-param name="to"><![CDATA[%3F]]></xsl:with-param>
<xsl:with-param name="value">
<xsl:call-template name="replace-substring">
<xsl:with-param name="from" select="'@'"/>
<xsl:with-param name="to"><![CDATA[%40]]></xsl:with-param>
<xsl:with-param name="value" select="$text" /></xsl:template>
Topics: XSLT | Submitter: admin
Comments
You must be logged in to post a comment.