-
-
Notifications
You must be signed in to change notification settings - Fork 179
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
xmldb:rename() function fails if the collection name contains spaces #5299
Comments
Workaround
let $main-colection := '/db/test'
let $old-collection-name := 'data with spaces'
let $new-collection-name := 'data-with-dashes'
let $old-collection := $main-colection || replace($old-collection-name, ' ', '%20')
let $new-collection := $main-colection || $new-collection-name
let $resources := xmldb:get-child-resources($old-collection)[matches(., ".*\.*")]
let $created-collection := xmldb:create-collection($main-colection, $new-collection-name)
let $result :=
for $resource in $resources return
xmldb:copy-resource($old-collection, $resource, $new-collection, $resource, true())
return (xmldb:remove($old-collection), $created-collection, $result) |
See discussion at #1824. From my summary:
|
From my point of view, there is an inconsistency in the treatment of collection names. The following function call works
but this one fails
It uses the same (encoded) name of the collection. |
@daliboris I tried to reproduce the issue and found it to work with collections with %-encoded spaces: xquery version "3.1";
let $_ := xmldb:create-collection("/db", "test")
let $_ := xmldb:create-collection("/db/test", "data%20with%20spaces")
return xmldb:rename("/db/test/data%20with%20spaces", "a") Maybe the issue was just that |
You're right @line-o, your code works. Maybe the documentation is misleading: xmldb:rename($source-collection-uri as xs:string, $new-collection-name as xs:string) as item() Renames the collection But the Or does it mean that the collection name represented by the URI is only the outermost part of the URI, not the entire URI? |
Collection with spaces in name cannot be renamed
If the collection name contains spaces, calling function
xmldb:rename($source-collection-uri as xs:string, $new-collection-name as xs:string)
fails with the following error:Expected behavior
Collection with spaces should be renamed.
The
xmldb:rename()
function with 4 parametrs works if the renamed resource contains spaces, for instanceTo Reproduce
Context
The text was updated successfully, but these errors were encountered: