public class Transform
extends java.lang.Object
It is possible to subclass this class to provide a customized command line interface. In writing such a subclass:
main(java.lang.String[])
method should instantiate the class and call the doTransform(java.lang.String[], java.lang.String)
method, passing the
argument list. The argument list can be augmented or modified if required: for example, by adding a -config
argument to cause the configuration to be initialized from a configuration file.setFactoryConfiguration(boolean, java.lang.String)
method can be implementedModifier and Type | Field and Description |
---|---|
protected boolean |
allowExit |
protected XsltCompiler |
compiler |
protected Processor |
processor |
protected int |
repeat |
protected boolean |
run |
protected boolean |
schemaAware |
protected boolean |
showTime |
protected java.lang.String |
sourceParserName |
protected boolean |
useURLs |
Constructor and Description |
---|
Transform() |
Modifier and Type | Method and Description |
---|---|
protected void |
applyLocalOptions(CommandLineOptions options,
Configuration config)
Customisation hook: apply options defined locally in a subclass.
|
protected void |
badUsage(java.lang.String message)
Report incorrect usage of the command line, with a list of the options and arguments that are available
|
void |
doTransform(java.lang.String[] args,
java.lang.String command)
Support method for main program.
|
protected Configuration |
getConfiguration()
Get the configuration.
|
protected void |
initializeConfiguration(Configuration config)
Customisation hook called immediately after the Configuration
object is instantiated.
|
static void |
main(java.lang.String[] args)
Main program, can be used directly from the command line.
|
protected Xslt30Transformer |
newTransformer(XsltExecutable sheet,
CommandLineOptions options,
Logger traceDestination)
Create a new Transformer.
|
protected static long |
now()
Get current time in nanoseconds
|
java.util.List<javax.xml.transform.Source> |
preprocess(java.util.List<javax.xml.transform.Source> sources)
Preprocess the list of sources.
|
protected void |
processFile(javax.xml.transform.Source source,
XsltExecutable sheet,
java.io.File outputFile,
CommandLineOptions options,
Logger traceDestination)
Process a single file using a supplied stylesheet
|
protected void |
quit(java.lang.String message,
int code)
Exit with a message
|
void |
setFactoryConfiguration(boolean schemaAware,
java.lang.String className)
Customisation hook called immediately after the Configuration
object is instantiated.
|
void |
setPermittedOptions(CommandLineOptions options)
Set the options that are recognized on the command line.
|
protected Processor processor
protected XsltCompiler compiler
protected boolean useURLs
protected boolean showTime
protected int repeat
protected java.lang.String sourceParserName
protected boolean schemaAware
protected boolean allowExit
protected boolean run
public static void main(java.lang.String[] args) throws java.lang.Exception
The format is:
java net.sf.saxon.Transform [options] source-file style-file >output-file
followed by any number of parameters in the form {keyword=value}... which can be referenced from within the stylesheet.
This program applies the XSL style sheet in style-file to the source XML document in source-file.
args
- List of arguments supplied on operating system command linejava.lang.Exception
- Indicates that a compile-time or
run-time error occurredpublic void setPermittedOptions(CommandLineOptions options)
options
- the CommandLineOptions in which the recognized options are to be registered.public void doTransform(java.lang.String[] args, java.lang.String command)
args
- the command-line argumentscommand
- the form of the command as written by the user. Not used, retained for backwards compatibilityprotected void initializeConfiguration(Configuration config)
config
- the Configuration objectpublic void setFactoryConfiguration(boolean schemaAware, java.lang.String className) throws LicenseException
initializeConfiguration(net.sf.saxon.Configuration)
in preference. This method is called after initializeConfiguration(net.sf.saxon.Configuration)
,
but only if the configuration was not created using a configuration file.
The default implementation does nothing.schemaAware
- True if the transformation is to be schema-awareclassName
- Always null.LicenseException
- can be thrown if there is no valid license availableprotected void applyLocalOptions(CommandLineOptions options, Configuration config)
setPermittedOptions(net.sf.saxon.trans.CommandLineOptions)
must be overridden in the subclass to add details of
options recognized in the subclass.options
- the CommandLineOptions. This will contain details of all the options
that were specified on the command line. Those that are recognized by the standard Saxon
command line interface will already have been processed; other options can now be processed
by the subclass.config
- the Saxon Configurationpublic java.util.List<javax.xml.transform.Source> preprocess(java.util.List<javax.xml.transform.Source> sources) throws XPathException
sources
- the list of Source objectsXPathException
- if a Source object is not recognizedprotected Configuration getConfiguration()
protected void quit(java.lang.String message, int code)
message
- The message to be outputcode
- The result code to be returned to the operating
system shellprotected Xslt30Transformer newTransformer(XsltExecutable sheet, CommandLineOptions options, Logger traceDestination) throws SaxonApiException
sheet
- The XsltExecutable object representing the compiled stylesheetoptions
- The commmand line optionstraceDestination
- destination for trace outputSaxonApiException
- if any error occursprotected static long now()
protected void processFile(javax.xml.transform.Source source, XsltExecutable sheet, java.io.File outputFile, CommandLineOptions options, Logger traceDestination) throws SaxonApiException
source
- The source XML document to be transformed (maybe null if an initial template
is specified)sheet
- The Templates object identifying the stylesheetoutputFile
- The output file to contain the results of the
transformationoptions
- The command line optionstraceDestination
- Destination for output from fn:trace() functionSaxonApiException
- If the transformation failsprotected void badUsage(java.lang.String message)
message
- The error messageCopyright (c) 2004-2018 Saxonica Limited. All rights reserved.