Possible to Access Environment Variables from XQuery?
I’m running BaseX in a Docker container started via docker-compose. I need to communicate some local configuration details to BaseX. Can set these as environment variables (e.g., using .env with docker-compose) but I don’t see anything in the docs that would let me access environment variables from XQuery.
Is there a built-in way to do this?
Thanks,
Eliot
Hi Eliot,
fn:environment-variable should do the job; proc:property [1] can be used to access system properties.
Hope this helps, Christian
Quoted text · Eliot Kimber · 16 lines
On Sat, Mar 25, 2017 at 7:01 PM, Eliot Kimber <ekimber at contrext.com> wrote: > I’m running BaseX in a Docker container started via docker-compose. I need to communicate some local configuration details to BaseX. Can set these as environment variables (e.g., using .env with docker-compose) but I don’t see anything in the docs that would let me access environment variables from XQuery. > > Is there a built-in way to do this? > > Thanks, > > Eliot > > -- > Eliot Kimber > http://contrext.com > > > >
Hi Eliot,
Try the XPath function fn:environment-variable [1]
/Andy
[1] https://www.w3.org/TR/xpath-functions-31/#func-environment-variable
Quoted text · Eliot Kimber · 21 lines
On 25 March 2017 at 18:01, Eliot Kimber <ekimber at contrext.com> wrote: > I’m running BaseX in a Docker container started via docker-compose. I need > to communicate some local configuration details to BaseX. Can set these as > environment variables (e.g., using .env with docker-compose) but I don’t > see anything in the docs that would let me access environment variables > from XQuery. > > Is there a built-in way to do this? > > Thanks, > > Eliot > > -- > Eliot Kimber > http://contrext.com > > > > >
Thanks—it never occurred to me this would be a built-in function of XQuery 3.
Cheers,
E.
Quoted text · Christian Grün · 1 line
On 3/25/17, 7:05 PM, "Christian Grün" <christian.gruen at gmail.com> wrote:
proc:property [1] can be used to access system properties.
Hope this helps,
Christian
[1] http://docs.basex.org/wiki/Process_Module#proc:propertyQuoted text · Eliot Kimber · 16 lines
On Sat, Mar 25, 2017 at 7:01 PM, Eliot Kimber <ekimber at contrext.com> wrote: > I’m running BaseX in a Docker container started via docker-compose. I need to communicate some local configuration details to BaseX. Can set these as environment variables (e.g., using .env with docker-compose) but I don’t see anything in the docs that would let me access environment variables from XQuery. > > Is there a built-in way to do this? > > Thanks, > > Eliot > > -- > Eliot Kimber > http://contrext.com > > > >
Written for BaseX 8.6. BaseX may have changed since: please check the current documentation.