|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: xsl search engine
Hi,
> When I have the time I'll try to perfect it, I didn't manage
> to get out of
> the problem of Case and accents :
> it's harder then just add translate($text, 'ABCDEFG...éèê',
> 'abcdef...eee')
> on every contains() and most of all it's hard to get the
> result with the
> original case at the end.
Doing case-insensitive operations in XSLT isn't easy. Anyhow, you can put the uppercase and lowercase strings into variables $u and $l, that will make the code a tad more readable.
> Other thing is that the @label contains twice the searched
> expression then
> it will will be display once (that was a last problem) BUT it
> will highlight
> only the first occurence...
Oh yeah. Just make the template a bit less greedy
<xsl:template name="highlight">
<xsl:param name="label" select="@label"/>
<xsl:param name="text" select="normalize-space($string)"/>
<xsl:choose>
<xsl:when test="contains($text, ' ')">
<xsl:variable name="current" select="substring-before($text, ' ')"/>
<xsl:choose>
<xsl:when test="contains($label, $current)">
<xsl:call-template name="highlight">
<xsl:with-param name="label" select="substring-before($label, $current)"/>
<xsl:with-param name="text" select="$text"/> <!-- change this -->
</xsl:call-template>
<em>
<xsl:value-of select="$current"/>
</em>
<xsl:call-template name="highlight">
<xsl:with-param name="label" select="substring-after($label, $current)"/>
<xsl:with-param name="text" select="$text"/> <!-- change this -->
</xsl:call-template>
</xsl:when>
i.e. don't move on to the next token once a match is found, but rather continue with that same token until it's not found. The rest of the template is the same.
Cheers,
Jarno - Tactical Sekt: Xfixiation (Hellfire mix by [:SITD:] )
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








