Page 1 of 1
Connect oxy_actions and transformations scenario for XSLT
Posted: Fri Jun 07, 2019 3:13 pm
by Oleksii
Hi!
I'm building a simple GUI for convenient XSLT-transformations in oXygen. The GUI is am xml file and I use form-controls to inset the parameters and oxygen actions to run the transformations. For instance, there is the following button in the CSS:
Code: Select all
button[name = "mergeStaves"]:before {
content:
oxy_button(actionID, 'mergeStaves');
}
I faced a problem that with pure XSLT you cannot overwrite the file which you read, cf.
https://stackoverflow.com/q/56472663/7315908.
But in oXygen you can do it when you use the scenario. So I thought maybe there is any possibility to use this feature for my approach?
best Oleksii
Re: Connect oxy_actions and transformations scenario for XSLT
Posted: Mon Jun 10, 2019 2:39 pm
by alex_jitianu
Hi Oleksii,
I've tried to execute such a transformation from Oxygen, with Saxon 9.8, but it didn't actually work. I got the error message:
Code: Select all
Cannot write to a URI that has already been read: file:/D:/projects/eXml/samples/dita/xslt/input.xml
But in oXygen you can do it when you use the scenario.
I'm not aware about anything specific that we might do to allow such a behavior, but if you want to try it, the fastest way would be to configure an action that uses the
ro.sync.ecss.extensions.commons.operations.ExecuteTransformationScenariosOperation to execute an already configured transformation scenario.
If, for whatever reasons, the scenario approach is not an options, you can create your own
custom operation . This operation can use the API to create a new transformer and execute it:
Code: Select all
ro.sync.ecss.extensions.api.AuthorAccess.getXMLUtilAccess()
ro.sync.exml.workspace.api.util.XMLUtilAccess.createSaxon9XSLTTransformerWithExtensions(Source, ExtensionFunctionDefinition[], int)
Best regards,
Alex
Re: Connect oxy_actions and transformations scenario for XSLT
Posted: Mon Jun 17, 2019 7:30 pm
by Oleksii
Hi Alex,
I already use the action
...ExecuteTransformationScenariosOperation
The button which fires the action is placed in another xml file which is a kind of GUI from which I want to run all the transformations. The file which should be processed is defined in a @file attribute as relative path. So when running the transformation, I try to get this value by :
Code: Select all
${xpath_eval(
doc('${currentFileURL}')//{http://www.mozarteum.at/ns/dme}div[@id = 'mergeStaves']//{http://www.mozarteum.at/ns/dme}file/@file
)}
There is obviously a problem with resolving the namespace (?) because this expression works fine:
Code: Select all
${xpath_eval(
doc('${currentFileURL}')//@file
)}
It tested first by defining a parameter and printing out a message. When I wanted to define it in the
XML URL a strange behaviour is occured: a part of the expression is replaced by '*':
Code: Select all
${xpath_eval(doc('${currentFileURL}')//{http://www.mozarteum.at/ns/dme}div[@id = 'mergeStaves']//{http:*****************************@file
Should it still work?
best regards
Oleksii
Re: Connect oxy_actions and transformations scenario for XSLT
Posted: Tue Jun 18, 2019 3:06 pm
by sorin_carbunaru
Hello Oleksii,
Could you please try the solution from
https://stackoverflow.com/a/55181151/1288460 (preceding the namespace with 'Q') and then let me know if it worked for you? We tried something quick on our side and it seemed to work
.
Best wishes,
Sorin Carbunaru
oXygen XML
P.S. - Alex is on vacation
Re: Connect oxy_actions and transformations scenario for XSLT
Posted: Mon Jun 24, 2019 7:13 pm
by Oleksii
Hi Sorin,
The adding of the
Q before the Clark notation works well!
Currently I can specify the XMLURL as relative path. by:
Code: Select all
${xpath_eval(
doc('${currentFileURL}')//Q{http://www.mozarteum.at/ns/dme}div[@id = 'mergeStaves']//@file
)}
The next problem I faced is to specify the output URL. I tried to specify the following in the Output >> Save as of the XSLT transformation dialog box:
Code: Select all
${xpath_eval(
resolve-uri(
doc('${currentFileURL}')//Q{http://www.mozarteum.at/ns/dme}div[@id = 'mergeStaves']//@file, ${currentFileURL})
)}
The error I gets is:
Cannot delete the file: C:\Users\...\xslt_oxygen\lib prior to result generation.
Also it adds the file
DIME-tools.xml_xslt
.
To make it clearer: I try to run a transformation with an oxy_button from
C:\...\repos_develop_os\trunk_branch-os\util\xslt_oxygen\lib\DIME-tools.xml
The transformed file is placed in:
C:\...\repos_develop_os\sandbox_os\MRE\dmeref_543-004_6252-3456.xml
and the XSLT stylesheet in:
C:\...\repos_develop_os\trunk_branch-os\util\xslt_oxygen\reference_texts\mergeStaves.xsl
P.S . So I wish Alex a great sunny time
Re: Connect oxy_actions and transformations scenario for XSLT
Posted: Wed Jun 26, 2019 11:04 am
by Oleksii
I solved the problem by specifying the in the Output >> Save as of the XSLT transformation dialog box :
Code: Select all
${xpath_eval(
doc('${currentFileURL}')//Q{http://www.mozarteum.at/ns/dme}div[@id = 'mergeStaves']//@file
)}
So the same as in the input.
Re: Connect oxy_actions and transformations scenario for XSLT
Posted: Thu Jun 27, 2019 11:33 am
by alex_jitianu
Hi Oleksii,
I'm glad to see that you've made progress. Please let me know if you encounter any other challenges.
Best regards,
Alex