Re: translate quot to apos

Subject: Re: translate quot to apos
From: "Andrea Penna" <andreapenna@xxxxxxxxx>
Date: Wed, 23 Aug 2000 13:33:51 +0200
Similar problem here:

I have to change all "quote" and "apos" before use the string as a
javascript-function argument.
So I need to change every  "apos" to "\apos" or to "apos apos" and the same
with "quote" too.

But if I'm not wrong the translate function can substitute one character
with only another one and not with two or more:
"If the third argument string is longer than the second argument string,
then excess characters are ignored"
(from http://zvon.org/xxl/XSLTreference/Output/index.html site).

Also if I use variables. How to solve this?

This is the piece of my xsl file (not working because replacing &#39; with
&#39; and not with &#39;&#39;):

        <xsl:variable name="apos">&#39;</xsl:variable>
        <xsl:variable name="apos2">&#39;&#39;</xsl:variable>
        <xsl:variable name="quote">&#34;</xsl:variable>
        <xsl:variable name="quote2">&#34;&#34;</xsl:variable>
        <xsl:variable name="Abstract1" select="normalize-space(.)"/>
        <xsl:variable name="Abstract2"
select="translate($Abstract1,$apos,$apos2)"/>
        <xsl:variable name="Abstract3"
select="translate($Abstract2,$quote,$quote2)"/>
        <xsl:attribute name="onclick">NewWindow('<xsl:value-of
select="$Abstract3"/>')</xsl:attribute>

Thank you,
Andrea

> Best way is to use variables:
>
> <xsl:variable name="quot">"</xsl:variable>
> <xsl:variable name="apos">'</xsl:variable>
> <xsl:value-of select="translate(Tag1, $quot, $apos)"/>
>
> Mike Kay




 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread