Name
contains() Function — Determines if the first argument string contains the second.
Synopsis
booleancontains(stringstring)
Inputs
Two strings. If the first string contains the second string, the function returns the boolean value true.
Output
The boolean value true if the first argument contains the second; false otherwise.
Defined in
XPath section 4.2, String Functions.
Example
This stylesheet uses the replace-substring named template. It passes three arguments to the replace-substring template: the original string, the substring to be searched for in the original string, and the substring to replace the target substring in the original string. The replace-substring template uses the contains(), substring-after(), and substring-before() functions extensively.
Here is our sample stylesheet. It replaces all occurrences of World with the string “Mundo”:
<?xml version="1.0"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:output method="text"/> <xsl:template match="/"> <xsl:variable name="test"> <xsl:call-template name="replace-substring"> <xsl:with-param name="original">Hello World!</xsl:with-param> <xsl:with-param name="substring">World</xsl:with-param> <xsl:with-param name="replacement">Mundo</xsl:with-param> </xsl:call-template> </xsl:variable> <xsl:value-of select="$test"/> </xsl:template> <xsl:template name="replace-substring"> <xsl:param name="original"/> <xsl:param name="substring"/> <xsl:param name="replacement" select="''"/> <xsl:variable ...