Skip to content

Instantly share code, notes, and snippets.

@dmcassel
Created March 25, 2014 01:15
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/9753522 to your computer and use it in GitHub Desktop.
Save dmcassel/9753522 to your computer and use it in GitHub Desktop.
declare function local:doc-compliance-map($uri, $terms)
{
let $map := map:new(
for $term in $terms
return map:entry($term, 0)
)
let $doc := fn:doc($uri)
let $_ :=
for $s in $doc/document/body//(section|subsection)
for $term in $TERMS
where fn:contains($s/fn:data(compliance), $term)
return map:put($map, $term, map:get($map, $term) + 1)
return $map
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment