Hello Christian,
Thanks a lot, this is exactly what I needed. I saw it several times when reading the docs, and for some reason I thought it would give me the filesystem path to the database... (just in case, the reference for Google / mailing list archives: https://docs.basex.org/wiki/Databases#XML_Documents)
Best, - Tim
On Sun, Dec 12, 2021 at 12:03 AM Christian Grün christian.gruen@gmail.com wrote:
Hi Tim,
Did you try db:path?
All the best, Christian
Timothée timoguic@gmail.com schrieb am So., 12. Dez. 2021, 04:39:
Hello,
I am trying to build a web application, powered by data served through BaseX. One of the use cases I have is that I want to find all "documents" that match a xquery.
I have the following in a RESTXQ file:
declare %rest:path("filter_by_author") %rest:GET %rest:query-param("name", "{$name}") function page:by_author($name as xs:string) { let $docs := db:node-id(db:open("sp")//head/meta[@name='author' and contains(lower-case(@content), lower-case(web:decode-url($name)))]) return <response> {for $node_id in distinct-values($docs) return <title value="{$node_id}" />} </response> };
As expected, this does not work because it returns the node IDs. How can I get the "document ID" or "document path" from a node? I understand XQuery does not know about files in a collection (I found the following thread / message in the archives about it: https://mailman.uni-konstanz.de/pipermail/basex-talk/2010-July/000499.html)
- but is there a "db" function that would allow me to do it?
Thanks for your help,
- Tim