xsl-list
[Top] [All Lists]

RE: Case sensitive filter

2002-09-18 05:28:24
Hi Terry,

To achieve case-insensitive searching, just use translate() to change the
strings to all-lower case.
To achieve the security filter, why not just include that condition as
another predicate on the
menu step (or am I missing something?).

I think the following should work (although it's untested):

<xsl:variable name="searchNode"
select="msxsl:node-set(//resource//menu[contains(@id,$prmSecCat)]
[contains(translate(.,'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
'abcdefghijklmnopqrstuvwxyz'),translate($prmSearch,
'ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz'))] |
//resource[contains(translate(notes,'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
'abcdefghijklmnopqrstuvwxyz'),translate($prmSearch,
'ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz'))]"/>

Cheers,

Stuart


-----Original Message-----
From: Terry Clark [mailto:tclark(_at_)mbiinternational(_dot_)com]
Sent: 18 September 2002 12:47
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: [xsl] Case sensitive filter


Hi

Two part question (I hope).

I have created a search engine for a site that passes the 
search string
through to an ASP page that passes it back into the xsl template as a
parameter. I then use this parameter to create a node set as 
sub set of
the main data set.

i.e. <xsl:variable name="searchNode"
select="msxsl:node-set(//resource//menu[contains(.,$prmSearch)] |
//resource[contains(notes,$prmSearch)])"/>

Which works to a certain extent, the problem is the old case sensitive
one. If the search string is in a menu node it would normally have the
first letter capitalised (or all of them) where as if it is 
in the notes
it may well be all lowercase and as a consequence not all results are
being returned. I have had a look at the translate function but am
unsure how/if to use it in this scenario.

Part two:
Part of the site "security" is to only allow access to certain menu
options which works fine when I am creating the menu 
structure as I only
include those that have a certain string in the ID attribute, however
the search brings back results they should not be able to access, how
could I go about restricting the result set of $searchNode (see above)
so that only the eligible nodes are selected. In the menu 
creation I use
:
                      <xsl:if test="contains(@id,$prmSecCat)" />
....</xsl:if>
To only display the correct menu options. How could I 
integrate the same
logic in the creation of the $searchNode variable

Thanks

Terry

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


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



<Prev in Thread] Current Thread [Next in Thread>