Page 1 of 1

Editor Variables in XSLTOperation

Posted: Wed Jun 18, 2014 6:05 pm
by dmanineelu
Hello,

How can I use Editor Variables in XSLTOperation ? Something like following

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" exclude-result-prefixes="xs">
<xsl:import href="xsl/comand.xslt"/>
<xsl:variable name="command" select="'insert.inlinetopic'"/>
<xsl:variable name="param1" select="${ask('Message', generic, 'default_value')}"/>
</xsl:stylesheet>
Thank you

Re: Editor Variables in XSLTOperation

Posted: Thu Jun 19, 2014 4:24 pm
by alex_jitianu
Hello,

Unfortunately the XSLTOperation doesn't currently expand editor variables but I'll add an improvement request for it. Until then, I suggest creating your own custom XSLTOperation. Instructions on how to create a custom operation are found inside topic How to Add a Custom Operation to an Existing Document Type. Once you get the oXygen SDK as described in the topic, inside it you will find the source code for XSLTOperation. You can copy all of it in you own operation. All that you have to change (in theory) is to pass the script (which is the XSLT) through the following call (so that the variables are expanded):

Code: Select all


ro.sync.util.editorvars.EditorVariables.expandEditorVariables(String, String)
Best regards,
Alex

Re: Editor Variables in XSLTOperation

Posted: Fri Jun 20, 2014 4:11 pm
by dmanineelu
Hallo Alex,

Thank you but expandEditorVariables is not working for ${ask}. I tried in following both ways

Code: Select all

ro.sync.util.editorvars.EditorVariables.expandEditorVariables(sbefore,authorAccess.getEditorAccess().getEditorLocation().toURI().toString());

and

authorAccess.getUtilAccess().expandEditorVariables(sbefore, authorAccess.getEditorAccess().getEditorLocation());
In both cases ${ask} Editor variable did not work but some other variables like ${oxygenHome} are working.

Thank you

Re: Editor Variables in XSLTOperation

Posted: Fri Jun 20, 2014 4:36 pm
by alex_jitianu
Hi,

I was convinced that EditorVariables.expandEditorVariables() handles the $ask variable too. It seems I was wrong and that code it's not available from the API. Sorry about that! Nevertheless, you can give up the $ask variable and instead present a dialog to the user using a JOptionPane.showInputDialog call. Afterwards you can put that value inside the XSLT.

Best regards,
Alex

Re: Editor Variables in XSLTOperation

Posted: Fri Jan 22, 2016 7:46 pm
by stdu
Hi Alex,

just to be sure: the newer version of oXygen since June 2014 don't include an update, that enables the using of editor variables in the XSLTOperation?

Thx & kind regards,
Stefan

Re: Editor Variables in XSLTOperation

Posted: Mon Jan 25, 2016 11:04 am
by alex_jitianu
Hi Stefan,

Nothing new in this area. But if we are to talk about the ${ask} variable in particular, I would say that is better not to expand it automatically before applying the transformation. The user interaction might be needed on a particular XSLT branch so it make sense to only present the dialog then and you can do it quite quickly with a JOptionPane:

Code: Select all


<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="2.0"
xmlns:jop="java:javax.swing.JOptionPane">

<xsl:template match="p">
<p>
<xsl:value-of select="jop:showInputDialog(null, 'Get some input', '')"/>
</p>
</xsl:template>
</xsl:stylesheet>
Best regards,
Alex

Re: Editor Variables in XSLTOperation

Posted: Wed Jan 27, 2016 1:38 pm
by stdu
Thx for this useful hint!

Kind regards,
Stefan