Xpath translation function turns things into lowercase?
I am using xpath's translation function to remove some characters 开发者_C百科in a string but it also converts all the letters into lower case. Is this supposed to happen? How can I change this behavior.
The standard XPath function:
translate($someString, $chars-to-be-replaced, $replacement-chars)
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
.
From the XPath 1.0 W3C specification:
Function: string translate(string, string, string)
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 stringBAr
. 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.
Therefore, the problem you have is in the code that you haven't shown.
精彩评论