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 @@ ...@@ -4,7 +4,9 @@
(: For example, $name := 'Montangé', to search for documents whose author named Coutant:) (: 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 :) (: 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') let $name_noAcc := translate($name, 'áàâäéèêëíìîïóòôöúùûüABCDEFGHIJKLMNOPQRSTUVWXYZ','aaaaeeeeiiiioooouuuuabcdefghijklmnopqrstuvwxyz')
for $doc in $docs for $doc in $docs
...@@ -16,6 +18,3 @@ declare function local:searchDocByAuthor($name as xs:string, $docs as node()*) a ...@@ -16,6 +18,3 @@ declare function local:searchDocByAuthor($name as xs:string, $docs as node()*) a
group by $titre (: Avoid duplications of documents by their titre:) group by $titre (: Avoid duplications of documents by their titre:)
return $doc return $doc
}; };
\ No newline at end of file
(: Example :)
local:searchDocByAuthor('Montangé', //document)
\ No newline at end of file
...@@ -3,12 +3,11 @@ ...@@ -3,12 +3,11 @@
(: 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':)
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 for $doc in $docs
where matches($doc/titre, $name, "i") where matches($doc/titre, $name, "i")
return $doc return $doc
}; };
\ No newline at end of file
(: Example :)
local:searchDocByTitle('^NF29_HdocEtherpad$', //document)
\ No newline at end of file
...@@ -4,7 +4,9 @@ ...@@ -4,7 +4,9 @@
(: For example, $keyword := 'Syntax', to search for sections whose titles containing "Syntax" :) (: For example, $keyword := 'Syntax', to search for sections whose titles containing "Syntax" :)
(: Remark : case and accents in the keyword have been taken care of :) (: 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') let $keyword_noAcc := translate($keyword, 'áàâäéèêëíìîïóòôöúùûüABCDEFGHIJKLMNOPQRSTUVWXYZ','aaaaeeeeiiiioooouuuuabcdefghijklmnopqrstuvwxyz')
for $doc in $docs for $doc in $docs
...@@ -14,6 +16,3 @@ declare function local:searchSectionByTitle($keyword as xs:string, $docs as node ...@@ -14,6 +16,3 @@ declare function local:searchSectionByTitle($keyword as xs:string, $docs as node
where matches($title_noAcc, $keyword_noAcc) where matches($title_noAcc, $keyword_noAcc)
return $section return $section
}; };
\ No newline at end of file
(: Example :)
local:searchSectionByTitle('contenu', //document)
\ 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