仅使用 xslt 1.0 小写字符串的第一个字符

发布于 2024-07-15 09:21:08 字数 280 浏览 5 评论 0原文

我已经看到模式 对于那些使用 xslt 1.0 的人来说,使用 translate 函数将字符串翻译成小写(或大写)。

有没有一种优雅的方法可以将字符串的第一个字母变成小写?

TestCase => testCase

I have seen patterns for translating a string into lower (or upper case) using the translate function for folks stuck using xslt 1.0.

Is there a elegant way of just making the first letter of a string lowercase?

TestCase => testCase

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

浮云落日 2024-07-22 09:21:08

例如,如果您的字符串位于名为 name 的属性中:

<xsl:value-of select="concat(translate(substring(@name, 1, 1), 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz'), substring(@name, 2))"/>

If your string were, for example, in an attribute called name:

<xsl:value-of select="concat(translate(substring(@name, 1, 1), 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz'), substring(@name, 2))"/>
梦幻的心爱 2024-07-22 09:21:08

您应该能够组合 substringconcat 与翻译类似:

concat(translate(substring(s,1,1), $smallcase, $uppercase),substring(s,2))

You should be able to combine substring and concat with translate to do it like so:

concat(translate(substring(s,1,1), $smallcase, $uppercase),substring(s,2))
囚我心虐我身 2024-07-22 09:21:08

使用 XPath translate 函数,将字符串分成第一个字符和其余字符。 这将需要使用多个变量来保存中间结果的冗长 XSLT。

Use the XPath translate function, having separated the string into first character and the rest. This will require somewhat long winded XSLT using multiple variables to hold intermediate results.

失退 2024-07-22 09:21:08

XSLT 有一个子字符串函数,因此您可以将该模式与子字符串函数结合使用来获得您想要的内容。

XSLT has a substring function, so you could use that pattern with the substring function to get what you want.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文