Bug (?) with dynamic namespace constructor
Sunday, 30 January 2022 · 5 messages · last reply 31 Jan 2022
HR
Hans-Juergen Rennau30 Jan 2022 10:53 #
Dear BaseX people,
is this a bug:
basex "<foo>{namespace {''}{'bar'}}</foo>"
=>
[XQDY0102] Duplicate namespace declaration: ''.
?
This works as expected:
basex "<foo>{namespace {'xxx'}{'bar'}}</foo>"
=>
<foo xmlns:xxx="bar"/>
With kind regards,
Hans-Jürgen
CG
Christian Grün30 Jan 2022 17:53 #
Hi Hans-Jürgen,
Quoted text · Hans-Juergen Rennau · 3 lines
> basex "<foo>{namespace {''}{'bar'}}</foo>" > => > [XQDY0102] Duplicate namespace declaration: ''.
This is expected. The specification states that “[…] if the name of an element in an element constructor is in no namespace, creating a default namespace for that element using a computed namespace constructor is an error [err:XQDY0102]”
You’ll need to include a (static) namespace URI as part of the direct element constructor:
<foo xmlns='bar'/>Best,
Christian
[1] https://www.w3.org/TR/xquery-31/#id-ns-nodes-on-elements
HR
Hans-Juergen Rennau30 Jan 2022 23:48 #
Thank you, Christian, now I understand!
Incidentally, nevertheless I am not sure the following behaviour is correct: basex "<_ xmlns='bar'>{element foo {namespace {''} {'bar'}}}</_>/*"=> [XQDY0102] Duplicate namespace declaration: ''.
As the dynamic constructor is located in a static context with a default namespace, the foo should be interpreted as a name in that namespace, thus "if the name of an element in an element constructor is in no namespace" does not apply. Cordial greetings,Hans-Jürgen
PS: By contrast, this works:basex "<_ xmlns='bar'>{<foo/>}</_>/*" =><foo xmlns="bar"/>
PPS: And this also works:basex "<_ xmlns:f='bar'>{element f:foo {namespace {'f'} {'bar'}}}</_>/*" =>
<f:foo xmlns:f="bar"/>
Am Sonntag, 30. Januar 2022, 17:54:24 MEZ hat Christian Grün <christian.gruen at gmail.com> Folgendes geschrieben:
Hi Hans-Jürgen,
Quoted text · Christian Grün · 3 lines
> basex "<foo>{namespace {''}{'bar'}}</foo>" > => > [XQDY0102] Duplicate namespace declaration: ''.
This is expected. The specification states that “[…] if the name of an element in an element constructor is in no namespace, creating a default namespace for that element using a computed namespace constructor is an error [err:XQDY0102]”
You’ll need to include a (static) namespace URI as part of the direct element constructor:
<foo xmlns='bar'/>Best,
Christian
[1] https://www.w3.org/TR/xquery-31/#id-ns-nodes-on-elements
CG
Christian Grün31 Jan 2022 13:47 #
Fixed [1,2].
I ❤ namespaces.
[1] https://github.com/BaseXdb/basex/commit/869b411bbfabac57c98e7d756d48e1b38170951e [2] https://files.basex.org/releases/latest/
Quoted text · Hans-Juergen Rennau · 54 lines
On Sun, Jan 30, 2022 at 11:48 PM Hans-Juergen Rennau <hrennau at yahoo.de> wrote: > > Thank you, Christian, now I understand! > > Incidentally, nevertheless I am not sure the following behaviour is correct: > > basex "<_ xmlns='bar'>{element foo {namespace {''} {'bar'}}}</_>/*" > => > [XQDY0102] Duplicate namespace declaration: ''. > > As the dynamic constructor is located in a static context with a default namespace, the foo should be interpreted as a name in that namespace, thus "if the name of an element in an element constructor is in no namespace" does not apply. > > Cordial greetings, > Hans-Jürgen > > PS: By contrast, this works: > basex "<_ xmlns='bar'>{<foo/>}</_>/*" > => > <foo xmlns="bar"/> > > PPS: And this also works: > basex "<_ xmlns:f='bar'>{element f:foo {namespace {'f'} {'bar'}}}</_>/*" > => > <f:foo xmlns:f="bar"/> > > > > > Am Sonntag, 30. Januar 2022, 17:54:24 MEZ hat Christian Grün <christian.gruen at gmail.com> Folgendes geschrieben: > > > Hi Hans-Jürgen, > > > basex "<foo>{namespace {''}{'bar'}}</foo>" > > => > > [XQDY0102] Duplicate namespace declaration: ''. > > This is expected. The specification states that “[…] if the name of an > element in an element constructor is in no namespace, creating a > default namespace for that element using a computed namespace > constructor is an error [err:XQDY0102]” > > You’ll need to include a (static) namespace URI as part of the direct > element constructor: > > <foo xmlns='bar'/> > > Best, > Christian > > > [1] > https://www.w3.org/TR/xquery-31/#id-ns-nodes-on-elements >
HR
Hans-Juergen Rennau31 Jan 2022 14:00 #
Wahnsinn - phantastic, so many thanks! Tested - works!
Cheers,Hans-Jürgen
Am Montag, 31. Januar 2022, 13:47:56 MEZ hat Christian Grün <christian.gruen at gmail.com> Folgendes geschrieben:
Fixed [1,2].
I ❤ namespaces.
[1] https://github.com/BaseXdb/basex/commit/869b411bbfabac57c98e7d756d48e1b38170951e [2] https://files.basex.org/releases/latest/
Quoted text · Hans-Juergen Rennau · 54 lines
On Sun, Jan 30, 2022 at 11:48 PM Hans-Juergen Rennau <hrennau at yahoo.de> wrote: > > Thank you, Christian, now I understand! > > Incidentally, nevertheless I am not sure the following behaviour is correct: > > basex "<_ xmlns='bar'>{element foo {namespace {''} {'bar'}}}</_>/*" > => > [XQDY0102] Duplicate namespace declaration: ''. > > As the dynamic constructor is located in a static context with a default namespace, the foo should be interpreted as a name in that namespace, thus "if the name of an element in an element constructor is in no namespace" does not apply. > > Cordial greetings, > Hans-Jürgen > > PS: By contrast, this works: > basex "<_ xmlns='bar'>{<foo/>}</_>/*" > => > <foo xmlns="bar"/> > > PPS: And this also works: > basex "<_ xmlns:f='bar'>{element f:foo {namespace {'f'} {'bar'}}}</_>/*" > => > <f:foo xmlns:f="bar"/> > > > > > Am Sonntag, 30. Januar 2022, 17:54:24 MEZ hat Christian Grün <christian.gruen at gmail.com> Folgendes geschrieben: > > > Hi Hans-Jürgen, > > > basex "<foo>{namespace {''}{'bar'}}</foo>" > > => > > [XQDY0102] Duplicate namespace declaration: ''. > > This is expected. The specification states that “[…] if the name of an > element in an element constructor is in no namespace, creating a > default namespace for that element using a computed namespace > constructor is an error [err:XQDY0102]” > > You’ll need to include a (static) namespace URI as part of the direct > element constructor: > > <foo xmlns='bar'/> > > Best, > Christian > > > [1] > https://www.w3.org/TR/xquery-31/#id-ns-nodes-on-elements >
Written for BaseX 9.6. BaseX may have changed since: please check the current documentation.
⚡Generated with XQuery