Hi Stuart
Pretty much spot on thanks. Although this was producing a union and
duplicates but so I then had to create an intersection of the two nodes
instead. This sparked of the the idea to deal with simple security
measure in the same way and the final solution looked like :
<xsl:variable name="searchSubNode1"
select="msxsl:node-set(//resource//menu[contains(translate(.,'ABCDEFGHIJ
KLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz'),translate($prmSearch,'AB
CDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz'))])"/>
<xsl:variable name="searchSubNode2"
select="msxsl:node-set(//resource//notes[contains(translate(.,'ABCDEFGHI
JKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz'),translate($prmSearch,'A
BCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz'))])"/>
<!-- returns a node set of the security filtered nodes -->
<xsl:variable name="searchSubNode3"
select="*//resource//menu[contains(.,concat($prmSecCat,':'))]"/>
<!-- Creates the intersection of the two search nodes -<><> Note
to Self: why did = not work?? <><>- -->
<xsl:variable name="searchSubNode4"
select="$searchSubNode1[count(. | $searchSubNode2) !=
count($searchSubNode2)]"/>
<!-- Creates final intersection of search node and 'security'
node -->
<xsl:variable name="searchNode" select="$searchSubNode4[count(.
| $searchSubNode3) = count($searchSubNode3)]"/>
Although I'm wondering if this is the most efficient way of doing this,
but it works so I'm happy for now
Thanks again
Terry
-----Original Message-----
From: Stuart Brown [mailto:sbrown(_at_)extenza(_dot_)co(_dot_)uk]
Sent: 18 September 2002 12:28
To: 'xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com'
Subject: RE: [xsl] Case sensitive filter
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
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list