[oXygen-user] Opening dialog boxes from xslt - It works!
Wed May 20 04:07:09 CDT 2015
Hi,
I lately implemented custom saxon instructions that allow to create a
message boxes or option dialogs from within an XSLT script.
Since it turned out to be pretty easy to implement and very useful within
my framework, I just wanted to share this idea - and the joy over oxygen,
that even this is possible.
One use-cases would be a transformation that potentially overwrites an
existing file and asks the user before doing so (if the file already
exists). The code looks like this:
<xsl:if test="java:fileExists($myFile)">
<xsl:variable name="userDecision" as="xs:integer">
<gui:option-dialog title="Warning" options=
"('Continue', 'Abort')" default="1">
<xsl:text/>The file '<xsl:value-of select=
"$myFile"/>' already exists and will be overwritten.<xsl:text/>
</gui:option-dialog>
</xsl:variable>
<xsl:if test="$userDecision = 1">
<xsl:message terminate="yes">Abort on user request
</xsl:message>
</xsl:if>
</xsl:if>
To implement such extension instructions you will have to implement your
own java library and put it into oxygens lib folder.
To do so follow the saxon documentation at
http://www.saxonica.com/documentation/#!extensibility/instructions
and - much more important - look at the sample of Saxon-SQL, which is
included in the open source edition of saxon:
http://sourceforge.net/projects/saxon/files/Saxon-HE/)
Make sure to use the same version as included into oxygen!
To open the actual dialog you can use something like
JOptionPane.showOptionDialog(
(Frame)PluginWorkspaceProvider.getPluginWorkspace
().getParentFrame(),
textString,
titleString,
(optionList.size() == 2) ? JOptionPane.YES_NO_OPTION :
JOptionPane.YES_NO_CANCEL_OPTION,
JOptionPane.PLAIN_MESSAGE,
null,
optionList.toArray(new String[optionList.size()]),
defaultOption);
(If someone should be interested - I will also gladly share my java code.)
There is also an entry in the forum for this:
http://www.oxygenxml.com/forum/topic11531.html
Regards,
Patrik
GDV Dienstleistungs-GmbH & Co. KG
Glockengießerwall 1
D-20095 Hamburg
www.gdv-dl.de
Sitz und Registergericht: Hamburg
HRA 93 894
USt.-IdNr : DE 205183123
Komplementärin:
GDV Beteiligungsgesellschaft mbH
Sitz und Registergericht: Hamburg
HRB 71 153
Geschäftsführer:
Dr. Jens Bartenwerfer
Michael Bathke
Heiko Beermann
Volker Sonnenburg
------------------------------------------------------------------
Diese E-Mail und alle Anhänge enthalten vertrauliche und/oder rechtlich geschützte Informationen. Wenn Sie nicht der richtige Adressat sind oder diese E-Mail irrtümlich erhalten haben, informieren Sie bitte sofort den Absender und vernichten Sie diese E-Mail. Das unerlaubte Kopieren sowie die unbefugte Weitergabe der E-Mail ist nicht gestattet.
This e-mail and any attached files may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error) please notify the sender immediately and destroy this e-mail. Any unauthorised copying, disclosure or distributionof the material in this e-mail is strictly forbidden.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.oxygenxml.com/pipermail/oxygen-user/attachments/20150520/b9cd9cc7/attachment.html>
More information about the oXygen-user
mailing list