Browse Source

The command-line now automatically sets two parameters for any XSLT transformation: "fop-output-format" contains the MIME type of the currently selected output format, "fop-version" contains FOP's version number.

Suggested by: Roland Neilands

git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@355411 13f79535-47bb-0310-9956-ffa450edef68
tags/fop-0_91-beta
Jeremias Maerki 18 years ago
parent
commit
5144e1c68b
2 changed files with 16 additions and 6 deletions
  1. 11
    6
      src/java/org/apache/fop/cli/CommandLineOptions.java
  2. 5
    0
      status.xml

+ 11
- 6
src/java/org/apache/fop/cli/CommandLineOptions.java View File

import org.apache.fop.Version; import org.apache.fop.Version;
import org.apache.fop.apps.FOPException; import org.apache.fop.apps.FOPException;
import org.apache.fop.apps.FOUserAgent; import org.apache.fop.apps.FOUserAgent;
import org.apache.fop.apps.Fop;
import org.apache.fop.apps.MimeConstants; import org.apache.fop.apps.MimeConstants;
import org.apache.fop.fo.Constants; import org.apache.fop.fo.Constants;
import org.apache.fop.pdf.PDFEncryptionManager; import org.apache.fop.pdf.PDFEncryptionManager;
} }
checkSettings(); checkSettings();
createUserConfig(); createUserConfig();
addXSLTParameter("fop-output-format", getOutputFormat());
addXSLTParameter("fop-version", Version.getVersion());
} }
} catch (FOPException e) { } catch (FOPException e) {
printUsage(); printUsage();
return log; return log;
} }


private void addXSLTParameter(String name, String value) {
if (xsltParams == null) {
xsltParams = new Vector();
}
xsltParams.addElement(name);
xsltParams.addElement(value);
}
/** /**
* parses the commandline arguments * parses the commandline arguments
* @return true if parse was successful and processing can continue, false * @return true if parse was successful and processing can continue, false
System.out.println("FOP Version " + Version.getVersion()); System.out.println("FOP Version " + Version.getVersion());
} else if (args[i].equals("-param")) { } else if (args[i].equals("-param")) {
if (i + 2 < args.length) { if (i + 2 < args.length) {
if (xsltParams == null) {
xsltParams = new Vector();
}
String name = args[++i]; String name = args[++i];
xsltParams.addElement(name);
String expression = args[++i]; String expression = args[++i];
xsltParams.addElement(expression);
addXSLTParameter(name, expression);
} else { } else {
throw new FOPException("invalid param usage: use -param <name> <value>"); throw new FOPException("invalid param usage: use -param <name> <value>");
} }

+ 5
- 0
status.xml View File



<changes> <changes>
<release version="FOP Trunk"> <release version="FOP Trunk">
<action context="Code" dev="JM" type="add">
The command-line now automatically sets two parameters for any XSLT transformation:
"fop-output-format" contains the MIME type of the currently selected output format,
"fop-version" contains FOP's version number.
</action>
<action context="Code" dev="JM" type="fix"> <action context="Code" dev="JM" type="fix">
The output file is now deleted when an exception occurs when calling FOP from The output file is now deleted when an exception occurs when calling FOP from
the command-line. the command-line.

Loading…
Cancel
Save