Pathname of the current XQuery?

Monday, 1 April 2013 · 5 messages · last reply 12 Apr 2013
GS
Graydon Saunders1 Apr 2013 21:37 #
I have the awful feeling that I'm missing something really obvious, but I want to be able to get the pathname of the current query, and I can't figure out how. The use case is that the query validates documents in the collection differently, based on the document element, and I want to refer to the different schema files (which sit, on the file system, right next to the file with the query in it) in a machine-independent way. So instead of let $decisionSchema := '/home/graydon/workspace/Content Standards/schemas/decisions_schema.xsd' I'd like to be able to say something like let $decisionSchema := concat(string-join(tokenize(get-query-path(),'/')[position() ne last()],'/'),'/decisions_schema.xsd') only I can't figure out what get-query-path() is. Thanks! Graydon
LQ
Liam R E Quin2 Apr 2013 07:36 #
Quoted text · Graydon Saunders · 8 lines
On Mon, 2013-04-01 at 13:36 -0400, Graydon Saunders wrote: > I'd like to be able to say something like > > let $decisionSchema := > concat(string-join(tokenize(get-query-path(),'/')[position() ne > last()],'/'),'/decisions_schema.xsd') > > only I can't figure out what get-query-path() is.
For many Query engines it won't be defined. You could try constructing an element and asking for its base URI I suppose. Liam
-- Liam Quin - XML Activity Lead, W3C, http://www.w3.org/People/Quin/ Pictures from old books: http://fromoldbooks.org/ Ankh: irc.sorcery.net irc.gnome.org freenode/#xml
MS
Michael Seiferle4 Apr 2013 12:07 #
Thanks Liam, you are right, the shortest way to achieve should be the following:
Quoted text · Liam R E Quin · 1 line
> let $path-to-query-file := base-uri(<_/>)
Best from Konstanz Michael
Quoted text · Graydon Saunders · 27 lines
Am 02.04.2013 um 05:36 schrieb Liam R E Quin <liam at w3.org>: > On Mon, 2013-04-01 at 13:36 -0400, Graydon Saunders wrote: > >> I'd like to be able to say something like >> >> let $decisionSchema := >> concat(string-join(tokenize(get-query-path(),'/')[position() ne >> last()],'/'),'/decisions_schema.xsd') >> >> only I can't figure out what get-query-path() is. > > For many Query engines it won't be defined. > > You could try constructing an element and asking for its base URI I > suppose. > > Liam > > -- > Liam Quin - XML Activity Lead, W3C, http://www.w3.org/People/Quin/ > Pictures from old books: http://fromoldbooks.org/ > Ankh: irc.sorcery.net irc.gnome.org freenode/#xml > > _______________________________________________ > BaseX-Talk mailing list > BaseX-Talk at mailman.uni-konstanz.de > https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk
CG
Christian Grün12 Apr 2013 10:26 #
Hi Graydon, you may as well want to use the static-base-uri() function (“static” refers to the given query file and not the database context). Christian
Quoted text · Michael Seiferle · 44 lines
On Thu, Apr 4, 2013 at 12:07 PM, Michael Seiferle <ms at basex.org> wrote: > Thanks Liam, > you are right, the shortest way to achieve should be the following: > >> let $path-to-query-file := base-uri(<_/>) > > > Best from Konstanz > > Michael > > Am 02.04.2013 um 05:36 schrieb Liam R E Quin <liam at w3.org>: > >> On Mon, 2013-04-01 at 13:36 -0400, Graydon Saunders wrote: >> >>> I'd like to be able to say something like >>> >>> let $decisionSchema := >>> concat(string-join(tokenize(get-query-path(),'/')[position() ne >>> last()],'/'),'/decisions_schema.xsd') >>> >>> only I can't figure out what get-query-path() is. >> >> For many Query engines it won't be defined. >> >> You could try constructing an element and asking for its base URI I >> suppose. >> >> Liam >> >> -- >> Liam Quin - XML Activity Lead, W3C, http://www.w3.org/People/Quin/ >> Pictures from old books: http://fromoldbooks.org/ >> Ankh: irc.sorcery.net irc.gnome.org freenode/#xml >> >> _______________________________________________ >> BaseX-Talk mailing list >> BaseX-Talk at mailman.uni-konstanz.de >> https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk > > _______________________________________________ > BaseX-Talk mailing list > BaseX-Talk at mailman.uni-konstanz.de > https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk
GS
Graydon Saunders12 Apr 2013 16:34 #
I certainly do want to use static-base-uri(); thank you! Next time, I need to read the function definitions more slowly. :) -- Graydon On Fri, Apr 12, 2013 at 4:26 AM, Christian Grün <christian.gruen at gmail.com>wrote:
Quoted text · Christian Grün · 53 lines
> Hi Graydon, > > you may as well want to use the static-base-uri() function (“static” > refers to the given query file and not the database context). > > Christian > ___________________________ > > On Thu, Apr 4, 2013 at 12:07 PM, Michael Seiferle <ms at basex.org> wrote: > > Thanks Liam, > > you are right, the shortest way to achieve should be the following: > > > >> let $path-to-query-file := base-uri(<_/>) > > > > > > Best from Konstanz > > > > Michael > > > > Am 02.04.2013 um 05:36 schrieb Liam R E Quin <liam at w3.org>: > > > >> On Mon, 2013-04-01 at 13:36 -0400, Graydon Saunders wrote: > >> > >>> I'd like to be able to say something like > >>> > >>> let $decisionSchema := > >>> concat(string-join(tokenize(get-query-path(),'/')[position() ne > >>> last()],'/'),'/decisions_schema.xsd') > >>> > >>> only I can't figure out what get-query-path() is. > >> > >> For many Query engines it won't be defined. > >> > >> You could try constructing an element and asking for its base URI I > >> suppose. > >> > >> Liam > >> > >> -- > >> Liam Quin - XML Activity Lead, W3C, http://www.w3.org/People/Quin/ > >> Pictures from old books: http://fromoldbooks.org/ > >> Ankh: irc.sorcery.net irc.gnome.org freenode/#xml > >> > >> _______________________________________________ > >> BaseX-Talk mailing list > >> BaseX-Talk at mailman.uni-konstanz.de > >> https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk > > > > _______________________________________________ > > BaseX-Talk mailing list > > BaseX-Talk at mailman.uni-konstanz.de > > https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk >

⚡Generated with XQuery