[xsl] Word Highlighting

Subject: [xsl] Word Highlighting
From: Paul Terray <terray@xxxxxxxxxxxx>
Date: Tue, 05 Nov 2002 09:59:45 +0100
Hi,

Sorry if it is a double.

I have a specific problem: I want to highlight a word specified by a parameter outside my stylesheet.

I know how I can do that, with a recursive approach :
-------------------
<xsl:template match="text()">
  <xsl:choose>
    <xsl:when test="$p_textsearch!='' and contains(.,$p_textsearch)">
      <xsl:call-template name="marquage">
        <xsl:with-param name="p_text" select="."/>
      </xsl:call-template>
    </xsl:when>
    <xsl:otherwise>
      <xsl:value-of select="."/>
    </xsl:otherwise>
  </xsl:choose>
</xsl:template>

<xsl:template name="marquage">
  <xsl:param name="p_text" select="''"/>
  <xsl:choose>
    <xsl:when test="contains($p_text,$p_textsearch)">
      <xsl:value-of select="substring-before($p_text,$p_textsearch)"/>
      <font color="red">
      <xsl:value-of select="$p_textsearch"/>
      </font>
      <xsl:call-template name="marquage">
        <xsl:with-param name="p_text" select="substring-after($p_text,$p_textsearch)"/>
      </xsl:call-template>
    </xsl:when>
    <xsl:otherwise>
      <xsl:value-of select="$p_text"/>
    </xsl:otherwise>
  </xsl:choose>
</xsl:template>
-------------------
Now, my problem is that the text is french, with characters entities (like &eacute;). 

If I have words with entities in them, like cath&eacute;drale, they are considered as three text() nodes, not one, and my template matching fails. 

Does someone have a solution ?

Thanks in advance.


--
Paul TERRAY - Documents Management Systems Engineer
email : terray@xxxxxxxxxxxx 


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread