[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

RE: [xsl] using substring-functions more than once in a node


Subject: RE: [xsl] using substring-functions more than once in a node
From: "Mario Michlits" <mario.michlits@xxxxxxxx>
Date: Thu, 28 Mar 2002 15:19:24 +0100

Hello

Thanx to David I can markup all my footnotes with the format (FN [1-9]) in my para-elements with an HTML anchor.
  
	<xsl:param name="replace" select="'(FN '"/>

	<xsl:template name="doFootnotes">
		<xsl:param name="string"/>
		<xsl:choose>
			<xsl:when test="contains($string, $replace)">
				<xsl:variable name="before">
					<xsl:value-of select="substring-before($string, $replace)"/>
				</xsl:variable>
				<xsl:variable name="number">
					<xsl:value-of select="substring(substring-after($string, $replace),1,1)"/>
				</xsl:variable>
				<xsl:variable name="after">
					<xsl:value-of select="substring(substring-after($string, $replace),2)"/>
				</xsl:variable>
				<xsl:value-of select="$before"/>
				<xsl:value-of select="$replace"/>
				<a>
				<xsl:attribute name="href">
					<xsl:text>#FN_</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>

	<xsl:template match="para">
		<xsl:call-template name="doFootnotes">
			<xsl:with-param name="string" select="."/>
		</xsl:call-template>
	</xsl:template>


Now I ve got an additional problem to solve. I am now trying to markup footnotes with more than just one format, firstly the (FN 1-9) Footnotes and secondly footnotes that look like this *) where the *symbol can repeat up to nine times: *********)
One way to solve this is to process the stylesheet more than once supplying another $replace parameter each time processing. E.g. in saxon: saxon source.xml replace.xsl replace=*****)
This is a procedure I would like to avoid. So does anyone know how I can use this named template more than once replacing each time another string? Thanx in advance, Mario

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



Current Thread