This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: additional question: FO subscript Revisited
- From: Jeni Tennison <jeni at jenitennison dot com>
- To: "Tanzila Mohammad" <tmohammad at entier-solutions dot com>
- Cc: xsl-list at lists dot mulberrytech dot com
- Date: Wed, 21 Nov 2001 12:31:53 +0000
- Subject: Re: [xsl] additional question: FO subscript Revisited
- Organization: Jeni Tennison Consulting Ltd
- References: <EBEKJPOMOCIKIIPPEBHBEEMFCHAA.tmohammad@entier-solutions.com>
- Reply-to: xsl-list at lists dot mulberrytech dot com
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