Add namespace bindings via copy/modify/return

Saturday, 2 August 2025 · 10 messages · last reply 25 Sep 2025
HR
Hans-Juergen Rennau2 Aug 2025 15:51 #
Dear BaseX people, I cannot use copy/modify/return in order to add a namespacing: let $doc := <doc><a/></doc>return copy $doc_ := $doc modify insert node namespace xyz {'https://basex.org/ns'} into $doc_ return $doc_ =><doc> <a/></doc> Is this a bug? Kind regards,Hans-Jürgen
CG
Christian Grün4 Aug 2025 12:49 #
Hi Hans-Jürgen, The insertion of namespace nodes has not been defined in the XQuery Update spec. You may need choose the classic element constructor for that:
let $doc := <doc><a/></doc>
return element { node-name($doc) } {
  $doc/@*,
  namespace xyz { 'https://basex.org/ns' },
  $doc/node()
}
Hope this helps, Christian
Quoted text · Hans-Juergen Rennau · 19 lines
Von: Hans-Juergen Rennau via BaseX-Talk <basex-talk at mailman.uni-konstanz.de> Gesendet: Samstag, 2. August 2025 15:51 An: BaseX <basex-talk at mailman.uni-konstanz.de> Betreff: [basex-talk] Add namespace bindings via copy/modify/return Dear BaseX people, I cannot use copy/modify/return in order to add a namespacing: let $doc := <doc><a/></doc> return copy $doc_ := $doc modify insert node namespace xyz {'https://basex.org/ns'} into $doc_ return $doc_ => <doc> <a/> </doc> Is this a bug? Kind regards, Hans-Jürgen
HR
Hans-Juergen Rennau4 Aug 2025 13:09 #
Thank you, Christian! The problem is that this way I lose the base URI! The only way how to retain it which I am aware of would be the insertion of @xml:base, but this amounts to a change of the document I may not be authorized to do by the context. Is there any way how to change a document (as modified copy, not via copy/modify/return) and retain or control the base URI of the result, without inserting @xml:base? Kind regards, Hans-Jürgen Am Montag, 4. August 2025 um 12:49:50 MESZ hat Christian Grün <cg at basex.org> Folgendes geschrieben: Hi Hans-Jürgen, The insertion of namespace nodes has not been defined in the XQuery Update spec. You may need choose the classic element constructor for that:
let $doc := <doc><a/></doc>

return element { node-name($doc) } {

  $doc/@*,
namespace xyz { 'https://basex.org/ns' },
  $doc/node()
} Hope this helps, Christian
Quoted text · Hans-Juergen Rennau · 19 lines
Von: Hans-Juergen Rennau via BaseX-Talk <basex-talk at mailman.uni-konstanz.de> Gesendet: Samstag, 2. August 2025 15:51 An: BaseX <basex-talk at mailman.uni-konstanz.de> Betreff: [basex-talk] Add namespace bindings via copy/modify/return Dear BaseX people, I cannot use copy/modify/return in order to add a namespacing: let $doc := <doc><a/></doc> return copy $doc_ := $doc modify insert node namespace xyz {'https://basex.org/ns'} into $doc_ return $doc_ => <doc> <a/> </doc> Is this a bug? Kind regards, Hans-Jürgen
CG
Christian Grün4 Aug 2025 17:01 #
Hi Hans-Jürgen, It feels a bit clumsy, but adding a prefixed attribute and removing it again should do the job:
  let $xml := doc('x.xml')
  let $updated := $xml update {
    insert node <a xmlns:prefix='URI' prefix:attr=''/>/@* into *
  } update {
    delete node */@attr
  }
  return ($updated, base-uri($updated))
