caesarkim
February 1st, 2004, 07:23 PM
I have a xml file like this.
<projectteam>
<projectname>The Killer Application {a href="http://www.hotmail.com"}hotmail.com{/a}</projectname>
</projectteam>
but i want to convert '}' to '>' and '{' to '<' with xsl this function.
<xsl:template name="string-replace" >
<xsl:param name="string"/>
<xsl:param name="from"/>
<xsl:param name="to"/>
<xsl:choose>
<xsl:when test="contains($string,$from)">
<xsl:value-of select="substring-before($string,$from)"/>
<xsl:value-of select="$to"/>
<xsl:call-template name="string-replace">
<xsl:with-param name="string" select="substring-after($string,$from)"/>
<xsl:with-param name="from" select="$from"/>
<xsl:with-param name="to" select="$to"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$string" disable-output-escaping="yes"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
cuz i might have to generate html and other format. but when i try like this, it converts only '>' to a> which is html tag. but i want '<'. is there any way to do this? please help...
<projectteam>
<projectname>The Killer Application {a href="http://www.hotmail.com"}hotmail.com{/a}</projectname>
</projectteam>
but i want to convert '}' to '>' and '{' to '<' with xsl this function.
<xsl:template name="string-replace" >
<xsl:param name="string"/>
<xsl:param name="from"/>
<xsl:param name="to"/>
<xsl:choose>
<xsl:when test="contains($string,$from)">
<xsl:value-of select="substring-before($string,$from)"/>
<xsl:value-of select="$to"/>
<xsl:call-template name="string-replace">
<xsl:with-param name="string" select="substring-after($string,$from)"/>
<xsl:with-param name="from" select="$from"/>
<xsl:with-param name="to" select="$to"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$string" disable-output-escaping="yes"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
cuz i might have to generate html and other format. but when i try like this, it converts only '>' to a> which is html tag. but i want '<'. is there any way to do this? please help...