keeping relative paths in the document-uri?
Wednesday, 30 March 2022 · 3 messages · last reply 31 Mar 2022
GS
Graydon Saunders30 Mar 2022 22:52 #
Hello --
An approach that uses
db:create and file:descendant doesn't seem to work; the file paths have all been truncated to the name part of the path in the document-uri property of the individual documents in the DB.
I'm using 9.6.4 with Oracle Java 1.8.0_211 on a Windows 10 machine. (I have no control over any of the environment.)
Is there a way to keep the full path (relative or absolute) in the document uri property? I'm trying to inspect files with identical names in different directories, so I need the directory name to tell the files apart.
Thanks!
GraydonCG
Christian Grün31 Mar 2022 14:45 #
Hi Graydon,
It’s sufficient to supply the directory path as second argument:
db:create('db', '/path')If you want to filter the input paths before passing them on to
db:create, you can supply the paths as both inputs and database paths:
let $files := file:descendants('/path')
[file:is-file(.)]
[contains(file:read-text(.), 'abalaba')]
return db:create('db', $files, $files)
Best,
ChristianQuoted text · Graydon Saunders · 12 lines
On Wed, Mar 30, 2022 at 8:52 PM Graydon Saunders <graydonish at gmail.com> wrote: > > Hello -- > > An approach that uses db:create and file:descendant doesn't seem to work; the file paths have all been truncated to the name part of the path in the document-uri property of the individual documents in the DB. > > I'm using 9.6.4 with Oracle Java 1.8.0_211 on a Windows 10 machine. (I have no control over any of the environment.) > > Is there a way to keep the full path (relative or absolute) in the document uri property? I'm trying to inspect files with identical names in different directories, so I need the directory name to tell the files apart. > > Thanks! > Graydon
G
Graydon31 Mar 2022 17:40 #
Hello Christian --
Quoted text · Christian Grün · 4 lines
On Thu, Mar 31, 2022 at 02:45:34PM +0200, Christian Grün scripsit: > It’s sufficient to supply the directory path as second argument: > > db:create('db', '/path')
What I've been trying is
db:create('DB', file:descendants($path)[ends-with(.,$suffix), (),
$paramsMap)and I now realize that I can't do that with the third param.
Quoted text · Christian Grün · 7 lines
> If you want to filter the input paths before passing them on to > db:create, you can supply the paths as both inputs and database paths: > > let $files := file:descendants('/path') > [file:is-file(.)] > [contains(file:read-text(.), 'abalaba')] > return db:create('db', $files, $files)
That works!
Thank you!
-- Graydon
--
Graydon Saunders | graydonish at gmail.com
Þæs oferéode, ðisses swá mæg.
-- Deor ("That passed, so may this.")
Written for BaseX 9.7. BaseX may have changed since: please check the current documentation.
⚡Generated with XQuery