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

From: G. Ken Holman <gkholman@CraneSoftwrights.com>
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;")'/>
   </xsl:template>

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 http://XMLPrague.cz 2010-03-15/19
XSLT/XQuery/XPath training:   San Carlos, California 2010-04-26/30
Vote for your XML training:   http://www.CraneSoftwrights.com/f/i/
Crane Softwrights Ltd.          http://www.CraneSoftwrights.com/f/
Training tools: Comprehensive interactive XSLT/XPath 1.0/2.0 video
Video lesson:    http://www.youtube.com/watch?v=PrNjJCh7Ppg&fmt=18
Video overview:  http://www.youtube.com/watch?v=VTiodiij6gE&fmt=18
G. Ken Holman                 mailto:gkholman@CraneSoftwrights.com
Male Cancer Awareness Nov'07  http://www.CraneSoftwrights.com/f/bc
Legal business disclaimers:  http://www.CraneSoftwrights.com/legal
-------------------
(*) To unsubscribe, send a message with words 'unsubscribe xep-support'
in the body of the message to majordomo@renderx.com from the address
you are subscribed from.
(*) By using the Service, you expressly agree to these Terms of Service http://www.renderx.com/terms-of-service.html
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