Skip to content
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

[feature] add mkdir -p like function to xmldb XQuery module #4238

Open
line-o opened this issue Feb 11, 2022 · 1 comment · May be fixed by #5062
Open

[feature] add mkdir -p like function to xmldb XQuery module #4238

line-o opened this issue Feb 11, 2022 · 1 comment · May be fixed by #5062
Labels
enhancement new features, suggestions, etc.

Comments

@line-o
Copy link
Member

line-o commented Feb 11, 2022

I've seen one-off implementations - and built one of my own - to solve a common problem:

Create an collection where missing parent collections will be created.

On the linux command line this is possible by setting the -p flag on mkdir.

mkdir -p `/this/is/a/deeply/nested/directory`

nodeJS for example mimics this behaviour by setting the recursive option on the builtin fs.mkdir method.

There is no such facility present in eXistdb to my knowledge. That is why I propose to add that by either

  1. a new function xmldb:create-collection-recursive accepting one parameter:
  • collectionUri as xs:string
  1. or add a signature to xmldb:create-collection accepting two parameters:
  • collectionUri as xs:string
  • options as xs:map
  1. create a new builtin XQuery module that will handle this and all other collection operations. This module would then deprecate
    currently available functions xmldb:create-collection, xmldb:collection-available and the like. While this is definitely a controversial proposal it also has the potential to rethink our current approach while maintaining backwards compatibility.

The fact that xmldb:create-collection already has a two parameter signature does rule out option 2 unless we choose to also
introduce a breaking change. The current xmldb:create-collection#2 would have to be changed to
xmldb:create-collection($collectionUri as xs:string) as xs:string removing the parent collection parameter that is currently expected.

I personally favor having the collection URIs to be in one parameter but certainly am open to discuss the motivation behind the current implementation.

@line-o line-o added the enhancement new features, suggestions, etc. label Feb 11, 2022
@adamretter
Copy link
Member

adamretter commented Sep 16, 2023

I agree this is a worthy addition to be added to the core in Java. In the past almost all projects that I undertook required me to write a function in XQuery like: dbu:create-collection($collection-uri).

I think the best solution would be to add an xmldb:create-collection#1 function to XMLDBModule.java and add its implementation to XMLDBCreateCollection.java, e.g.:

xmldb:create-collection($collection-uri as xs:string) as xs:string?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement new features, suggestions, etc.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants