Created
November 5, 2015 22:56
-
-
Save taoyou/5999fc4d926868b0c36d to your computer and use it in GitHub Desktop.
get facets based on path variable
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
xquery version "3.1"; | |
declare function local:get_facet ($books as element()*, $path as xs:string ) as element()? | |
{ | |
<binding>{ | |
for $book in $books | |
let $fld := $book/*[name()=$path] | |
group by $f := $fld | |
order by $f | |
return element {$f} { attribute number {fn:count($book)}} | |
}</binding> | |
}; | |
let $csv := fetch:text("https://gist.githubusercontent.com/CliffordAnderson/5be754415308dc407fc9/raw/daa23df71ceef375b83dd5b290284f83beeb710b/books.csv") | |
let $books := csv:parse($csv, map { 'header': true() })/csv/record | |
return local:get_facet($books, "Binding" ) | |
(: return ($book) :) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment