Community Tip - Need to share some code when posting a question or reply? Make sure to use the "Insert code sample" menu option. Learn more! X
Hi Guys,
we need to pass through the opened xml-file in Arbortext Editor with ACL to another .exe-Tool.
We know the command sh to call an external tool. But how can we pass through the opened xml file to this external tool?
Anybody an idea?
Thank you in advance for your help.
Hi Hubert,
I haven't done this myself, but I have some initial thoughts.
Will the exe be performing any changes to the XML or just referencing? If it's making changes, you may encounter errors since Arbortext locks open files from other editors.
As far as passing it to the external exe, I can think of 2 ways...
1. Pass the XML and file path as a cmd line argument to the exe.
2. Copy the content of the XML file and pass as an input stream.
Hope that helps!
-Jeff
Hi Jeff,
no, we do not need to change the xml. We only want to take informations about the opened file.
We thought about simlilar methods like suggested from you.
Our try was like this:
#mark the complete file | |
StartOfDocument; | |
EndOfDocExtend; | |
#selection into a variable | |
$sel = main::selection | |
#shell command | |
sh 'C:\testtool.exe $sel' | |
Unfortunately this try was without success. If we use following sh-command with a full path of a xml like:
sh 'C:\testtool.exe C:\testfile.xml' then its ok. But we need to pass through the opened xml file. Do you maybe know if there is a command or variable where the absolut path of the opened xml-file is included?
Thank you for your help.
Have you tried the function "pwd"? This will return the current working directory.
Hi Jeff,
thank you for the "pwd" command, we will sure need this command in other situations.
Hi Hubert--
I don't think it's going to be practical to paste an entire XML document's contents as a parameter in the shell command. You would need to quote it, otherwise the shell command processor would consider each space in the XML document to delimit a new parameter. But the XML markup itself is going to be full of quotes, so it's just going to be a big mess trying to do it that way.
I think a better approach is to pass a file reference to the XML file. (This assumes that it's just an XML file in a file system, and not some kind of virtual document stored in a CMS.) To get the full absolute path to the current document, you can use the doc_path() function. So, your code would look something like this:
function process_current_doc() {
local docpath = doc_path();
local cmd = 'sh "C:\testtool.exe" "' . docpath . '"';
execute(cmd);
}
Hopefully this will get you past the obstacle.
--Clay
Hi Clay,
thank you for the doc_path() function. This function returns the absolut path of the document.
Unfortunately we have the problem, that our other tool throws an exeption, because the xml file is in process and therefore it cannot be used.
Maybe our other try will be to save the opened xml file in a temp folder and try it again.
I will inform you.
Hi Hubert
You don't want to open already opened xml using exe-Tool. Is it right ?
What about this ?
global openedXml;
function openXML() {
$selXml = main::selection;
if(index(openedXml, selXml) > 0) {
response("'" . selXml . "' is already open!!");
} else {
openedXml = openedXml . "|" . selXml;
sh 'C:\testtool.exe $selXml'
}
}
Thanks,
Kim, Joon O
Hi Joon,
with your suggestion we have also the problem, that our exe-tool throws an exception, that the xml file is in use from other process.
We will try to save this xml in a temporary folder.
Thank you for your help.