如何使用 XSLT 将字符串转换为大写或小写? [英] How can I convert a string to upper- or lower-case with XSLT?

查看:35
本文介绍了如何使用 XSLT 将字符串转换为大写或小写?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在 XSL 中进行大小写转换?

How do you do case conversion in XSL?

<xsl:variable name="upper">UPPER CASE</xsl:variable>
<xsl:variable name="lower" select="???"/>

推荐答案

在 XSLT 1.0 中,upper-case()lower-case() 函数不可用.如果您使用的是 1.0 样式表,则大小写转换的常用方法是 translate():

In XSLT 1.0 the upper-case() and lower-case() functions are not available. If you're using a 1.0 stylesheet the common method of case conversion is translate():

<xsl:variable name="lowercase" select="'abcdefghijklmnopqrstuvwxyz'" />
<xsl:variable name="uppercase" select="'ABCDEFGHIJKLMNOPQRSTUVWXYZ'" />


<xsl:template match="/">
  <xsl:value-of select="translate(doc, $lowercase, $uppercase)" />
</xsl:template>

这篇关于如何使用 XSLT 将字符串转换为大写或小写?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