[ACCEPTED]-XSLT Stylesheet: Changing text to upper case-uppercase
Accepted answer
XSLT 2.0 has fn:upper-case() and fn:lower-case() functions. However 2 in case you are using of XSLT 1.0, you can 1 use translate():
<xsl:template match="/">
<xsl:variable name="smallcase" select="'abcdefghijklmnopqrstuvwxyz'" />
<xsl:variable name="uppercase" select="'ABCDEFGHIJKLMNOPQRSTUVWXYZ'" />
<xsl:value-of select="translate(doc, $smallcase, $uppercase)" />
</xsl:template>
You can use the translate()
function in XSLT 1.0:
<xsl:value-of select="translate(//some-xpath,
'abcdefghijklmnopqrstuvwxyz',
'ABCDEFGHIJKLMNOPQRSTUVWXYZ')" />
If 3 you're lucky enough to have access to XSLT 2 2.0, you can use the upper-case()
function:
<xsl:value-of select="upper-case(//some-xpath)"/>
See the XPath function reference page for 1 more details.
Use an Assembly like this:
<msxsl:script implements-prefix="user" language="C#">
<!--{%assembly%}-->
<![CDATA[
public string ToUpper(string stringValue)
{
string result = String.Empty;
if(!String.IsNullOrEmpty(stringValue))
{
result = stringValue.ToUpper();
}
return result;
}
]]>
</msxsl:script>
Call it as follows: select="user:ToUpper(//root/path)"
This 1 can be used in 1.0 or 2.0.
Source:
stackoverflow.com
More Related questions
Cookie Warning
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.