searchDocByAuthor.xqm 1.08 KB
Newer Older
1
2
(: This script will return documents by searching its author :)
(: We can assign a Regular Expression to the variable $author :)
simei.yin's avatar
simei.yin committed
3
(: For example, $name := '^Baptiste Montangé$', to search for an exact name:)
4
(: For example, $name := 'Montangé', to search for documents whose author named Coutant:)
simei.yin's avatar
simei.yin committed
5
(: Remark : case and accents in author's name have been taken care of :)
simei.yin's avatar
simei.yin committed
6

7
8
9
module namespace myNs = "https://gitlab.utc.fr/crozatst/hdoc/tree/master/hdoc_to_basex";

declare function myNs:searchDocByAuthor($name as xs:string, $docs as node()*) as node()*
10
{
simei.yin's avatar
simei.yin committed
11
  let $name_noAcc := translate($name, 'áàâäéèêëíìîïóòôöúùûüABCDEFGHIJKLMNOPQRSTUVWXYZ','aaaaeeeeiiiioooouuuuabcdefghijklmnopqrstuvwxyz')
12
  for $doc in $docs
13
14
15
  return
    for $author in $doc/authors/author
    let $titre := $doc/titre
simei.yin's avatar
simei.yin committed
16
    let $author_noAcc := translate($author, 'áàâäéèêëíìîïóòôöúùûüABCDEFGHIJKLMNOPQRSTUVWXYZ','aaaaeeeeiiiioooouuuuabcdefghijklmnopqrstuvwxyz')
17
18
19
    where matches($author_noAcc, $name_noAcc)
    group by $titre (: Avoid duplications of documents by their titre:)
    return $doc
20
};