I would like to know if there is a possibility to get the system path separator inside my XQuery code without special libraries?
No. There's nothing defined in the XQuery 1.0 or XQuery 3.0 specs to identify details of the filesystem.
However, using fn:doc(), you should be able to reference filesystem URIs generally by preceding the file name with file:/// and using / as a separator for directory.
As already mentioned, I don't think it is possible to achieve this by using standard XQuery functionality. However, depending on what processor you are using, it is quite likely that you can use Java bindings. I am aware that at least BaseX, eXist and Saxon support this.
By using this technique you can get the separator
declare namespace system="java:java.lang.System";
system:getProperty("file.separator")
Or if your processor supports the expanded QName notation you can also write
Q{java:java.lang.System}getProperty("file.separator")
Related
Context
I'm developing a Microsoft Visual Studio extension, for which I've seen there are:
$projectname$ variable to get the name given to the project,
$safeprojectname$ variable to get the name given to the project with all unsafe characters and spaces replaced by underscore.
Source: https://learn.microsoft.com/en-us/visualstudio/ide/template-parameters?view=vs-2019
For example with project name "Tata yoyo" variables will be:
$projectname$ = "Tata Yoyo SWIG",
$safeprojectname$ = "Tata_Yoyo_SWIG".
The extension I'm building is for SWIG projects that will generate Java from C++, and in this context there is a swig.exe call that, among others, takes the Java package as parameter, for which I want it to be all lower case, but for now it is com.company.$safeprojectname$, then, not necessarily lower case (pointing the obvious: if project name is not lower case, package will not be lower case) and I then have to convert it manually to lower case.
What I'm looking for
From source page above (and other documentation pages) I've already seen there is no $lowercasesafeprojectname$ for example, then if anybody knows a way to do it from a function, script or any other way I would be glad.
Edit: while I want for this purpose a lower case safe project name I still want to keep the original $safeprojectname$, then even if #Ed Dore answer is relevant it is not the solution for me.
In any case, do not hesitate if this is not clear or you want more information.
Thanks
If you implement a custom wizard (IWizard) with your template, you can replace the respective token values in the ReplacementsDictionary passed to your IWizard.RunStarted method, with lowercased equivalents.
Sincerely,
I have a module using regexp:sh_to_awk and regexp:match.
But when I compile it, the compiler warns me that the regexp module was removed from R15 and recommends me to use the re module instead.
I searched the erlang documentation but I can't find how to replace the two functions.
Can anyone tell me how to fix this?
Indeed, regexp module has been deprecated for a while and has now been removed, replaced by the re module.
The old regexp:match function has been replaced by the re:run functions, which add a lot of functionality, such as returning captured parts as lists or binary (The old way of returning start position and length also remains):
> re:run("Test String","[a-zA-Z]{4}",[{capture,all,list},global]).
{match,[["Test"],["Stri"]]}
Read through the re:run/3 documentation, it's worth it, just as all the other functions of the re module (like compile and replace).
The regexp:sh_to_awk has been removed. You can use the filelib:wildcard functions for matching filenames, if that was your intended use of the old regexp:sh_to_awk/1 function.
My delphi application runs scripts using JvInterpreter (from the Jedi project).
A feature I use is runtime evaluation of expressions.
Script Example:
[...]
ShowMessage(X_SomeName);
[...]
JvInterpreter doesn't know X_SomeName.
When X_SomeName's value is required the scripter calls its OnGetValue-callback.
This points to a function I handle. There I lookup X_SomeName's value and return it.
Then JvInterpreter calls ShowMessage with the value I provided.
Now I consider switching to DelphiWebScript since it has a proper debug-interface and should also be faster than JvInterpreter.
Problem: I didn't find any obvious way to implement what JvInterpreter does with its OnGetValue/OnSetValue functions, though.
X_SomeName should be considered (and actually is, most of the time) a variable which is handled by the host application.
Any Ideas?
Thanks!
You can do that through the language extension mechanism, which has a FindUnknownName method that allows to register symbols on the spot.
It is used in the asm lib module demo, and you can also check the new "AutoExternalValues" test case in ULanguageExtensionTests, which should be closer to what you're after.
I need to convert a huge number of constants from an application. Is it possible to get all the constants declared in a unit and their values, other then parsing the .pas file?
It seems that this is not possible without parsing your unit and extract the constants. During the compilation constants are replaced by value, so it is impossible to get the value from them at runtime.
LE: maybe there is someone who can explain this in depth.
There is the Open Tools API to work with the IDE in an object oriented way.
But I think it is not possible to list the constants of files.
I think the easiest way is to use grep or other similar RegEx program that can collect the string constants from files: ^\s*\w+\s*=\s*'.+?'\s*[;#\{\+]
How about changing all CONST to ResourceString, re-building, and then dump the string resources using a resource editor like XN Resource Editor?
That's how I'd approach it, if there were really THAT many of them.
i'm currently using File::Basename fileparse to separate out a file's directory, base file name and it's extension using something like this:
my($myfile_name,$mydirectory, $file_extension) = fileparse($$rhash_params{'storage_full_path_location'},'\..{1,4}');
But see that there's a variation where you can actually provide a array of suffixes to the function, the array would contains all the known file extension.
So i'm trying to find a safe way to do this as i've seen that i've got some strange file names to process, i.e. file.0f1.htm, etc.
Question:
Is there a list of commonly used
extension for Windows and Unix
systems? But in my case it's mainly
for Windows.
And is it safe to
assume that all file names in
Windows should have an extension
ending with three letter characters?
And if there's an even better way to do this, please share.
Thanks.
Updates:
So obviously i must be drunk to forgot about those other extension. :)
Thus i've updated the current regex to allow from 1-4chars.
In this case, how should i change my regex line to properly match it?
Or is it an even better idea to look for all those commonly used extension from google and put them into an array to be passed to the function instead? My users are usually either students or teachers.
1. Is there a list of commonly used extension for Windows and Unix
systems? But in my case it's mainly
for Windows.
Yes, loads, all over the internet: http://www.google.com/search?q=common+file+extensions
2. And is it safe to assume that all file names in Windows should have
an extension ending with three letter
characters?
No, it's perfectly possible to use '.c', '.java', etc in Windows.
There are several fault assumptions in your code:
files need not have extensions. For example most binary executables on Unix/Linux/... don't have an extension at all. They are simply calls "bash", "wget", "sed", "Xorg", ...
extensions need not be three characters long, as #Alnitak already told you: ".c", ".java", ".mpeg", ".jpeg", ".html" are all perfectly fine and rather wide-spread extensions
cutting at the last "." is probably saver, but can still fail for files with no extensions or with multiple (or multi-part) extensions such as ".tar.gz", "tar.bz2", which occur rather often in the Unix/Linux/...-World