Subject: Re: Placing mark-up in between strings
From: Jeff Sese <jsese@xxxxxxxxxxxx>
Date: Thu, 23 Nov 2006 18:07:39 +0800
|
Hi,
I'm not sure but i think it has something to do with the
ati:replace-with-nodes-1 function call in ati:replace-with-nodes. this
should return a xs:string and not a node() as per requirement in the 1st
parameter of ati:replace-with-nodes function.
i tried this inside the ati:replace-with-nodes-1 function:
<xsl:message terminate="yes">
<xsl:value-of select="$input"/>
<xsl:value-of select="$word-to-replace"/>
<xsl:copy-of select="$replacement"/>
</xsl:message>
and got nothing... i really can't find the actual problem but i think it
lies in the ati:replace-with-nodes-1 function.
-- jeff
Florent Georges wrote:
<xsl:sequence select="
if ( exists($words-to-replace) ) then
ati:replace-with-nodes(
ati:replace-with-nodes-1(
$input, $words-to-replace[1], $replacement[1]
),
remove($words-to-replace, 1),
remove($replacement, 1)
)
else
$input
"/>
<!--
Internal. Coroutine for ati:replace-with-nodes().
Treat a single replacement.
-->
<xsl:function name="ati:replace-with-nodes-1" as="node()*">
<xsl:param name="input" as="xs:string?"/>
<xsl:param name="word-to-replace" as="xs:string"/>
<xsl:param name="replacement" as="node()"/>
<xsl:variable name="before" select="
substring-before($input, $word-to-replace)"/>
<xsl:choose>
<xsl:when test="exists($before)">
<xsl:value-of select="$before"/>
<xsl:sequence select="$replacement"/>
<xsl:sequence select="
ati:replace-with-nodes-1(
substring-after($input, $word-to-replace),
$word-to-replace,
$replacement
)"/>
</xsl:when>
<xsl:otherwise>
<xsl:sequence select="$input"/>
</xsl:otherwise>
</xsl:choose>
</xsl:function>
|