Re: [xsl] Question on translate() function

Subject: Re: [xsl] Question on translate() function
From: "Michael Kay mike@xxxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Tue, 26 Sep 2017 10:31:52 -0000
> On 26 Sep 2017, at 10:20, Mailing Lists Mail daktapaal@xxxxxxxxx
<xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote:
>
> >>It's valid, but it does something
> >>completely different from what the
> >>user probably intended.
> What does it do ?

It replaces every occurrence of "A" by "x", deletes all occurrences of B, C,
D, and E, and leaves all other characters unchanged.

Michael Kay
Saxonica
>
>
> On Sep 26, 2017 4:32 AM, "Michael Kay mike@xxxxxxxxxxxx
<mailto:mike@xxxxxxxxxxxx>" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx
<mailto:xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>> wrote:
>
> > I have seen expressions like :
> > translate($xxx, 'ABCDE','x');
> > which is to say, replace ABCDE with x .. this also works fine
> > is this not valid?
>
> I have seen expressions like this too. It's up there in the list of common
XPath coding mistakes. It's valid, but it does something completely different
from what the user probably intended. One of those mistakes you make if you
guess what a function does from its name, without actually reading the spec.
>
> Michael Kay
> Saxonica
>
>
> XSL-List info and archive <http://www.mulberrytech.com/xsl/xsl-list>
> EasyUnsubscribe <-list/293509> (by email <>)

Current Thread