Subject: RE: [xsl] using substring-functions more than once in a node? From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx> Date: Tue, 26 Mar 2002 14:25:55 -0500 |
Cheers, Wendell
Hi.
You can define a template that matches a footnote, and calls itself recursively so that it gets them all. Something like this (untested):
<xsl:template name="doFootnotes"> <xsl:param name="string"/> <xsl:choose> <xsl:when test="contains($string,'(FN ')">
<xsl:variable name="before"> <xsl:value-of select="substring-before($string,'(FN ')"/> </xsl:variable> <xsl:variable name="number"> <xsl:value-of select="substring(substring-after($string,'(FN '),1,1)"/> </xsl:variable> <xsl:variable name="after"> <xsl:value-of select="substring(substring-after($string,'(FN '),2)"/> </xsl:variable>
<xsl:value-of select="$before"/> <xsl:text>(FN </xsl:text> <a> <xsl:attribute name="href"> <xsl:text>#FN_target_</xsl:text> <xsl:value-of select="$number"/> </xsl:attribute> <xsl:value-of select="$number"/> </a> <xsl:call-template name="doFootnotes"> <xsl:with-param name="string" select="$after"/> </xsl:call-template> </xsl:when> <xsl:otherwise> <xsl:value-of select="$string"/> </xsl:otherwise> </xsl:choose> </xsl:template>
You would then call it somthing like this:
<xsl:template match="para"> <xsl:call-template name="doFootnotes"> <xsl:with-param name="string" select="."/> </xsl:call-template> </xsl:template>
This template only works because you say the footnote numbers are only one digit - if you reached footnote 10, you'd need something cleverer....
Hope this helps, David.
====================================================================== Wendell Piez mailto:wapiez@xxxxxxxxxxxxxxxx Mulberry Technologies, Inc. http://www.mulberrytech.com 17 West Jefferson Street Direct Phone: 301/315-9635 Suite 207 Phone: 301/315-9631 Rockville, MD 20850 Fax: 301/315-8285 ---------------------------------------------------------------------- Mulberry Technologies: A Consultancy Specializing in SGML and XML ======================================================================
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] using substring-functions, McNally, David | Thread | [xsl] Best practice question, regar, Snow, Corey |
Re: [xsl] sort by attribute text, Wendell Piez | Date | [xsl] efficiency, David B. Bitton |
Month |