From: <jm...@us...> - 2004-03-07 09:57:36
|
Update of /cvsroot/exist/eXist-1.0/webapp/xquery In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27532/webapp/xquery Modified Files: process.xq Log Message: avoid having twice the same query in history Index: process.xq =================================================================== RCS file: /cvsroot/exist/eXist-1.0/webapp/xquery/process.xq,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** process.xq 2 Feb 2004 15:30:35 -0000 1.3 --- process.xq 7 Mar 2004 09:34:11 -0000 1.4 *************** *** 106,109 **** --- 106,129 ---- }; + (: Auxiliary function called in add-to-history() + to avoid having twice the same query in history + :) + declare function f:string-list-union( + $list as xs:string*, + $s as xs:string ) as xs:string* + { + let $contains := + for $ss in $list + return + if ( $ss = $s ) then true + else "" + + return + if ( $contains ) then + $list + else + ( $list, $s ) + }; + (: Add the last query to the query-history. The history is stored in the session as an XQuery sequence. *************** *** 113,117 **** let $history := request:get-session-attribute("history") return ! request:set-session-attribute("history", ($history, $query)) }; --- 133,138 ---- let $history := request:get-session-attribute("history") return ! request:set-session-attribute( "history", ! f:string-list-union($history, $query) ) }; *************** *** 161,165 **** <section title="Query Results"> - { f:main() } --- 182,185 ---- |