[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Question on translate() function

Subject: Question on translate() function
From: "Mailing Lists Mail daktapaal@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Mon, 25 Sep 2017 15:20:20 -0000
 Question on translate() function
I am using the translate() for some operation looks like I am getting
something I am not expecting .. Am I missing something?

I am making the following call to the custom function :

<xsl:value-of select="k7:replace-chars-in-string('if($xyz-(abc-bcd)')"/>


Function definition ..
<xsl:function name="k7:replace-chars-in-string">
<xsl:param name="string"/>
<!--examples :
$xxx,
,$xxx
($xxx
$xxx)
=$xxx
$xxx=
$xxx*
*$xxx
$xxx-
-$xxx
+$xxx
$xxx+

$xx+$yy-$zz

returns
#xx
or xx#
or #x#yy# etc.. replaces the operators after/before the stringto '#'

-->

<xsl:value-of select="translate($string ,'()''+-*$=' , '#')"/>
</xsl:function>


What I get is : if#xyz#abcbcd


What I was expecting / I want : if##xyz#abc#bcd#


Thing that is perticularly bothering me is abcbcd and not abc#bcd


My understanding about the translate() function is that the second param is
the list of chars you want to replace, the third param is the char you want
to replace with. SO I was  hoping that

()''+-*$=b will all be replaced with #


dakT

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.