You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xalan.apache.org by cu...@apache.org on 2002/01/25 20:43:35 UTC
cvs commit: xml-xalan/test/java/src/org/apache/qetest/xslwrapper XalanProcessWrapper.java
curcuru 02/01/25 11:43:35
Modified: test/java/src/org/apache/qetest/xslwrapper
XalanProcessWrapper.java
Log:
Added new option flag Processor.setAttribute.cmdline so users can
pass static arbitrary single-space-delimited additional cmdline
parameters to the underlying Process class
Revision Changes Path
1.2 +43 -5 xml-xalan/test/java/src/org/apache/qetest/xslwrapper/XalanProcessWrapper.java
Index: XalanProcessWrapper.java
===================================================================
RCS file: /home/cvs/xml-xalan/test/java/src/org/apache/qetest/xslwrapper/XalanProcessWrapper.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- XalanProcessWrapper.java 6 Dec 2001 14:57:10 -0000 1.1
+++ XalanProcessWrapper.java 25 Jan 2002 19:43:35 -0000 1.2
@@ -61,6 +61,8 @@
import java.util.Hashtable;
import java.util.Properties;
+import java.util.StringTokenizer;
+import java.util.Vector;
/**
* Implementation of TransformWrapper that calls Xalan's default
@@ -69,18 +71,24 @@
* This is similar to the common usage:
* java org.apache.xalan.xslt.Process -in foo.xml -xsl foo.xsl ...
*
- * //@todo support other command line options
+ * See OPT_PREFIX for how to pass miscellaneous cmdline args.
+ *
* //@todo support precompiled/serialized stylesheets
*
- * @author Shane Curcuru
- * @version $Id: XalanProcessWrapper.java,v 1.1 2001/12/06 14:57:10 curcuru Exp $
+ * @author Shane_Curcuru@us.ibm.com
+ * @version $Id: XalanProcessWrapper.java,v 1.2 2002/01/25 19:43:35 curcuru Exp $
*/
public class XalanProcessWrapper extends TransformWrapperHelper
{
/**
- * Array of additional or optional args for Process.main() calls.
- * //@todo not yet supported; futureuse for -validate, -edump, etc.
+ * Marker for cmdline items to add to optionArgs.
+ */
+ public static final String OPT_PREFIX = TransformWrapper.SET_PROCESSOR_ATTRIBUTES + "cmdline";
+
+
+ /**
+ * Array of additional or optional args for Process.main() calls.
*/
protected String[] optionArgs = new String[0];
@@ -136,6 +144,36 @@
public Object newProcessor(Hashtable options) throws Exception
{
newProcessorOpts = options;
+
+ // semi-HACK: set any additional cmdline options from user
+ String extraOpts = null;
+ try
+ {
+ // Attempt to use as a Properties block..
+ extraOpts = ((Properties)options).getProperty(OPT_PREFIX);
+ // But, if null, then try getting as hash anyway
+ if (null == extraOpts)
+ {
+ extraOpts = (String)options.get(OPT_PREFIX);
+ }
+ }
+ catch (ClassCastException cce)
+ {
+ // .. but fallback to get as Hashtable instead
+ extraOpts = (String)options.get(OPT_PREFIX);
+ }
+
+ if ((null != extraOpts) && (extraOpts.length() > 0))
+ {
+ Vector v = new Vector();
+ StringTokenizer st = new StringTokenizer(extraOpts, " ");
+ while (st.hasMoreTokens())
+ {
+ v.addElement(st.nextToken());
+ }
+ optionArgs = new String[v.size()];
+ v.copyInto(optionArgs);
+ }
//@todo do we need to do any other cleanup?
reset(false);
return null;
---------------------------------------------------------------------
To unsubscribe, e-mail: xalan-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xalan-cvs-help@xml.apache.org