- From: Ari Nordström <Ari.Nordstrom@condesign.se>
- Date: Thu, 16 May 2013 14:27:57 +0200
- To: <ichiro.furusato@gmail.com>,<xproc-dev@w3.org>
- Message-Id: <5194ECED02000073000165C8@grpw.condesign.se>
Hi, Thanks for your help. Best regards, /Ari >>> Ichiro Furusato 05/16/13 11:00 AM >>> Ack. @#$%*&! Gmail. It sent if off before I was done editing. The only thing that actually needs changing is that the line preceding the declaration file should read: ---------------------- declare-option-dialog.xpl --------------------- and not the Java class. Sorry for any confusion. Ichiro On Thu, May 16, 2013 at 8:56 PM, Ichiro Furusato <ichiro.furusato@gmail.com> wrote: Hi Ari, I've had a number of occasions to develop what are essentially pass-through steps, i.e., steps that do something related to the pipeline but don't alter the actual content flowing through. Below is a very quick shell of a step that displays a JOptionPane that displays a dialog upon encountering the step. This could obviously be improved by adding passed arguments, actually altering processing based upon the chosen option, etc., but I leave that as an exercise to the implementer since I don't know what you'd plan to do with it. Hopefully it's helpful. Here's the declaration: ---------------------- OptionDialogStep.java --------------------- http://acme.com/xproc/1.0/" xmlns:p="http://www.w3.org/ns/xproc"> This must be imported into an existing pipeline using: and then used as a step, e.g., This is a step used to display an option dialog. And here's the Java code (which I release without license restriction): ---------------------- OptionDialogStep.java --------------------- package com.acme.transform; import net.sf.saxon.s9api.SaxonApiException; import net.sf.saxon.s9api.XdmNode; import com.xmlcalabash.core.XProcRuntime; import com.xmlcalabash.io.ReadablePipe; import com.xmlcalabash.io.WritablePipe; import com.xmlcalabash.library.DefaultStep; import com.xmlcalabash.runtime.XAtomicStep; import javax.swing.JOptionPane; /** * An XProc step that displays a dialog box. * * @author Ichiro Furusato */ public class OptionDialogStep extends DefaultStep { private ReadablePipe source = null; // the source of this step private WritablePipe result = null; // the result of this step public OptionDialogStep( XProcRuntime runtime, XAtomicStep step ) { super(runtime, step); } @Override public final void setInput( String port, ReadablePipe pipe ) { source = pipe; } @Override public final void setOutput( String port, WritablePipe pipe ) { result = pipe; } @Override public void reset() { if ( source != null ) { source.resetReader(); } if ( result != null ) { result.resetWriter(); } } @Override public void run() throws SaxonApiException { try { Object message = "Dialog message here."; String title = "Dialog Title"; int option = JOptionPane.showConfirmDialog(null, message, title, JOptionPane.YES_NO_CANCEL_OPTION); switch ( option ) { case JOptionPane.YES_OPTION: System.out.println("option: YES_OPTION"); break; case JOptionPane.NO_OPTION: System.out.println("option: NO_OPTION"); break; case JOptionPane.CANCEL_OPTION: System.out.println("option: CANCEL_OPTION"); break; default: System.out.println("option: default"); break; } super.run(); // get Saxon document from pipeline XdmNode doc = source.read(); if ( doc == null ) { throw new IllegalStateException("null document."); } // pass through pipeline result.write(doc); } catch ( Exception e ) { throw new SaxonApiException(e.getClass().getName() + " thrown by OptionDialogStep: " + e.getLocalizedMessage(), e); } } } // end OptionDialogStep This message is for the designated recipient only and may contain privileged, proprietary, or otherwise private information. If you have received it in error, please notify the sender immediately and delete the original. Any other use of the email by you is prohibited. Condesign AB, 556255-8313, säte Göteborg; Condesign Automation AB, 556271-3676, säte Göteborg; Condesign Engineering AB, 556469-2092 säte Göteborg; Condesign Infocom AB, 556453-7172, säte Ljungby; Condesign InfoProductions AB, 556385-4255, säte Linköping; Condesign Operations Support AB, 556307-1231, säte Göteborg.
Received on Thursday, 16 May 2013 12:29:10 UTC