Lowercase conversion in XSL

时光怂恿深爱的人放手 提交于 2019-12-01 18:02:05

To convert a string to lower case or uppercase you can use the XPath 1.0 function translate:

First define your alphabets for lower case and upper case letters. Note that the position of each pair of characters needs to be the same:

<xsl:variable name="lcletters">abcdefghijklmnopqrstuvwxyz</xsl:variable>
<xsl:variable name="ucletters">ABCDEFGHIJKLMNOPQRSTUVWXYZ</xsl:variable>

Then you can convert to upper case:

<xsl:value-of select="translate($toconvert,$lcletters,$ucletters)"/>

or to lower case

<xsl:value-of select="translate($toconvert,$ucletters,$lcletters)"/>

emp[lower-case(fname)=lower-case($srchStr)]

Or, if you have XPath 1.0 only, you may try using translate like here: http://geekswithblogs.net/TimH/archive/2006/07/06/84229.aspx

Be warned though, the example with translate would not work on names with accents (like mine :)

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!