Bug #4891

hedge case?: file:copy deletes destination

Added by Giuseppe Bonelli 22 days ago. Updated 22 days ago.

In Progress
Start date:
Due date:
% Done:


Estimated time:
Legacy ID:
Applies to branch:
Fix Committed on Branch:
Fixed in Maintenance Release:


Hi, I am running SaxonPE9-9-1-8J under ubuntu (from a windows10 unix subsystem bash shell) and I found this:


<xsl:variable name="src" select="file:///dir/File.ext"/>

<xsl:variable name="dst" select="file:///dir/file.ext"/>

I.e. $dst=lower-case($src)


<xsl:value-of select="file:move($src, $dst)"/>

deletes the file at $dst

The easy workaround is:

<xsl:variable name="dst_tmp" select="concat($dst, '_tmp')"/>

<xsl:value-of select="file:move($src, $dst_tmp)"/>

<xsl:value-of select="file:move($dst_tmp, $dst)"/>

but maybe this shoud be investigated.

I have not tried under a regular bash shell, so maybe this is specific to Windows10 unix subsystem



#1 Updated by Michael Kay 22 days ago

  • Status changed from New to In Progress

This seems entirely consistent with the specification, which states (in ยง4.11):

if $target is a file, it will be overwritten

There are many other ways of having two different URIs that refer to the same file, for example by using non-normalised URIs, query parameters, or symbolic links. I'm not sure there is even a reliable way of discovering that two URIs refer to the same file.

#2 Updated by Giuseppe Bonelli 22 days ago

Yes, I agree, but I assumed that uris are case sensitive.

Or they aren't?

#3 Updated by Michael Kay 22 days ago

Correct, URI's are case sensitive. So file:///c:/x.xml and file:///C:/X.XML are two different URIs. But (on Windows) they are different names for the same underlying resource. You can have many other URIs also referring to this resource, for example if it is on an HTTP server then http://localhost/x.xml might be the same resource; and if you delete the resource using any of these URIs, the resource will be gone and the other URIs will fail to find it. A name is not the same as the thing it refers to; things can have more than one name.

#4 Updated by Giuseppe Bonelli 22 days ago

Ok, agreed.

I was assuming that a file name under the windows unix subsystem is case sensitive, but it seems it is not!

Thanks for the quick answer (and for saxonica).


Please register to edit this issue

Also available in: Atom PDF