[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] 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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|