xquery version "1.0"; declare namespace request="http://exist-db.org/xquery/request"; declare namespace util="http://exist-db.org/xquery/util"; declare namespace i18n="http://apache.org/cocoon/i18n/2.1"; (: Main function - builds the paradigm request, sends it off, and returns the generated paradigm in an xml fragment. :) declare function local:main() as element()+ { let $term := request:get-parameter("word", "test*"), $word := if ( contains($term, ' ') ) then tokenize($term, ' ')[last()] else $term, $lang := request:get-parameter("lang",""), $posreq := request:get-parameter("pos", ""), $mode := request:get-parameter("mode","standard"), $pos := if ( string-length($posreq) > 0 ) then if ( $posreq = 'S') then 'N' else upper-case($posreq) else 'Any' (: DEBUG ONLY: :) let $docpref := request:get-parameter("srchcoll","all"), $coll := request:get-parameter("coll","all"), $params := request:get-parameter-names() (: This is the target string, disregarding linebreaks: http://sami-cgi-bin.uit.no/cgi-bin/smi/smi.cgi? text=gávdnon&pos=Any&action=paradigm&mode=standard &charset=utf-8&lang=sme&xml_out=1 :) let $doc := concat( 'http://sami-cgi-bin.uit.no/cgi-bin/smi/smi.cgi?text=', encode-for-uri($word), '&pos=', $pos, '&action=paradigm', '&mode=', $mode, '&charset=utf-8', '&lang=', $lang, '&xml_out=1' ) return ( (: DEBUG

Parameters: {$params}
Term: {$term}
Word: {$word}
POS: «{$pos}»
Lang: «{$lang}»
Selection: {$coll}
Search collection: {$docpref}
Paradigm request:
{$doc}

, :) , doc($doc)/* ) }; let $para := request:get-parameter("mode","standard") return