diff --git a/modules/basic-text-formatting.xml b/modules/basic-text-formatting.xml index 6b8ea5f..c679eac 100644 --- a/modules/basic-text-formatting.xml +++ b/modules/basic-text-formatting.xml @@ -138,6 +138,34 @@ </div> </common> </template> + + + <!-- + Convert the input string into Title Case. + + $input-string: The string to be converted. + + Returns: The converted string. + --> + <function name="infosci:title-case" as="xs:string"> + <common> + <xsl:param name="input-string" /> + <xsl:variable name="output-string"> + <xsl:choose> + <xsl:when test="contains($input-string, ' ')"> + <xsl:value-of select="infosci:title-case(substring-before($input-string, ' '))" /> + <xsl:text> </xsl:text> + <xsl:value-of select="infosci:title-case(substring-after($input-string, ' '))" /> + </xsl:when> + <xsl:otherwise> + <xsl:value-of select="concat(upper-case(substring($input-string, 1, 1)), substring($input-string, 2))" /> + </xsl:otherwise> + </xsl:choose> + </xsl:variable> + + <xsl:sequence select="$output-string" /> + </common> + </function> </stylesheet>