Xpath 翻译功能把东西变成小写? [英] Xpath translation function turns things into lowercase?

查看:26
本文介绍了Xpath 翻译功能把东西变成小写?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 xpath 的翻译功能来删除字符串中的一些字符,但它也将所有字母转换为小写.这是应该发生的吗?我该如何改变这种行为.

I am using xpath's translation function to remove some characters in a string but it also converts all the letters into lower case. Is this supposed to happen? How can I change this behavior.

推荐答案

标准XPath函数:

translate($someString, $chars-to-be-replaced, $replacement-chars)

产生一个新的字符串,其中 $someString 中的一个字符被改变,只是它是第二个参数中的一个字符——$chars-to-be-replaced.

produces a new string in which a character from $someString is changed only it is one of the characters in the second argument -- $chars-to-be-replaced.

来自 XPath 1.0 W3C 规范:

函数:字符串翻译(字符串,字符串,字符串)

Function: string translate(string, string, string)

翻译功能返回第一个参数字符串字符出现在第二个参数字符串替换为对应的字符第三个参数字符串中的位置.例如,translate("bar","abc","ABC") 返回字符串 BAr.如果有一个第二个参数中的字符没有字符的字符串第三个对应位置参数字符串(因为第二个参数字符串比第三个参数字符串),然后该字符在第一个参数字符串被删除.为了例子,translate("--aaa--","abc-","ABC")返回 "AAA".如果一个字符出现在第二个参数中不止一次字符串,然后第一次出现确定替换字符.如果第三个参数字符串更长比第二个参数字符串,然后多余的字符将被忽略.

The translate function returns the first argument string with occurrences of characters in the second argument string replaced by the character at the corresponding position in the third argument string. For example, translate("bar","abc","ABC") returns the string BAr. If there is a character in the second argument string with no character at a corresponding position in the third argument string (because the second argument string is longer than the third argument string), then occurrences of that character in the first argument string are removed. For example, translate("--aaa--","abc-","ABC") returns "AAA". If a character occurs more than once in the second argument string, then the first occurrence determines the replacement character. If the third argument string is longer than the second argument string, then excess characters are ignored.

因此,您的问题在于您没有显示的代码.

这篇关于Xpath 翻译功能把东西变成小写?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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