document-uri() and base-uri() functions in BaseX 11.8

Friday, 21 March 2025 · 5 messages · last reply 25 Mar 2025
Y
ykhabins21 Mar 2025 15:36 #
Hello, Congrats on the BaseX 11.8 release. Was there a change in BaseX 11.8 to the document-uri() and base-uri() functions behavior? It seems that they are striping out a file name at the end of the fully qualified file path on the file system! Please find below a repro of it. BaseX 11.7 ========== declare variable $base_dir as xs:string := 'e:\Temp\Identity Transformation88\';
for $x at $i in collection($base_dir)
let $file := tokenize(document-uri($x), '/')[last()]
return (document-uri($x), $file)
Emits the following as expected: file:///E:/Temp/Identity%20Transformation88/Input.xml Input.xml file:///E:/Temp/Identity%20Transformation88/Output.xml Output.xml BaseX 11.8 ========== The same XQuery emits the following: file:///E:/Temp/Identity%20Transformation88/ file:///E:/Temp/Identity%20Transformation88/ Regards, Yitzhak Khabinsky
GR
Gunther Rademacher21 Mar 2025 20:41 #
Hi Yitzhak, thank you for reporting this. This is my fault, this change is causing it: https://github.com/BaseXdb/basex/commit/83acbb74f9419d50a4c03c5793647d449b5577c1 It was made to fix the behavior of duplicating the last part of the path. E.g. this query
    base-uri(doc('https://www.w3.org/TR/xml/'))
up to 11.7 used to return https://www.w3.org/TR/xml/xml which is clearly wrong, and the above mentioned change fixes it to correctly return https://www.w3.org/TR/xml/ But as you noticed it obviously affects documents retrieved by fn:collection, and that slippped through our tests. Note that it does not affect documents retrieved by fn:doc, so in your case
    document-uri(doc("E:\Temp\Identity Transformation88\Input.xml"))
should still return the correct file URI. Apologies for the oversight - I’ll investigate further. Best regards, Gunther Gesendet: Freitag, 21. März 2025 um 15:36
Quoted text · ykhabins at bellsouth.net · 29 lines
Von: ykhabins at bellsouth.net An: basex-talk at mailman.uni-konstanz.de Betreff: [basex-talk] document-uri() and base-uri() functions in BaseX 11.8 Hello, Congrats on the BaseX 11.8 release. Was there a change in BaseX 11.8 to the document-uri() and base-uri() functions behavior? It seems that they are striping out a file name at the end of the fully qualified file path on the file system! Please find below a repro of it. BaseX 11.7 ========== declare variable $base_dir as xs:string := 'e:\Temp\Identity Transformation88\'; for $x at $i in collection($base_dir) let $file := tokenize(document-uri($x), '/')[last()] return (document-uri($x), $file) Emits the following as expected: file:///E:/Temp/Identity%20Transformation88/Input.xml Input.xml file:///E:/Temp/Identity%20Transformation88/Output.xml Output.xml BaseX 11.8 ========== The same XQuery emits the following: file:///E:/Temp/Identity%20Transformation88/ file:///E:/Temp/Identity%20Transformation88/ Regards, Yitzhak Khabinsky
GR
Gunther Rademacher25 Mar 2025 19:19 #
Hi Yitzhak, this has been now addressed by https://github.com/BaseXdb/basex/pull/2404 and the fix is contained in the latest snapshot: https://files.basex.org/releases/latest/ Best regards, Gunther Gesendet: Freitag, 21. März 2025 um 20:41
Quoted text · Gunther Rademacher · 48 lines
Von: "Gunther Rademacher via BaseX-Talk" <basex-talk at mailman.uni-konstanz.de> An: ykhabins at bellsouth.net, basex-talk at mailman.uni-konstanz.de Betreff: [basex-talk] Re: document-uri() and base-uri() functions in BaseX 11.8 Hi Yitzhak, thank you for reporting this. This is my fault, this change is causing it: https://github.com/BaseXdb/basex/commit/83acbb74f9419d50a4c03c5793647d449b5577c1 It was made to fix the behavior of duplicating the last part of the path. E.g. this query base-uri(doc('https://www.w3.org/TR/xml/')) up to 11.7 used to return https://www.w3.org/TR/xml/xml which is clearly wrong, and the above mentioned change fixes it to correctly return https://www.w3.org/TR/xml/ But as you noticed it obviously affects documents retrieved by fn:collection, and that slippped through our tests. Note that it does not affect documents retrieved by fn:doc, so in your case document-uri(doc("E:\Temp\Identity Transformation88\Input.xml")) should still return the correct file URI. Apologies for the oversight - I’ll investigate further. Best regards, Gunther Gesendet: Freitag, 21. März 2025 um 15:36 Von: ykhabins at bellsouth.net An: basex-talk at mailman.uni-konstanz.de Betreff: [basex-talk] document-uri() and base-uri() functions in BaseX 11.8 Hello, Congrats on the BaseX 11.8 release. Was there a change in BaseX 11.8 to the document-uri() and base-uri() functions behavior? It seems that they are striping out a file name at the end of the fully qualified file path on the file system! Please find below a repro of it. BaseX 11.7 ========== declare variable $base_dir as xs:string := 'e:\Temp\Identity Transformation88\'; for $x at $i in collection($base_dir) let $file := tokenize(document-uri($x), '/')[last()] return (document-uri($x), $file) Emits the following as expected: file:///E:/Temp/Identity%20Transformation88/Input.xml Input.xml file:///E:/Temp/Identity%20Transformation88/Output.xml Output.xml BaseX 11.8 ========== The same XQuery emits the following: file:///E:/Temp/Identity%20Transformation88/ file:///E:/Temp/Identity%20Transformation88/ Regards, Yitzhak Khabinsky
Y
ykhabins25 Mar 2025 20:20 #
Hi Gunter, I tested the latest build, BaseX 11.9 beta c55e0e8 Everything is back to normal. The document-uri() and base-uri() functions working as expected. Thanks a lot for such quick turn-around with the fix. Regards, Yitzhak Khabinsky
Y
ykhabins25 Mar 2025 20:27 #
Hi Gunther, I tested the latest build, BaseX 11.9 beta c55e0e8 Everything is back to normal. The document-uri() and base-uri() functions working as expected. Thanks a lot for such quick turn-around with the fix. Regards, Yitzhak Khabinsky

⚡Generated with XQuery