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
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
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 := $doclet $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.xmlOutput document base URI: file:///C:/Projects/tableman/work/doc.xml Input element base URI: file:///C:/Projects/tableman/work/doc.xmlOutput 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
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:
Thanks. This behavior is compliant with the spec: A copied element loses its reference to the document node providing the base URI.
Hope this helps, Christian
A pity (for me), because I need to preserve the information about an element's origin without changing the element by adding a clumsy @xml:base. Out of luck. Kind regards,Hans-Jürgen
Am Montag, 28. August 2023 um 16:11:56 MESZ hat Christian Grün christian.gruen@gmail.com Folgendes geschrieben:
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:
Thanks. This behavior is compliant with the spec: A copied element loses its reference to the document node providing the base URI. Hope this helps,Christian
The restriction goes back to the XML standard:
https://www.w3.org/TR/xmlbase/#granularity
Hans-Juergen Rennau hrennau@yahoo.de schrieb am Mo., 28. Aug. 2023, 16:39:
A pity (for me), because I need to preserve the information about an element's origin without changing the element by adding a clumsy @xml:base.
Out of luck.
Kind regards, Hans-Jürgen
Am Montag, 28. August 2023 um 16:11:56 MESZ hat Christian Grün < christian.gruen@gmail.com> Folgendes geschrieben:
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:
Thanks. This behavior is compliant with the spec: A copied element loses its reference to the document node providing the base URI.
Hope this helps, Christian
basex-talk@mailman.uni-konstanz.de