xsl script have been developped, so I would like to call xsl scripts developed inside ExtendScript in order the users don't need to save .FM as .xml, then, run xslt script to transfter the other .xml format. Is it possible?
I suspect that Jang Graat will respond, but here is a link to one of his blog posts to get you started:
If I have time later, I will post some example code. I use this feature extensively in my ExtendScript scripts to run XSLT stylesheets. FrameMaker has the Saxon Enterprise Edition built in and you can do a lot with it from your scripts.
Thanks for your quick reply.
I will be really appreciate if you have time to post some example code in order for me to understand better and hand on it quickly. Thanks again.
By the way, I have read that artical before and also followed steps to call CallClient() but nothting is happened .. so, I would like to have same example code to study how to make it work. One more question, should we change the setting of FrameMaker in the meanwhile? Thanks a lot.
Copy link to clipboard
Here is a general purpose function that you can use to invoke an XSLT transform:
Thanks a lot for your general purpose code! now I got the "result = -1" which is better than before, returns something;-).
The command used is shown below (without params (Optional)),
Is the command wrong? by the way, what should be set for "sparam"? Is it possible to explain a little bit about this with the example? Thanks.
You want to put all of your XSLTRunTrScenario into a string variable (without the angled brackets in your example) and then pass it to this call:
// Invoke the transform. result = CallClient ("FmXSLT", cmd);
where cmd is your string variable.
"cmd" posted before is copied from data structure and I added < > that to show the command line, excuse me for the confustion.
Here is my whole code for this operation:
var transform = new Object();
transform.xml = "C:\temp\chapters_structured.xml";
transform.xsl = "C:\temp\test.xsl";
transform.pro = "SAXON"
transform.out = "C:\temp\chapters_structured_after.xml"
transform.console = true;
cmd = 'XSLTRunTrScenario ' +
'-file \"' + transform.xml + '\" ' +
'-xslfilepath \"' + transform.xsl + '\" ' +
'-processor \"' + transform.pro + '\" ' +
'-outputfilepath \"' + transform.out + '\"';
result = CallClient ("FmXSLT", cmd);
alert("CallClient result:" + result);
Everything looks correct. A couple of things to check: Are you getting any messages to the Console window? Also, I would put this in my code:
so you can check your command line string for correctness; for example, matching quotes, etc. Add this to your code and post the Console message here. Thanks.
It works now 🙂 The root cause is that I made a mistake which the output file wasn't created before calling CallClient() ... thanks a lot again for your advices and quick responses 🙂
sparam is an optional set of name/value pairs for passing parameters to your stylesheet.
By the way, result still returns "-1" even when "Transformation Successful" is printed in Console window. Any idea? Thanks a lot.
FrameMaker API clients can have an integer return value and 0 is typically returned for success. Apparently, not all API clients are programmed this way, so I generally ignore the return value. As far as I know, there is no public documentation for the FmXSLT client, although I have requested documentation from Adobe. Here is a screenshot from the FDK Reference that may be helpful: