searchDocByAuthor.hq 876 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
(: This script will return documents by searching its author :)
(: We can assign a Regular Expression to the variable $author :)
(: For example, $author := '^Baptiste Montangé$', to search for an exact name:)
(: For example, $name := 'Montangé', to search for documents whose author named Coutant:)
(: Remark : Accents in the authors' names have been taken care of :)

<documents>{
  let $name := 'Montangé'
  let $name_noAcc := translate($name, 'áàâäéèêëíìîïóòôöúùûü','aaaaeeeeiiiioooouuuu')
  for $doc in //document
  return
    for $author in $doc/authors/author
    let $titre := $doc/titre
    let $author_noAcc := translate($author, 'áàâäéèêëíìîïóòôöúùûü','aaaaeeeeiiiioooouuuu')
    where matches($author_noAcc, $name_noAcc)
    group by $titre (: Avoid duplications of documents by their titre:)
    return $doc
}</documents>