Skip to content

Instantly share code, notes, and snippets.

@dmcassel
Last active August 29, 2015 13:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dmcassel/9669279 to your computer and use it in GitHub Desktop.
Save dmcassel/9669279 to your computer and use it in GitHub Desktop.
declare function gs:doc-compliance-map($uri as xs:string)
{
let $query := cts:document-query($uri)
let $map := map:map()
let $doc := gs:highlight($uri, 'a')
let $header1 :=
for $s in $doc/document/body//(section|subsection)
where fn:contains($s/fn:data(compliance), $TERM1)
return fn:count($s)
let $header2 :=
for $s in $doc/document/body//(section|subsection)
where fn:contains($s/fn:data(compliance), $TERM2)
return fn:count($s)
let $header3 :=
for $s in $doc/document/body//(section|subsection)
where fn:contains($s/fn:data(compliance), $TERM3)
return fn:count($s)
let $val1 := fn:sum($header1)
let $val2 := fn:sum($header2)
let $val3 := fn:sum($header3)
let $_ :=
(
map:put($map, $TERM1, $val1),
map:put($map, $TERM2, $val2),
map:put($map, $TERM3, $val3)
)
return $map
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment