Xquery for multiple files
Hello all,
I am not sure if this can be done in XQuery, and if BaseX makes it possible, but I am trying to query all the files under a directory. This directory is copied through webdav. For example, I need to get all the files that have root <article>.
Searching for how to do this, I came across this post, that shows how to do something similar with marklogic
http://stackoverflow.com/questions/19243253/search-and-load-all-xml-files-in-xquery
How to do this in BaseX if possible ??
Thank you.
Mansour,
Sorry for being persistent, but I would be grateful if you could first check out our Wiki and try things before requesting the list. Two links that should give you a start:
http://docs.basex.org/wiki/File_Module http://docs.basex.org/wiki/XQuery
XQuery is a very powerful language. Even things like raytracers have been written in the language. – It takes some time to learn the language, but I dare say it’s worth the time.
Thanks, Christian
Quoted text · Mansour Al Akeel · 22 lines
On Thu, Dec 12, 2013 at 5:56 AM, Mansour Al Akeel <mansour.alakeel at gmail.com> wrote: > Hello all, > > I am not sure if this can be done in XQuery, and if BaseX makes it > possible, but I am trying to query all the files under a directory. > This directory is copied through webdav. > For example, I need to get all the files that have root <article>. > > Searching for how to do this, I came across this post, that shows how > to do something similar with marklogic > > http://stackoverflow.com/questions/19243253/search-and-load-all-xml-files-in-xquery > > How to do this in BaseX if possible ?? > > > Thank you. > _______________________________________________ > BaseX-Talk mailing list > BaseX-Talk at mailman.uni-konstanz.de > https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk
Christian, Querying all files, the way it's in the thread is done by "querying all the files". My understanding is through iterating over each file and loading it, then filtering them. I am sorry, but I think I used the wrong words. I think I got what I wanted from using the db model. For others facing the same problem, here's what I did:
declare %rest:path("repo/articles")
%rest:GET
function page:list-articles(){
<articles>
{
let $db := db:open('repo')
for $a in $db/article
return <article
count="{count($db/article)}">{$a//title[1]}</article>
}
</articles>
} ;Quoted text · Christian Grün · 41 lines
On Thu, Dec 12, 2013 at 5:15 AM, Christian Grün <christian.gruen at gmail.com> wrote: > Mansour, > > Sorry for being persistent, but I would be grateful if you could first > check out our Wiki and try things before requesting the list. Two > links that should give you a start: > > http://docs.basex.org/wiki/File_Module > http://docs.basex.org/wiki/XQuery > > XQuery is a very powerful language. Even things like raytracers have > been written in the language. – It takes some time to learn the > language, but I dare say it’s worth the time. > > Thanks, > Christian > ___________________________ > > On Thu, Dec 12, 2013 at 5:56 AM, Mansour Al Akeel > <mansour.alakeel at gmail.com> wrote: >> Hello all, >> >> I am not sure if this can be done in XQuery, and if BaseX makes it >> possible, but I am trying to query all the files under a directory. >> This directory is copied through webdav. >> For example, I need to get all the files that have root <article>. >> >> Searching for how to do this, I came across this post, that shows how >> to do something similar with marklogic >> >> http://stackoverflow.com/questions/19243253/search-and-load-all-xml-files-in-xquery >> >> How to do this in BaseX if possible ?? >> >> >> Thank you. >> _______________________________________________ >> BaseX-Talk mailing list >> BaseX-Talk at mailman.uni-konstanz.de >> https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk
Written for BaseX 7.7. BaseX may have changed since: please check the current documentation.