Altova Mailing List Archives>Archive Index >comp.text.xml Archive Home >Recent entries >Thread Prev - Re: Replace hithighlight tags >Thread Next - Re: Replace hithighlight tags Re: Replace hithighlight tagsTo: NULL Date: 10/8/2005 2:33:00 PM > But I think: <xsl:template match="searchhit"> won't work because of
> <searchhit> and </searchhit> being CDATA within the fulltext element.
Right, so you have something like:
---8<---8<---
<fulltext><![CDATA[This module is the <searchhit>third</searchhit> in the
OPPS series. More text...]]></fulltext>
---8<---8<---
> I think I need some sort of replacement template to replace the
> <searchhit> tags.
Would this kind of template do the trick?
---8<---8<---
<xsl:template name="wrapper">
<xsl:param name="content"/>
<xsl:choose>
<xsl:when test="contains($content, '<searchhit>')">
<xsl:value-of select="substring-before($content,
'<searchhit>')"/>
<span style="background: red; padding: 0.125em 0.5em;">
<xsl:value-of
select="substring-before(substring-after($content,
'<searchhit>'), '</searchhit>')"/>
</span>
<xsl:call-template name="wrapper">
<xsl:with-param name="content"><xsl:value-of
select="substring-after($content,
'</searchhit>')"/></xsl:with-param>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$content"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="/result/document/fulltext">
<xsl:call-template name="wrapper">
<xsl:with-param name="content"><xsl:value-of
select="text()"/></xsl:with-param>
</xsl:call-template>
</xsl:template>
---8<---8<---
--
Ixa
| ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
