Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: Replace hithighlight tags

From: Ixa <ixa@-------.---.-->
To: 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, '&lt;searchhit&gt;')">
        <xsl:value-of select="substring-before($content, 
'&lt;searchhit&gt;')"/>
        <span style="background: red; padding: 0.125em 0.5em;">
          <xsl:value-of 
select="substring-before(substring-after($content, 
'&lt;searchhit&gt;'), '&lt;/searchhit&gt;')"/>
        </span>
        <xsl:call-template name="wrapper">
          <xsl:with-param name="content"><xsl:value-of 
select="substring-after($content, 
'&lt;/searchhit&gt;')"/></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



transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent