public class Transform extends 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 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(String message)
Report incorrect usage of the command line, with a list of the options and arguments that are available
|
void |
doTransform(String[] args,
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(String[] args)
Main program, can be used directly from the command line.
|
protected XsltTransformer |
newTransformer(XsltExecutable sheet,
CommandLineOptions options,
Logger traceDestination)
Create a new Transformer.
|
protected static long |
now()
Get current time in nanoseconds
|
List<Source> |
preprocess(List<Source> sources)
Preprocess the list of sources.
|
protected void |
processFile(Source source,
XsltExecutable sheet,
File outputFile,
CommandLineOptions options,
Logger traceDestination)
Process a single file using a supplied stylesheet
|
protected void |
quit(String message,
int code)
Exit with a message
|
void |
setFactoryConfiguration(boolean schemaAware,
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 String sourceParserName
protected boolean schemaAware
protected boolean allowExit
protected boolean run
public static void main(String[] args) throws 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 lineException
- 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(String[] args, 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, 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 List<Source> preprocess(List<Source> sources) throws XPathException
sources
- the list of Source objectsXPathException
- if a Source object is not recognizedprotected Configuration getConfiguration()
protected void quit(String message, int code)
message
- The message to be outputcode
- The result code to be returned to the operating
system shellprotected XsltTransformer 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(Source source, XsltExecutable sheet, 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(String message)
message
- The error messageCopyright (c) 2004-2014 Saxonica Limited. All rights reserved.