Commit 81c6eade authored by simei.yin's avatar simei.yin

add namespace and diffrentiate xquery library modules from main module

parent 14ec2763
(: this script with .xq as suffix is the main module :)
(: all functions defined in .xqm files (library modules) can be called here :)
import module namespace myNs = "https://gitlab.utc.fr/crozatst/hdoc/tree/master/hdoc_to_basex" at "searchSectionByTitle.xqm", "searchSectionByTitle.xqm", "searchDocByAuthor.xqm";
(: myNs:searchDocByTitle('^NF29_HdocEtherpad$', //document ):)
(: myNs:searchSectionByTitle('contenu', //document) :)
myNs:searchDocByAuthor('Montangé', //document)
\ No newline at end of file
......@@ -4,7 +4,9 @@
(: For example, $name := 'Montangé', to search for documents whose author named Coutant:)
(: Remark : case and accents in author's name have been taken care of :)
declare function local:searchDocByAuthor($name as xs:string, $docs as node()*) as node()*
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()*
{
let $name_noAcc := translate($name, 'áàâäéèêëíìîïóòôöúùûüABCDEFGHIJKLMNOPQRSTUVWXYZ','aaaaeeeeiiiioooouuuuabcdefghijklmnopqrstuvwxyz')
for $doc in $docs
......@@ -15,7 +17,4 @@ declare function local:searchDocByAuthor($name as xs:string, $docs as node()*) a
where matches($author_noAcc, $name_noAcc)
group by $titre (: Avoid duplications of documents by their titre:)
return $doc
};
(: Example :)
local:searchDocByAuthor('Montangé', //document)
\ No newline at end of file
};
\ No newline at end of file
......@@ -3,12 +3,11 @@
(: For example, $name := '^NF29_HdocEtherpad$', to search for an exact name:)
(: For example, $name := 'NF29', to search for documents whose name contains 'NF29':)
declare function local:searchDocByTitle($name as xs:string, $docs as node()*) as node()*
module namespace myNs = "https://gitlab.utc.fr/crozatst/hdoc/tree/master/hdoc_to_basex";
declare function myNs:searchDocByTitle($name as xs:string, $docs as node()*) as node()*
{
for $doc in $docs
where matches($doc/titre, $name, "i")
return $doc
};
(: Example :)
local:searchDocByTitle('^NF29_HdocEtherpad$', //document)
\ No newline at end of file
};
\ No newline at end of file
......@@ -4,7 +4,9 @@
(: For example, $keyword := 'Syntax', to search for sections whose titles containing "Syntax" :)
(: Remark : case and accents in the keyword have been taken care of :)
declare function local:searchSectionByTitle($keyword as xs:string, $docs as node()*) as node()*
module namespace myNs = "https://gitlab.utc.fr/crozatst/hdoc/tree/master/hdoc_to_basex";
declare function myNs:searchSectionByTitle($keyword as xs:string, $docs as node()*) as node()*
{
let $keyword_noAcc := translate($keyword, 'áàâäéèêëíìîïóòôöúùûüABCDEFGHIJKLMNOPQRSTUVWXYZ','aaaaeeeeiiiioooouuuuabcdefghijklmnopqrstuvwxyz')
for $doc in $docs
......@@ -13,7 +15,4 @@ declare function local:searchSectionByTitle($keyword as xs:string, $docs as node
let $title_noAcc := translate($section/titresection, 'áàâäéèêëíìîïóòôöúùûüABCDEFGHIJKLMNOPQRSTUVWXYZ','aaaaeeeeiiiioooouuuuabcdefghijklmnopqrstuvwxyz')
where matches($title_noAcc, $keyword_noAcc)
return $section
};
(: Example :)
local:searchSectionByTitle('contenu', //document)
\ No newline at end of file
};
\ 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