Created
April 2, 2012 17:55
-
-
Save esbanarango/2285702 to your computer and use it in GitHub Desktop.
Test for Xquery
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
declare namespace oai_dc="http://www.openarchives.org/OAI/2.0/oai_dc/"; | |
declare namespace xdb="http://exist-db.org/xquery/xmldb"; | |
declare namespace request="http://exist-db.org/xquery/request"; | |
declare namespace dc="http://purl.org/dc/elements/1.1/"; | |
declare namespace oai_lom="http://ltsc.ieee.org/xsd/LOM"; | |
declare namespace functx = "http://www.functx.com"; | |
declare function local:term-callback($term as xs:string, $data as xs:int+) as element() { | |
<term freq="{$data[1]}" docs="{$data[2]}" n="{$data[3]}">{$term}</term> | |
}; | |
let $data-collection := '/db/bdcol' | |
let $scope := collection($data-collection)//dc:record | |
let $query := "educational.context" | |
let $callback := util:function(xs:QName("local:term-callback"), 2) | |
let $faceteing := concat('util:index-keys($scope//dc:',$query,",'', $callback, 10000)") | |
let $result := <terms>{util:eval($faceteing)}</terms> | |
let $title-predicate := "[ft:query(dc:educational.learningResourceType,<query><phrase>Autoevaluación</phrase ></query>)]" | |
let $search-string := concat | |
('$scope', | |
$title-predicate | |
) | |
let $hitsReturn := | |
for $m in util:eval($search-string) | |
let $score := ft:score($m) | |
order by $score descending | |
return | |
$m | |
return $hitsReturn | |
(:let $show := | |
<terms> | |
{ | |
for $term in $result/term | |
let $ord := xs:integer($term//@freq) | |
where $term != "" | |
order by $ord descending | |
return | |
$term | |
} | |
</terms> | |
return $show:) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment