View Single Post
  #6 (permalink)  
Old March 4th, 2008, 12:14 PM
RussLewis RussLewis is offline
Registered User
 
Join Date: Feb 2008
Location: , , .
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Michael's suggestion worked after I removed the extra bracket after 'info'. However David Carlisle also gave me a suggestion on the Mulberry Tech List that exposed a limitation of your suggestion that I had never considered. While Field1 should only contain "Data...", or "Info", or "All" I have noticed an occasion where some users use this field incorrectly and therefore it may contain (even though it shouldn't) both "data" AND ("all" or "info"). My mistake was not considering the "idiot factor". This said, Mr. Carlisle's suggestion accounts for this (knowingly or unknowingly) and it also shows how I can use translate() against "info" and "all" instead of using multiple not()s. I show both implementations below for the sake of passing useful information in this forum. Thanks for everybody's help on this.

Michael Kay's suggestion:
record[not(Field1 = 'info')][Field1 = 'all' or *[name()=$searchfield and contains(., $searchtext)]

This suggestion works and answers my question as I asked it but if Field1 is entered incorrectly and contains both 'All' and 'Data3-1'(even though it shouldn't since 'Data3-1' and 'All' are redundant) this filter statement will not output these records. It also outputs records where Field1 is entered incorrectly and contains both 'info' and 'data' (even though it shouldn't either since this means that the user doesn't understand the use of this field). Below is the xsl implementation of this statement I used showing also multiple cases of 'info' and 'all'.
Like I said this should have worked if users always used Field1 correctly(I should have known better).

<xsl:for-each select="record[not(Field1 = 'info')][not(Field1 = 'Info')][not(Field1 = 'INFO')][Field1 = 'all' or Field1 = 'All' or Field1 = 'ALL' or *[name()=$searchfield and contains(., $searchtext)]]">

-----------------------------

David Carlisle's sugggestion:
record[not(contains(translate(Field1,$lowercase,$uppercas e),'INFO'))][contains(translate(Field1,$lowercase,$uppercase),' ALL') or *[name() = $searchfield][contains(translate(.,$lowercase,$uppercase),$UCASE TEXT)]]

Since Mr. Carlisle's suggestion uses the contains() function it outputs records even if Field1 is used incorrectly (which has happened) and contains both 'data' AND 'all'. It also Excludes records where Field1 may contain both 'data' and 'info'. His suggestion also uses my reusable translate() function variables $lowercase and $uppercase the way I should have thereby allowing me to get rid of $Propertext and $lcasetext which are just specific applications of the translate() function. Below is the xsl implementation that I used as a result:

<xsl:for-each select="record[not(contains(translate(Field1,$lowercase,$uppercas e),'INFO'))][contains(translate(Field1,$lowercase,$uppercase),' ALL') or *[name() = $searchfield][contains(translate(.,$lowercase,$uppercase),$UCASE TEXT)]]">

Thanks again,
Russ Lewis

Reply With Quote