Re: [xep-support] Replace straight apostrophe with curly apostrophe

From: G. Ken Holman <>
Date: Sun Jan 17 2010 - 11:55:29 PST

At 2010-01-17 11:24 -0500, Harvey, Paul wrote:
>Sounds like the simplest thing in the world, but I can figure this out.
>Whatever I try I get errors along the lines of
>Unmatched quote in expression '
>The problem is - how to select a single apostrophe in XSLT?

If you are working on a simple string, say $input, and you need to do
the replacement of a straight apostrophe to a curly apostrophe, the
following should work:

   <xsl:value-of select='translate($input,"&apos;","&#x201a;")'/>

Following Kevin's approach to translating every straight apostrophe
found in text to a curly apostrophe, that would be:

   <xsl:tempate match="text()">
    <xsl:value-of select='translate(.,"&apos;","&#x201a;")'/>

The trick is just to keep track of the string delimiters and the
attribute delimiters. You can use the attribute delimiter inside the
attribute value if you escape it, and it has to be in whatever string
delimiter that isn't the attribute delimiter.

I hope this helps.

. . . . . . . . . . Ken

UBL and Code List training:      Copenhagen, Denmark 2010-02-08/10
XSLT/XQuery/XPath training after 2010-03-15/19
XSLT/XQuery/XPath training:   San Carlos, California 2010-04-26/30
Vote for your XML training:
Crane Softwrights Ltd.
Training tools: Comprehensive interactive XSLT/XPath 1.0/2.0 video
Video lesson:
Video overview:
G. Ken Holman       
Male Cancer Awareness Nov'07
Legal business disclaimers:
(*) To unsubscribe, send a message with words 'unsubscribe xep-support'
in the body of the message to from the address
you are subscribed from.
(*) By using the Service, you expressly agree to these Terms of Service
Received on Sun Jan 17 12:22:20 2010

This archive was generated by hypermail 2.1.8 : Sun Jan 17 2010 - 12:22:21 PST