[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: xsl search engine

Subject: RE: xsl search engine
From: Jarno.Elovirta@xxxxxxxxx
Date: Wed, 17 Mar 2004 09:13:52 +0200
xsl search
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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.