function to give the current file being processed?
Saturday, 24 December 2011 · 5 messages · last reply 7 Jan 2012
J
jidanni24 Dec 2011 15:24 #
{comment {"Made by noise.xq, will get OVERWRITTEN"}}
gives me
$ basex noise.xq
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2">
<!--Made by noise.xq, will get OVERWRITTEN-->
<Document>...
Is there any function to enable me not to need to hardwire the name into
the file?CG
Christian Grün26 Dec 2011 23:29 #
..not quite sure what you're trying to achieve: Do you want to request the name of your query file from within XQuery? Currently, there's no way to do this, but we could think about adding a pre-defined XQuery function for that.
Quoted text · jidanni · 14 lines
On Sat, Dec 24, 2011 at 3:24 PM, <jidanni at jidanni.org> wrote: > {comment {"Made by noise.xq, will get OVERWRITTEN"}} > gives me > $ basex noise.xq > <?xml version="1.0" encoding="UTF-8"?> > <kml xmlns="http://www.opengis.net/kml/2.2"> > <!--Made by noise.xq, will get OVERWRITTEN--> > <Document>... > Is there any function to enable me not to need to hardwire the name into > the file? > _______________________________________________ > BaseX-Talk mailing list > BaseX-Talk at mailman.uni-konstanz.de > https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk
J
jidanni27 Dec 2011 01:18 #
Quoted text · Christian Grün · 1 line
>>>>> "CG" == Christian Grün <christian.gruen at gmail.com> writes:
CG> ..not quite sure what you're trying to achieve: Do you want to request CG> the name of your query file from within XQuery?
Yes, like I can do in bash
$ cat f
echo $0
$ bash f
fCG> Currently, there's no way to do this, but we could think about CG> adding a pre-defined XQuery function for that.
Yes, like one can do with
$ man perlvar
$PROGRAM_NAME, $0 Contains the name of the program being executed.
$ARGV Contains the name of the current file when reading from "<>".Wait,
$ basex i.xq
Stopped at line 1, column 7 in /tmp/i.xq:
[XPDY0002] No context item set for 'zzzzzzz'.
Something inside basex knows that it is processing /tmp/i.xq . Can we get access to that something from within the xquery program, and would that be an basex specific way or general xquery way?
I can't find any
fn:error() examples that can be smart enough to tell the user what file he is processing without hardwiring the file name into the program.J
Well I guess one way not to hardwire it into the program is to pass it in as an external variable... rather clumsy with the same item twice on the command line.
CG
Christian Grün7 Jan 2012 13:40 #
Quoted text · jidanni · 3 lines
> Well I guess one way not to hardwire it into the program is to pass it > in as an external variable... rather clumsy with the same item twice on > the command line.
Sorry for the delay. The discussed function has now been added:
http://docs.basex.org/wiki/Utility_Module#util:path
Hth,
Christian
Written for BaseX 7.0. BaseX may have changed since: please check the current documentation.
⚡Generated with XQuery