- From: axdmoraes <alexmoraes@gmail.com>
- Date: Mon, 8 Oct 2007 04:40:33 -0700 (PDT)
- To: xsl-editors@w3.org
Hi,
I need to add a tag around a specific word.Like this
<chapter> Chapter 1
<title> Licenses and attribution notices</title>
<para> Redistributions of source code must retain the above
copyright notice, this list of conditions and the following
disclaimer.</para>
</chapter>
Then I want to add a tag around the source word. And the resultant xml would
be:
<chapter> Chapter 1
<title> Licenses and attribution notices</title>
<para> Redistributions of <high>source</high> code must retain the
above copyright notice, this list of conditions and the following
disclaimer.</para>
</chapter>
This is my xsl:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" omit-xml-declaration="yes"/>
<xsl:param name="palavra"/>
<xsl:template match="/">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="text()">
<xsl:call-template name="globalReplace">
<xsl:with-param name="outputString" select="."/>
<xsl:with-param name="target" select="'Source'"/>
<xsl:with-param name="replacement">
<xsl:text
disable-output-escaping="yes"><high>Source</high></xsl:text>
</xsl:with-param>
</xsl:call-template>
</xsl:template>
<xsl:template match="@*|*">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template name="globalReplace">
<xsl:param name="outputString"/>
<xsl:param name="target"/>
<xsl:param name="replacement"/>
<xsl:choose>
<xsl:when test="contains($outputString,$target)">
<xsl:value-of select="concat(substring-before($outputString,$target),
$replacement)"/>
<xsl:call-template name="globalReplace">
<xsl:with-param name="outputString"
select="substring-after($outputString,$target)"/>
<xsl:with-param name="target" select="$target"/>
<xsl:with-param name="replacement" select="$replacement"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$outputString"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
My problem is that the xalan or saxon didn“t transform the < in <. And
transform > in >. How can I solve this problem?
Thanks
Alexandre
--
View this message in context: http://www.nabble.com/Add-Xml-tag-using-xslt-tf4587622.html#a13094932
Sent from the w3.org - xsl-editors mailing list archive at Nabble.com.
Received on Monday, 8 October 2007 11:40:42 UTC