XSLT String Tools

Published on .

PHP-like string functions as XSLT 1.0 named templates:string-tools.xsl. Edit the parameters, then test.

str_pad: Pad a string to a certain length with another string

Top ↑
<xsl:call-template name="str_pad"> <xsl:with-param name="" select="''"/> <xsl:with-param name="" select="''"/> <xsl:with-param name="" select="''"/> <xsl:with-param name="" select="''"/> </xsl:call-template>

OR

str_repeat: Repeat a string

Top ↑
<xsl:call-template name="str_repeat"> <xsl:with-param name="" select="''"/> <xsl:with-param name="" select="''"/> </xsl:call-template>

OR

str_replace: Replace all occurrences of the search string with the replacement string

Top ↑
<xsl:call-template name="str_replace"> <xsl:with-param name="" select="''"/> <xsl:with-param name="" select="''"/> <xsl:with-param name=""><![CDATA[ ]]></xsl:with-param> </xsl:call-template>

OR

substring-after-last: Returns the rest of a given string after the last given needle

Top ↑
<xsl:call-template name="substring-after-last"> <xsl:with-param name=""><![CDATA[ ]]></xsl:with-param> <xsl:with-param name="" select="''"/> </xsl:call-template>

OR

substring-before-last: Returns the contents of a given string before the last given needle

Top ↑
<xsl:call-template name="substring-before-last"> <xsl:with-param name=""><![CDATA[ ]]></xsl:with-param> <xsl:with-param name="" select="''"/> </xsl:call-template>

OR

wordwrap: Wraps a string to a given number of characters

Top ↑
<xsl:call-template name="wordwrap"> <xsl:with-param name=""><![CDATA[ ]]></xsl:with-param> <xsl:with-param name="" select="''"/> <xsl:with-param name="" select="''"/> </xsl:call-template>

OR