[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: additional question: FO subscript Revisited

Subject: RE: additional question: FO subscript Revisited
From: "Tanzila Mohammad" <tmohammad@xxxxxxxxxxxxxxxxxxxx>
Date: Wed, 21 Nov 2001 12:54:07 -0000
xsl fo subscripts
Thanks Jeni.

The list of characters may get larger and larger over time.

Tanzila

-----Original Message-----
From: Jeni Tennison [mailto:jeni@xxxxxxxxxxxxxxxx]
Sent: 21 November 2001 12:32
To: Tanzila Mohammad
Cc: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: Re:  additional question: FO subscript Revisited


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

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

---
Jeni Tennison
http://www.jenitennison.com/




 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.