Skip to content

Commit

Permalink
dédupliquer les occurences #753
Browse files Browse the repository at this point in the history
  • Loading branch information
emchateau committed Jul 13, 2020
1 parent 0dcf38a commit 34356e0
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions models/teiBuilder.xqm
Expand Up @@ -496,20 +496,22 @@ declare function getOccurences($entry as element()) as map(*)* {
'item' : fn:normalize-space($type),
'occurences' : array{
let $ids := $item/@passive ! fn:tokenize(., ' ') ! fn:substring-after(., '#')
let $occurences :=
let $lookup :=
for $id in $ids
let $entry := getDivFromId($id)
let $uuid := $entry/@xml:id
return map {
return map{
'id' : $id,
'title' : getSectionTitle($entry),
'uuid' : $uuid,
'path' : '/item/',
'url' : $gdp.globals:root || '/items/' || $uuid
}
return getDistinctMaps($occurences, map{})
}
'entry' : getDivFromId($id)/@xml:id
}
for $item in fn:distinct-values($lookup?entry)
return map{
'title' : getSectionTitle(db:open('gdp')//tei:div[@xml:id=$item]),
'uuid' : xs:string($item),
'path' : '/item/',
'url' : $gdp.globals:root || '/items/' || $item,
'ids' : array{ $lookup[?entry = $item]?id }
}
}
}
};

(:~
Expand Down

0 comments on commit 34356e0

Please sign in to comment.