Best, Christian
Quoted text · Hans-Juergen Rennau · 38 lines
Von: Hans-Juergen Rennau <hrennau at yahoo.de> Gesendet: Montag, 4. August 2025 13:09 An: BaseX <basex-talk at mailman.uni-konstanz.de>; Christian Grün <cg at basex.org> Betreff: Re: AW: [basex-talk] Add namespace bindings via copy/modify/return Thank you, Christian! The problem is that this way I lose the base URI! The only way how to retain it which I am aware of would be the insertion of @xml:base, but this amounts to a change of the document I may not be authorized to do by the context. Is there any way how to change a document (as modified copy, not via copy/modify/return) and retain or control the base URI of the result, without inserting @xml:base? Kind regards, Hans-Jürgen Am Montag, 4. August 2025 um 12:49:50 MESZ hat Christian Grün <cg at basex.org> Folgendes geschrieben: Hi Hans-Jürgen, The insertion of namespace nodes has not been defined in the XQuery Update spec. You may need choose the classic element constructor for that: let $doc := <doc><a/></doc> return element { node-name($doc) } { $doc/@*, namespace xyz { 'https://basex.org/ns' }, $doc/node() } Hope this helps, Christian Von: Hans-Juergen Rennau via BaseX-Talk <basex-talk at mailman.uni-konstanz.de> Gesendet: Samstag, 2. August 2025 15:51 An: BaseX <basex-talk at mailman.uni-konstanz.de> Betreff: [basex-talk] Add namespace bindings via copy/modify/return Dear BaseX people, I cannot use copy/modify/return in order to add a namespacing: let $doc := <doc><a/></doc> return copy $doc_ := $doc modify insert node namespace xyz {'https://basex.org/ns'} into $doc_ return $doc_ => <doc> <a/> </doc> Is this a bug? Kind regards, Hans-Jürgen
HR
Hans-Juergen Rennau4 Aug 2025 22:58 #
Thank you very much, Christian, a tip much appreciated! It works. In case (quite improbable) that someone else faces the requirement to add namespaces, retaining the base URI, I add the code of a function I wrote for this operation. Kind regards, Hans-Jürgen PS: Is it not simply oversight that the Update spec does not support the insertion of namespace nodes, although XQuery 3.0 does define their constructors? Would a feature request have any chance?
 (:~
  : Adds namespace nodes to a node, retaining its base URI.
  : Note that the namespaces are added to the root element of
  : the incoming document or fragment.
  :)
 declare function f:addNamespaces($node as node(),
                                  $namespaces as namespace-node()*)
         as node() {
    let $root := $node ! root()
    let $fnElem := function($n) {$n/descendant-or-self::*[1]}
    let $prefixes := $namespaces ! name(.)
    let $uris := $namespaces ! string(.)
    return $root
        update {
            for $p at $pos in $prefixes
            let $uri := $uris[$pos]
            let $attName := QName($uri, $p||':_')
            return insert node attribute {$attName} {()} into $fnElem(.)
        }
        update {
            let $elem := $fnElem(.)
            for $p in $prefixes
            return delete node $elem/@*[name() eq $p||':_']
        }
};
Am Montag, 4. August 2025 um 17:03:28 MESZ hat Christian Grün <cg at basex.org> Folgendes geschrieben: Hi Hans-Jürgen, It feels a bit clumsy, but adding a prefixed attribute and removing it again should do the job:
  let $xml := doc('x.xml')

  let $updated := $xml update {
insert node <a xmlns:prefix='URI' prefix:attr=''/>/@* into *
  } update {
delete node */@attr } return ($updated, base-uri($updated)) Best, Christian
Quoted text · Hans-Juergen Rennau · 38 lines
Von: Hans-Juergen Rennau <hrennau at yahoo.de> Gesendet: Montag, 4. August 2025 13:09 An: BaseX <basex-talk at mailman.uni-konstanz.de>; Christian Grün <cg at basex.org> Betreff: Re: AW: [basex-talk] Add namespace bindings via copy/modify/return Thank you, Christian! The problem is that this way I lose the base URI! The only way how to retain it which I am aware of would be the insertion of @xml:base, but this amounts to a change of the document I may not be authorized to do by the context. Is there any way how to change a document (as modified copy, not via copy/modify/return) and retain or control the base URI of the result, without inserting @xml:base? Kind regards, Hans-Jürgen Am Montag, 4. August 2025 um 12:49:50 MESZ hat Christian Grün <cg at basex.org> Folgendes geschrieben: Hi Hans-Jürgen, The insertion of namespace nodes has not been defined in the XQuery Update spec. You may need choose the classic element constructor for that: let $doc := <doc><a/></doc> return element { node-name($doc) } { $doc/@*, namespace xyz { 'https://basex.org/ns' }, $doc/node() } Hope this helps, Christian Von: Hans-Juergen Rennau via BaseX-Talk <basex-talk at mailman.uni-konstanz.de> Gesendet: Samstag, 2. August 2025 15:51 An: BaseX <basex-talk at mailman.uni-konstanz.de> Betreff: [basex-talk] Add namespace bindings via copy/modify/return Dear BaseX people, I cannot use copy/modify/return in order to add a namespacing: let $doc := <doc><a/></doc> return copy $doc_ := $doc modify insert node namespace xyz {'https://basex.org/ns'} into $doc_ return $doc_ => <doc> <a/> </doc> Is this a bug? Kind regards, Hans-Jürgen
CG
Christian Grün5 Aug 2025 11:46 #
Quoted text · Hans-Juergen Rennau · 1 line
> PS: Is it not simply oversight that the Update spec does not support the insertion of namespace nodes, although XQuery 3.0 does define their constructors? Would a feature request have any chance?
If I remember correctly, the namespace constructor had not yet been defined when XQuery Update 1.0 was finalized. On XQUF 3.0, not too much time was spent, so it can indeed be regarded as an oversight. While it may not be too much effort to implement, it could take some time to specify it properly. Anything involving namespaces takes much longer than it seems at first glance…
ML
Marco Duiker - LandGoedin reply to Hans-Juergen Rennau, 2 Aug 2025, 15:5124 Sep 2025 15:44 #
Dear BaseX people, As I use BaseX mainly for data containing a lot of geospatial information i'd love to see support for querying gml (3.x) in BaseX. Google points me to some promising but very old materials (eg. https://files.basex.org/publications/Seydi%20Gheranghiyeh%20%5B2015%5D,%20Geospatial%20Processing%20in%20BaseX.pdf) which is already more than 10 years old. I can see that the Geo module was removed at version 10 and only supported gml 2. This leads me to a few questions. Any help greatly appreciated: * Is there any feasible way to query gml 3.x using BaseX? * Are there any plans for bringing back geo module and add support for gml 3 * Would it help if I do some funding for this? Regards, MArco
-- Marco Duiker LandGoed Technisch directeur +31617115114
GR
Gunther Rademacher24 Sep 2025 18:52 #
Dear Marco, thank you for your interest in the BaseX Geo Module. Although unpublished, we currently have an updated version that works with both GML 2 and GML 3.2. It supports the basic geometry types (Point, Polygon, etc.), while more complex constructs, such as Feature Collections, are not covered. In practice, this means that the module can parse and process GML 3.2 geometries, but there are limitations with regard to the broader schema. The module has already been used successfully in customer projects with GML 3.2 data. The functionality largely corresponds to the EXPath Geo Module specification, http://expath.org/spec/geo , with both GML 2 and their corresponding GML 3.2 geometries being recognized. Functions that return geometries will produce results in GML 2 or GML 3.2, depending on the input. To better understand your situation, could you share which parts of GML 3 you rely on most - for example, specific geometry types? In addition, it might be helpful for you to review the EXPath specification and check whether the functions described there already meet your needs. This would give us a clearer picture of whether the current functionality is sufficient for your use case. Best regards, Gunther Gesendet: Mittwoch, 24. September 2025 um 15:44
Quoted text · Marco Duiker - LandGoed · 17 lines
Von: "Marco Duiker - LandGoed via BaseX-Talk" <basex-talk at mailman.uni-konstanz.de> An: basex-talk at mailman.uni-konstanz.de Betreff: [basex-talk] gml3 support Dear BaseX people, As I use BaseX mainly for data containing a lot of geospatial information i'd love to see support for querying gml (3.x) in BaseX. Google points me to some promising but very old materials (eg. https://files.basex.org/publications/Seydi%20Gheranghiyeh%20%5B2015%5D,%20Geospatial%20Processing%20in%20BaseX.pdf) which is already more than 10 years old. I can see that the Geo module was removed at version 10 and only supported gml 2. This leads me to a few questions. Any help greatly appreciated: Is there any feasible way to query gml 3.x using BaseX? Are there any plans for bringing back geo module and add support for gml 3 Would it help if I do some funding for this? Regards, MArco -- Marco Duiker LandGoed Technisch directeur +31617115114
IL
Imsieke, Gerrit, le-texin reply to Marco Duiker - LandGoed, 24 Sep 2025, 15:4424 Sep 2025 21:05 #
Hi Marco,
Quoted text · Marco Duiker - LandGoed · 2 lines
On 24.09.2025 15:44, Marco Duiker - LandGoed via BaseX-Talk wrote: > Would it help if I do some funding for this?
This hasn’t been covered by Gunther’s reply, but it is an important point. BaseX could have so many more attractive and modern features if there were more funding, especially from commercial or public entities. The transform() function [1], a new storage layout that supports more than 255 namespaces [2], or multiversion concurrency control [3] come to my mind. Or GML 3.2 support and a revived geospatial module. We and our customers sponsored a few features already, such as XML catalog support for xsl:include/xsl:import in Saxon (that is invoked from BaseX) or xslt:transform-report() [4]. We know how hard it is to convince individual customers or a consortium to sponsor a feature in an open source project. So please, try to hand over as much money as you can afford to the team to get the features that you need (without distracting them too much, of course). Gerrit [1] https://www.w3.org/TR/xpath-functions-31/#func-transform [2] https://github.com/BaseXdb/basex/issues/902 [3] https://en.wikipedia.org/wiki/Multiversion_concurrency_control [4] https://docs.basex.org/main/XSLT_Functions#xslt:transform-report
ML
Marco Duiker - LandGoedin reply to Gunther Rademacher, 24 Sep 2025, 18:5225 Sep 2025 08:44 #
Dear Gunther, Great to hear that things are already possible. Can you please point me to some docs on how this is working? Most of my use cases will be covered by Simple features (points, lines, polygon also in the multi form), geometry collections of one geometry type (so collections of eg multipoints only, but not multipoint and multipolygon in one collection) and curves defined by 3 points. Functionality as described in http://expath.org/spec/geo does meet my needs. regards, Marco
Quoted text · Gunther Rademacher · 59 lines
On 24-09-2025 18:52, Gunther Rademacher wrote: > Dear Marco, > > thank you for your interest in the BaseX Geo Module. > > Although unpublished, we currently have an updated version that works > with both GML 2 and GML 3.2. It supports the basic geometry types > (Point, Polygon, etc.), while more complex constructs, such as Feature > Collections, are not covered. In practice, this means that the module > can parse and process GML 3.2 geometries, but there are limitations > with regard to the broader schema. The module has already been used > successfully in customer projects with GML 3.2 data. > > The functionality largely corresponds to the EXPath Geo Module > specification, http://expath.org/spec/geo , with both GML 2 and their > corresponding GML 3.2 geometries being recognized. Functions that > return geometries will produce results in GML 2 or GML 3.2, depending > on the input. > > To better understand your situation, could you share which parts of > GML 3 you rely on most - for example, specific geometry types? In > addition, it might be helpful for you to review the EXPath > specification and check whether the functions described there already > meet your needs. This would give us a clearer picture of whether the > current functionality is sufficient for your use case. > > Best regards, > Gunther > *Gesendet: *Mittwoch, 24. September 2025 um 15:44 > *Von: *"Marco Duiker - LandGoed via BaseX-Talk" > <basex-talk at mailman.uni-konstanz.de> > *An: *basex-talk at mailman.uni-konstanz.de > *Betreff: *[basex-talk] gml3 support > Dear BaseX people, > > As I use BaseX mainly for data containing a lot of geospatial > information i'd love to see support for querying gml (3.x) in BaseX. > > Google points me to some promising but very old materials (eg. > https://files.basex.org/publications/Seydi%20Gheranghiyeh%20%5B2015%5D,%20Geospatial%20Processing%20in%20BaseX.pdf) > which is already more than 10 years old. > > I can see that the Geo module was removed at version 10 and only > supported gml 2. > > This leads me to a few questions. Any help greatly appreciated: > > * Is there any feasible way to query gml 3.x using BaseX? > * Are there any plans for bringing back geo module and add support > for gml 3 > * Would it help if I do some funding for this? > > Regards, MArco > > -- > Marco Duiker > LandGoed > Technisch directeur > +31617115114
-- Marco Duiker LandGoed Technisch directeur +31617115114

⚡Generated with XQuery