This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: translate quot to apos


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 ' with
' and not with ''):

        <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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]