after getting hints here: xslt string replace concrete example, I've made these two templates to use in my own environment. They use html-tables in order to get some formatting done when calling the second template (fhb-bib-info) from yet another .xsl-template:
<xsl:template name="string-replace-all">
<xsl:param name="text" />
<xsl:param name="replace" />
<xsl:param name="by" />
<xsl:choose>
<xsl:when test="$text = '' or $replace = ''or not($replace)" >
<!-- Prevent this routine from hanging -->
<xsl:value-of select="$text" />
</xsl:when>
<xsl:when test="contains($text, $replace)">
<xsl:value-of select="substring-before($text,$replace)" />
<xsl:value-of select="$by" />
<xsl:call-template name="string-replace-all">
<xsl:with-param name="text" select="substring-after($text,$replace)" />
<xsl:with-param name="replace" select="$replace" />
<xsl:with-param name="by" select="$by" />
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$text" />
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="fhb-bib-info">
<xsl:choose>
<xsl:when test="./bib-info =''">
<tr>
<td colspan="2"><xsl:text>Autor: </xsl:text><xsl:value-of select="./z13-author"/></td>
</tr>
<tr>
<td colspan="2"><xsl:text>Titel: </xsl:text><xsl:value-of select="./z13-title"/></td>
</tr>
<tr>
<td colspan="2"><xsl:text>ISBN/ISSN: </xsl:text><xsl:value-of select="./z13-isbn-issn"/></td>
</tr>
</xsl:when>
<xsl:otherwise>
<xsl:template match="bib-info">
<xsl:variable name="newtext">
<xsl:call-template name="string-replace-all">
<xsl:with-param name="text" select="text()" />
<xsl:with-param name="replace" select="']: '" />
<xsl:with-param name="by" select="']: '" />
</xsl:call-template>
</xsl:variable>
</xsl:template>
<tr>
<td colspan="2"><bib-info><xsl:value-of select="$newtext" /></bib-info></td>
</tr>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
But when I try to run them I get the following errors. The two templates are part of the file funcs.xsl. Line 153 is where the xsl:value-of select="$newtext" statement occurs.
Can anybody help me debug/clear these error-messages? Kate
Error at xsl:value-of on line 153 of file:/C:/Aleph-22-Test/alephcom/files/SWF50/PrintTemplates/ger/funcs.xsl:
XPST0008: XPath syntax error at char 8 on line 153 in {$newtext}:
Variable $newtext has not been declared
Error at xsl:template on line 143 of file:/C:/Aleph-22-Test/alephcom/files/SWF50/PrintTemplates/ger/funcs.xsl:
XTSE0010: An xsl:otherwise element must not contain an xsl:template element
Error at xsl:template on line 143 of file:/C:/Aleph-22-Test/alephcom/files/SWF50/PrintTemplates/ger/funcs.xsl:
XTSE0010: Element must be used only at top level of stylesheet