Commit 3016c2e3 authored by simei.yin's avatar simei.yin

new Basex requests : search document by author

parent 0d7479ae
(: 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>
\ No newline at end of file
(: This script will return documents by searching one/several keyword in their title :) (: This script will return documents by searching one keyword in their title :)
(: We can assign a Regular Expression to the variable $name :) (: We can assign a Regular Expression to the variable $name :)
(: For example, $name := '^NF29_HdocEtherpad$', to search for an exact name:) (: For example, $name := '^NF29_HdocEtherpad$', to search for an exact name:)
(: For example, $name := 'NF29', to search for documents whose name contains 'NF29':) (: For example, $name := 'NF29', to search for documents whose name contains 'NF29':)
let $name := '^NF29_HdocEtherpad$' <documents>{
for $doc in //document let $name := '^NF29_HdocEtherpad$'
where matches($doc/titre, $name, "i") for $doc in //document
return $doc where matches($doc/titre, $name, "i")
\ No newline at end of file return $doc
}</documents>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment