This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: Remove a quote in a string
- To: <xsl-list at lists dot mulberrytech dot com>
- Subject: Re: [xsl] Remove a quote in a string
- From: "Bob DuCharme" <bob at udico dot com>
- Date: Tue, 19 Jun 2001 16:16:06 -0400
- References: <3B2FA4FA.2B34F82C@orionsci.com>
- Reply-To: xsl-list at lists dot mulberrytech dot com
> How do I remove a quote in a string.
> Ex. I have a string in a tag like
> <NAME>O′Neill</NAME>
>
> Now in the NAME template, I want to remove the
> quote ie (′) How do I write a translate statement to remove
> that ′ and replace it with a quote.
How's this:
<xsl:template match="NAME">
<xsl:value-of select="translate(.,'′',"'")"/>
</xsl:template>
Note that because the double quote character (") is used to quote the select
attribute' s value and the apostrophe (') is the third parameter to pass to
the translate() function, I used " and ' entity references to pass
' as a parameter to the function. These two are among the five (along with
lt, gt, and amp) that all XML parsers have to recognize even when they're
not declared.
Bob DuCharme www.snee.com/bob <bob@
snee.com> see http://www.snee.com/bob/xsltquickly for
info on new book "XSLT Quickly" from Manning Publications.
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list