Dear Christian, 

after manifold motions making little speed it dawned on me that the problem occurs if the node in question is an element node, rather than the document node, as demonstrated by this query:

declare namespace f="http://www.parsqube.de";

declare function f:prettyNode($n as node()) as node()? {
    copy $n_ := $n
    modify delete nodes $n_//text()[not(matches(., '\S'))][../*]
    return $n_
};        

let $doc := doc('doc.xml')
let $dnode1 := $doc
let $dnode2 := f:prettyNode($dnode1)
let $enode1 := $doc/*
let $enode2 := f:prettyNode($enode1)
return (
    'Input document base URI:  '||$dnode1/base-uri(.),
    'Output document base URI: '||$dnode1/base-uri(.),
    '',
    'Input element base URI:   '||$enode1/base-uri(.),
    'Output element base URI:  '||$enode2/base-uri(.)
)

Output:
Input document base URI:  file:///C:/Projects/tableman/work/doc.xml
Output document base URI: file:///C:/Projects/tableman/work/doc.xml

Input element base URI:   file:///C:/Projects/tableman/work/doc.xml
Output element base URI:  file:///C:/Projects/tableman/work/test-pretty-node.xq

Greetings -
Hans-Jürgen

Am Montag, 28. August 2023 um 10:35:48 MESZ hat Christian Grün <christian.gruen@gmail.com> Folgendes geschrieben:


Hi Hans-Jürgen,

The following query gives me true:

(: doc.xml :)
<xml/>

(: query.xq :)
let $doc := doc('doc.xml')
let $copy := copy $d := $doc modify () return $d
return deep-equal(base-uri($doc), base-uri($copy))

Could you please provide us with a little self-contained example?

Thanks in advance,
Christian


On Thu, Aug 24, 2023 at 6:12 PM Hans-Juergen Rennau <hrennau@yahoo.de> wrote:
Dear BaseX team,

I seem to remember that in earlier versions of BaseX a copy/modify/return did not change the base URI of the processed document. However, now it is lost, or more precisely, replaced with the static base URI of the processing XQuery module.

Am I mistaken? At any rate it would be very desirable for copy/modify/return to preserve the base URI of the processed document or fragment.

Kind regards,
Hans-Jürgen