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

Please add process:execute #602

Open
rrthomas opened this issue Jul 15, 2023 · 4 comments
Open

Please add process:execute #602

rrthomas opened this issue Jul 15, 2023 · 4 comments

Comments

@rrthomas
Copy link
Contributor

process:execute($command as xs:string, $options as node()) as item()*

as per https://en.wikibooks.org/wiki/XQuery/Execute_External_Process

This is not a standard function, of course, but this seems to be the commonest version of the function implemented in other systems.

@DrRataplan
Copy link
Collaborator

Hey Reuben,

Did you consider using an external function for this? Something like this should work:

registerCustomXPathFunction({namespaceURI: 'http://exist-db.org/xquery/process', localName: 'execute'}, ['xs:string', 'node()'], 'item()*', (_dynContext, command, options) => {
  // Do you magic here, something with child_process.execSync? https://nodejs.org/api/child_process.html#child_processexecsynccommand-options.
});

This way the NodeJS dependency also stays were it should be. FontoXPath is also running in the browser, where I don;t have access to shell commands.

Kind regards,

Martin

@rrthomas
Copy link
Contributor Author

Thanks, I'll try this. It would still be nice to have an implementation on platforms where it makes sense; I think this is not the only feature that doesn't make sense in the browser but does in other environments.

@DrRataplan
Copy link
Collaborator

Hey Reuben,

What kind of functions would those be? I'm not opposed to setting up an extension module to FontoXPath or something with those kinds of functions, to make FontoXPath easier to use in different environments. I'm now mainly working with the browser, but I guess some standard functions to access external information or maybe some of the [EXPath](expath.org] functions?

@rrthomas
Copy link
Contributor Author

rrthomas commented Sep 7, 2023

Yes, your examples are exactly what I'm thinking of: accessing the file system, running processes, the sort of thing one wants to do in a server, command-line environment. The motivating case for my templating system Ruth, as linked above, is to be able to run arbitrary external commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants