1

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.

Matthew Hui
  • 3,321
  • 2
  • 27
  • 38
  • How about some code that demonstrates your problem? – Steve Wellens May 01 '11 at 22:58
  • As proof by @Dimitre's answer this is a not reproducible problem for `fn:translate()`. Unless you provide an example this is not a real question. –  May 02 '11 at 19:36

1 Answers1

2

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 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.

Therefore, the problem you have is in the code that you haven't shown.

Dimitre Novatchev
  • 240,661
  • 26
  • 293
  • 431