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

From: G. Ken Holman <gkholman@CraneSoftwrights.com>
Date: Thu Sep 30 2010 - 07:49:50 PDT

At 2010-09-30 15:34 +0200, Jacques Foucry wrote:
>On 28 sept. 2010, at 14:55, G. Ken Holman wrote:
>Hello Ken,
>
> > In my example below I have removed the modes and the DocBook and
> it works file in Saxon ... if you try the example below with
> xsltproc and it works, then the issue is, I think, to do with the
> modes in play.
>
>Thanks for your help and your time.
>
>I used the xslt without the node and the "identity for all nodes"
>with saxon (in oxygenXML with XEP) and it failed :

Oh, I wasn't expecting my stylesheet to solve your formatting issue
... I was only asking you to try my stylesheet with your xsltproc to
see if the result successfully translates all the quotes.

>If I remove the "identity for all nodes" it work for all the
>straight quote (transformed into curly quote) except for the
>figure/title (which used to work before).

Right ... because of the mode ... my code was not intended for use in
your stylesheet, only as a standalone test.

>In fact the only way I found to make it work in all case is to have two
>
><xsl:template match="d:title//text()|d:para//text()">
> <xsl:value-of
> select="translate(.,$singlequote,$curlyquote)"/>
></xsl:template>
>
>One with the mode="no.anchor.mode" and another without the mode.
>
>What did think about that ?

That is very acceptable when using XSLT 1.0 ... there is a shortcut
when using XSLT 2.0:

   <xsl:template match="...whatever..." mode="#all">

One approach in XSLT 1.0 to prevent duplication of code is:

   <xsl:template match="...whatever..." mode="no.anchor.mode">
     <xsl:call-template name="handle-quotes"/>
   </xsl:template>
   <xsl:template match="...whatever..." name="handle-quotes">
     <xsl:value-of select="..."/>
   </xsl:template>

... or even the following:

   <xsl:template match="...whatever..." mode="no.anchor.mode">
     <xsl:apply-templates select="."/>
   </xsl:template>
   <xsl:template match="...whatever...">
     <xsl:value-of select="..."/>
   </xsl:template>

(note a reader might think the above is recursive, but it is not
because the <xsl:apply-templates> is in the unnamed default mode, not
in the "no.anchor.mode" mode.)

I hope this helps. Please forgive me for misleading you regarding my
earlier standalone fragment.

. . . . . . . . . . . . . Ken

--
XSLT/XQuery training:   after http://XMLPrague.cz 2011-03-28/04-01
Vote for your XML training:   http://www.CraneSoftwrights.com/f/i/
Crane Softwrights Ltd.          http://www.CraneSoftwrights.com/f/
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 Thu Sep 30 08:15:51 2010

This archive was generated by hypermail 2.1.8 : Thu Sep 30 2010 - 08:15:52 PDT