translate($string ,'()''+-*$=' , '#')
That means "replace '(' by '#', remove any occurrences of ')' or ' or '+' or
'-' or '*' or '$' or '=', and leave anything else unchanged."
If you want all the characters in the second argument to be replaced by '#'
characters then you need to write
translate($string ,'()''+-*$=' , '########')
Alternatively, use the replace() function.
Michael Kay
Saxonica
On 25 Sep 2017, at 16:20, Mailing Lists Mail daktapaal(_at_)gmail(_dot_)com
<xsl-list-service(_at_)lists(_dot_)mulberrytech(_dot_)com> wrote:
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
()''+-*$= will all be replaced with #
dakT
XSL-List info and archive <http://www.mulberrytech.com/xsl/xsl-list>
EasyUnsubscribe <-list/293509> (by email <>)
--~----------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
EasyUnsubscribe: http://lists.mulberrytech.com/unsub/xsl-list/1167547
or by email: xsl-list-unsub(_at_)lists(_dot_)mulberrytech(_dot_)com
--~--