default context item

Sunday, 31 October 2021 · 5 messages · last reply 3 Nov 2021
HR
Hans-Juergen Rennau31 Oct 2021 10:46 #
Dear BaseX people, probably a blackout of mine, but I do not understand the following behaviour. Query: declare context item external := '#none'; . When I call it, specifying a context item using -i or -I, I always get the default context item ('#none'). What do I overlook? Kind regards,Hans-Jürgen
CG
Christian Grün2 Nov 2021 13:41 #
Hi Hans-Jürgen, If you assign an external context item on command line, there is no need for a context item declaration in the query prolog:
Quoted text · Hans-Juergen Rennau · 1 line
> basex -I123 .
123 If a declaration exists with a default value, the bound context item is replaced by this default value. This contrasts with the behavior of variable declarations, though, so I might check if we can align the behavior in one or the other way. Schöne Grüße Christian
Quoted text · Hans-Juergen Rennau · 15 lines
On Sun, Oct 31, 2021 at 10:47 AM Hans-Juergen Rennau <hrennau at yahoo.de> wrote: > > Dear BaseX people, > > probably a blackout of mine, but I do not understand the following behaviour. Query: > > declare context item external := '#none'; > . > > When I call it, specifying a context item using -i or -I, I always get the default context item ('#none'). > > What do I overlook? > > Kind regards, > Hans-Jürgen
CG
Christian Grün2 Nov 2021 15:01 #
The behavior is more consistent now in the latest snapshot [1]: The default context item will be overwritten by an externally supplied value. [1] https://files.basex.org/releases/latest/
Quoted text · Christian Grün · 36 lines
On Tue, Nov 2, 2021 at 1:41 PM Christian Grün <christian.gruen at gmail.com> wrote: > > Hi Hans-Jürgen, > > If you assign an external context item on command line, there is no > need for a context item declaration in the query prolog: > > > basex -I123 . > 123 > > If a declaration exists with a default value, the bound context item > is replaced by this default value. > > This contrasts with the behavior of variable declarations, though, so > I might check if we can align the behavior in one or the other way. > > Schöne Grüße > Christian > > > > On Sun, Oct 31, 2021 at 10:47 AM Hans-Juergen Rennau <hrennau at yahoo.de> wrote: > > > > Dear BaseX people, > > > > probably a blackout of mine, but I do not understand the following behaviour. Query: > > > > declare context item external := '#none'; > > . > > > > When I call it, specifying a context item using -i or -I, I always get the default context item ('#none'). > > > > What do I overlook? > > > > Kind regards, > > Hans-Jürgen
HR
Hans-Juergen Rennau2 Nov 2021 20:36 #
Hi Christian, thank you very much for your response and the new snapshot. I do not quite understand what you mean by "alignment", as I think the spec leaves no room for interpretation, any "more" or "less": if using "declare context item external := ...", the default context item declared must be replaced by the context item supplied, if there is one. Testing the new snapshot I noticed that an atomic context item specified via -I does replace the default value, but a document context item specified via -i does not. That was not intended, I think? Bonner Grüße,Hans-Jürgen Am Dienstag, 2. November 2021, 15:01:49 MEZ hat Christian Grün <christian.gruen at gmail.com> Folgendes geschrieben: The behavior is more consistent now in the latest snapshot [1]: The default context item will be overwritten by an externally supplied value. [1] https://files.basex.org/releases/latest/
Quoted text · Christian Grün · 36 lines
On Tue, Nov 2, 2021 at 1:41 PM Christian Grün <christian.gruen at gmail.com> wrote: > > Hi Hans-Jürgen, > > If you assign an external context item on command line, there is no > need for a context item declaration in the query prolog: > > > basex -I123 . > 123 > > If a declaration exists with a default value, the bound context item > is replaced by this default value. > > This contrasts with the behavior of variable declarations, though, so > I might check if we can align the behavior in one or the other way. > > Schöne Grüße > Christian > > > > On Sun, Oct 31, 2021 at 10:47 AM Hans-Juergen Rennau <hrennau at yahoo.de> wrote: > > > > Dear BaseX people, > > > > probably a blackout of mine, but I do not understand the following behaviour. Query: > > > > declare context item external := '#none'; > > . > > > > When I call it, specifying a context item using -i or -I, I always get the default context item ('#none'). > > > > What do I overlook? > > > > Kind regards, > > Hans-Jürgen
CG
Christian Grün3 Nov 2021 11:14 #
Thanks, Hans-Jürgen, your additional remarks have been helpful. My phrase on »aligning the behavior« was a bit arcane, as more insight into the specific implementation is required to understand the implications I had in mind. The major challenge is that there are various ways how a context value can be assigned (via Java, APIs, the command-line, and XQuery), and that it’s important in which order the assignments take place. I think that the latest update (and uploaded snapshot) should match the majority of the cases one might be able to generate. Please note that the context item declaration is still optional (but it can certainly be helpful if you need to specify a default value).
Quoted text · Hans-Juergen Rennau · 59 lines
On Tue, Nov 2, 2021 at 8:36 PM Hans-Juergen Rennau <hrennau at yahoo.de> wrote: > > Hi Christian, > > thank you very much for your response and the new snapshot. I do not quite understand what you mean by "alignment", as I think the spec leaves no room for interpretation, any "more" or "less": if using "declare context item external := ...", the default context item declared must be replaced by the context item supplied, if there is one. > > Testing the new snapshot I noticed that an atomic context item specified via -I does replace the default value, but a document context item specified via -i does not. That was not intended, I think? > > Bonner Grüße, > Hans-Jürgen > > > > Am Dienstag, 2. November 2021, 15:01:49 MEZ hat Christian Grün <christian.gruen at gmail.com> Folgendes geschrieben: > > > The behavior is more consistent now in the latest snapshot [1]: The > default context item will be overwritten by an externally supplied > value. > > [1] https://files.basex.org/releases/latest/ > > > On Tue, Nov 2, 2021 at 1:41 PM Christian Grün <christian.gruen at gmail.com> wrote: > > > > Hi Hans-Jürgen, > > > > If you assign an external context item on command line, there is no > > need for a context item declaration in the query prolog: > > > > > basex -I123 . > > 123 > > > > If a declaration exists with a default value, the bound context item > > is replaced by this default value. > > > > This contrasts with the behavior of variable declarations, though, so > > I might check if we can align the behavior in one or the other way. > > > > Schöne Grüße > > Christian > > > > > > > > On Sun, Oct 31, 2021 at 10:47 AM Hans-Juergen Rennau <hrennau at yahoo.de> wrote: > > > > > > Dear BaseX people, > > > > > > probably a blackout of mine, but I do not understand the following behaviour. Query: > > > > > > declare context item external := '#none'; > > > . > > > > > > When I call it, specifying a context item using -i or -I, I always get the default context item ('#none'). > > > > > > What do I overlook? > > > > > > Kind regards, > > > Hans-Jürgen

⚡Generated with XQuery