This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
RE: Case sensitive filter
- From: Stuart Brown <sbrown at extenza dot co dot uk>
- To: "'xsl-list at lists dot mulberrytech dot com'" <xsl-list at lists dot mulberrytech dot com>
- Date: Wed, 18 Sep 2002 13:28:24 +0100
- Subject: RE: [xsl] Case sensitive filter
- Reply-to: xsl-list at lists dot mulberrytech dot com
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@mbiinternational.com]
> Sent: 18 September 2002 12:47
> To: xsl-list@lists.mulberrytech.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