Editor Variables in XSLTOperation

Oxygen general issues.
dmanineelu
Posts: 6
Joined: Fri May 23, 2014 6:18 pm

Editor Variables in XSLTOperation

Post 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
alex_jitianu
Posts: 1008
Joined: Wed Nov 16, 2005 11:11 am

Re: Editor Variables in XSLTOperation

Post 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
dmanineelu
Posts: 6
Joined: Fri May 23, 2014 6:18 pm

Re: Editor Variables in XSLTOperation

Post 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
alex_jitianu
Posts: 1008
Joined: Wed Nov 16, 2005 11:11 am

Re: Editor Variables in XSLTOperation

Post 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
stdu
Posts: 81
Joined: Mon Mar 05, 2012 5:23 pm

Re: Editor Variables in XSLTOperation

Post 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
alex_jitianu
Posts: 1008
Joined: Wed Nov 16, 2005 11:11 am

Re: Editor Variables in XSLTOperation

Post 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
stdu
Posts: 81
Joined: Mon Mar 05, 2012 5:23 pm

Re: Editor Variables in XSLTOperation

Post by stdu »

Thx for this useful hint!

Kind regards,
Stefan
Post Reply