Re: [xsl] additional question: FO subscript Revisited

Subject: Re: [xsl] additional question: FO subscript Revisited
From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx>
Date: Wed, 21 Nov 2001 12:31:53 +0000
Hi Tanzila,

> Just a question, I have used the code but I am trying to manipulate
> it so that as well as a 2 it subscripts a 5. But this time the row
> information is duplicated - any suggestions?

The reason it's duplicating the information is that you're doing two
things with the same string at the same time - first substituting the
2 and then substituting the 5. The two choices need to be separate.
Also, you need to make sure that you call the template on the
substring *before* the 2, just in case it contains a 5:

<xsl:template name="replace2s">
  <xsl:param name="string" select="string()" />
  <xsl:variable name="subscript2">
    <fo:inline baseline-shift="sub" font-size="6px">2</fo:inline>
  <xsl:variable name="subscript5">
    <fo:inline baseline-shift="sub" font-size="6px">5</fo:inline>
    <xsl:when test="contains($string, '2')">
      <xsl:call-template name="replace2s">
        <xsl:with-param name="string"
                        select="substring-before($string, '2')" />
      <xsl:copy-of select="$subscript2" />
      <xsl:call-template name="replace2s">
        <xsl:with-param name="string"
                        select="substring-after($string, '2')" />
    <xsl:when test="contains($string, '5')">
      <xsl:value-of select="substring-before($string, '5')" />
      <xsl:copy-of select="$subscript5" />
      <xsl:call-template name="replace2s">
        <xsl:with-param name="string"
                        select="substring-after($string, '5')" />
    <xsl:otherwise><xsl:value-of select="$string" /></xsl:otherwise>

If you keep adding things to the list of characters that need to be
replaced, then you'd be better off with a different approach, so let
us know if that's the case.

I hope that helps,


Jeni Tennison

 XSL-List info and archive:

Current Thread