Package net.sf.saxon.trans
Class CommandLineOptions
- java.lang.Object
-
- net.sf.saxon.trans.CommandLineOptions
-
public class CommandLineOptions extends Object
This is a helper class for classes such as net.sf.saxon.Transform and net.sf.saxon.Query that process command line options
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceCommandLineOptions.ParamSetter
-
Field Summary
Fields Modifier and Type Field Description static intTYPE_BOOLEANstatic intTYPE_CLASSNAMEstatic intTYPE_DATETIMEstatic intTYPE_ENUMERATIONstatic intTYPE_FILENAMEstatic intTYPE_FILENAME_LISTstatic intTYPE_INTEGERstatic intTYPE_INTEGER_PAIRstatic intTYPE_QNAMEstatic intTYPE_STRINGstatic intVALUE_PROHIBITEDstatic intVALUE_REQUIRED
-
Constructor Summary
Constructors Constructor Description CommandLineOptions()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddRecognizedOption(String option, int optionProperties, String helpText)Set the permitted options.voidapplyFileParams(Processor processor, Xslt30Transformer transformer)Apply XSLT 3.0 file-valued parameters to an XSLT transformer.voidapplyStaticParams(XsltCompiler compiler)Apply XSLT 3.0 static parameters to a compilerInfo.voidapplyToConfiguration(Processor processor)Apply options to the Configurationstatic StringcoerceImplicitOutputURI(String outputName)booleandefinesParameterValues()Test whether there is any keyword=value option presentStringdisplayPermittedOptions()Display the list the permitted optionsstatic StringfeatureKeys()static StringgetCommandName(Object command)static URIgetCurrentWorkingDirectory()StringgetOptionValue(String option)Get the value of a named option.List<String>getPositionalOptions()Get the options specified positionally, that is, without a leading "-"static booleanisImplicitURI(String name)static voidloadAdditionalSchemas(Configuration config, String additionalSchemas)static booleanloadDocuments(String sourceFileName, boolean useURLs, Processor processor, boolean useSAXSource, List<Source> sources)Load a document, or all the documents in a directory, given a filename or URLvoidsetActualOptions(String[] args)Set the options actually present on the command linestatic voidsetCatalogFiles(ConfigurableResourceResolver crr, List<String> catalogs)voidsetParams(Processor processor, CommandLineOptions.ParamSetter paramSetter)voidsetPermittedValues(String option, String[] values, String defaultValue)Set the permitted values for an optionvoidsetSerializationProperties(Serializer serializer)Set any output properties appearing on the command line in the form!indent=yesas properties of the suppliedSerializerbooleantestIfSchemaAware()Prescan the command line arguments to see if any of them imply use of a schema-aware processor
-
-
-
Field Detail
-
TYPE_BOOLEAN
public static final int TYPE_BOOLEAN
- See Also:
- Constant Field Values
-
TYPE_FILENAME
public static final int TYPE_FILENAME
- See Also:
- Constant Field Values
-
TYPE_CLASSNAME
public static final int TYPE_CLASSNAME
- See Also:
- Constant Field Values
-
TYPE_ENUMERATION
public static final int TYPE_ENUMERATION
- See Also:
- Constant Field Values
-
TYPE_INTEGER
public static final int TYPE_INTEGER
- See Also:
- Constant Field Values
-
TYPE_QNAME
public static final int TYPE_QNAME
- See Also:
- Constant Field Values
-
TYPE_FILENAME_LIST
public static final int TYPE_FILENAME_LIST
- See Also:
- Constant Field Values
-
TYPE_DATETIME
public static final int TYPE_DATETIME
- See Also:
- Constant Field Values
-
TYPE_STRING
public static final int TYPE_STRING
- See Also:
- Constant Field Values
-
TYPE_INTEGER_PAIR
public static final int TYPE_INTEGER_PAIR
- See Also:
- Constant Field Values
-
VALUE_REQUIRED
public static final int VALUE_REQUIRED
- See Also:
- Constant Field Values
-
VALUE_PROHIBITED
public static final int VALUE_PROHIBITED
- See Also:
- Constant Field Values
-
-
Method Detail
-
getCurrentWorkingDirectory
public static URI getCurrentWorkingDirectory()
-
addRecognizedOption
public void addRecognizedOption(String option, int optionProperties, String helpText)
Set the permitted options.- Parameters:
option- A permitted option.optionProperties- of this option, for example whether it is mandatoryhelpText- message to be output if the user needs help concerning this option
-
setPermittedValues
public void setPermittedValues(String option, String[] values, String defaultValue)
Set the permitted values for an option- Parameters:
option- the option keywordvalues- the set of permitted valuesdefaultValue- the default value if the option is supplied but no value is given. May be null if no default is defined.
-
setActualOptions
public void setActualOptions(String[] args) throws XPathException
Set the options actually present on the command line- Parameters:
args- the options supplied on the command line- Throws:
XPathException- if an unrecognized or invalid option is found
-
definesParameterValues
public boolean definesParameterValues()
Test whether there is any keyword=value option present- Returns:
- true if there are any keyword=value options
-
testIfSchemaAware
public boolean testIfSchemaAware()
Prescan the command line arguments to see if any of them imply use of a schema-aware processor- Returns:
- true if a schema-aware processor is needed
-
applyToConfiguration
public void applyToConfiguration(Processor processor) throws TransformerException
Apply options to the Configuration- Parameters:
processor- the s9api Processor object- Throws:
TransformerException- if invalid options are present
-
setCatalogFiles
public static void setCatalogFiles(ConfigurableResourceResolver crr, List<String> catalogs)
-
displayPermittedOptions
public String displayPermittedOptions()
Display the list the permitted options- Returns:
- the list of permitted options, as a string
-
getOptionValue
public String getOptionValue(String option)
Get the value of a named option. Returns null if the option was not present on the command line. Returns "" if the option was present but with no value ("-x" or "-x:").- Parameters:
option- the option keyword- Returns:
- the option value, or null if not specified.
-
getPositionalOptions
public List<String> getPositionalOptions()
Get the options specified positionally, that is, without a leading "-"- Returns:
- the list of positional options
-
setParams
public void setParams(Processor processor, CommandLineOptions.ParamSetter paramSetter) throws SaxonApiException
- Throws:
SaxonApiException
-
setSerializationProperties
public void setSerializationProperties(Serializer serializer)
Set any output properties appearing on the command line in the form!indent=yesas properties of the suppliedSerializer- Parameters:
serializer- the suppliedSerializer, whose serialization properties are to be modified.
-
applyStaticParams
public void applyStaticParams(XsltCompiler compiler) throws SaxonApiException
Apply XSLT 3.0 static parameters to a compilerInfo. Actually this sets all parameter values, whether static or dynamic. This is possible because the stylesheet is compiled for once-only use.- Parameters:
compiler- The XsltCompiler object into which the parameters are copied- Throws:
SaxonApiException- if invalid options are found
-
applyFileParams
public void applyFileParams(Processor processor, Xslt30Transformer transformer) throws SaxonApiException
Apply XSLT 3.0 file-valued parameters to an XSLT transformer. Most parameters are applied before compilation, so that the compiler can take advantage of knowing their values; but file-valued parameters (provided as +name=value) are deferred until run-time because of complications storing their values in a SEF file.- Parameters:
transformer- The Xslt30Transformer object into which the parameters are copied- Throws:
SaxonApiException- if invalid options are found
-
loadDocuments
public static boolean loadDocuments(String sourceFileName, boolean useURLs, Processor processor, boolean useSAXSource, List<Source> sources) throws SaxonApiException
Load a document, or all the documents in a directory, given a filename or URL- Parameters:
sourceFileName- the name of the source file or directoryuseURLs- true if the filename argument is to be treated as a URIprocessor- the Saxon s9api ProcessoruseSAXSource- true if the method should use a SAXSource rather than a StreamSourcesources- an empty list which the method will populate. If sourceFileName represents a single source document, a corresponding XdmNode is added to the list. If sourceFileName represents a directory, multiple XdmNode objects, one for each file in the directory, are added to the list- Returns:
- true if the supplied sourceFileName was found to be a directory
- Throws:
SaxonApiException- if access to documents fails
-
isImplicitURI
public static boolean isImplicitURI(String name)
-
loadAdditionalSchemas
public static void loadAdditionalSchemas(Configuration config, String additionalSchemas) throws SchemaException
- Throws:
SchemaException
-
featureKeys
public static String featureKeys()
-
-