Package net.sf.saxon
Class Query
java.lang.Object
net.sf.saxon.Query
- Direct Known Subclasses:
JDOMQuery
This Query class provides a command-line interface to the Saxon XQuery processor.
The XQuery syntax supported conforms to the W3C XQuery 1.0 drafts.
- Author:
- Michael H. Kay
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected boolean
protected Configuration
protected boolean
protected String
protected DecimalValue
protected String
protected String
protected Properties
protected boolean
protected boolean
protected String
protected int
protected boolean
protected String
protected boolean
protected String
protected boolean
protected boolean
protected boolean
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected void
applyLocalOptions
(CommandLineOptions options, Configuration config) Customisation hook: apply options defined locally in a subclassprotected void
Report incorrect usage of the command line, with a list of the options and arguments that are availableprotected XQueryExpression
compileQuery
(StaticQueryContext staticEnv, String queryFileName, boolean useURLs) Compile the queryprotected void
Support method for main program.protected void
explain
(XQueryExpression exp) Explain the results of query compilationprotected Configuration
Get the configuration in usestatic void
Main program, can be used directly from the command line.protected void
parseOptions
(CommandLineOptions options, String command, DynamicQueryContext dynamicEnv) Parse the options supplied on the command lineprotected void
processSource
(Source sourceInput, XQueryExpression exp, DynamicQueryContext dynamicEnv) Process the supplied source fileprotected Source
processSourceFile
(String sourceFileName, boolean useURLs) protected static void
Exit with a messageprotected void
runQuery
(XQueryExpression exp, DynamicQueryContext dynamicEnv, OutputStream destination, Properties outputProps) Run the queryvoid
setPermittedOptions
(CommandLineOptions options) Set the options that are recognized on the command line.
-
Field Details
-
config
-
outputProperties
-
showTime
protected boolean showTime -
repeat
protected int repeat -
sourceFileName
-
queryFileName
-
useURLs
protected boolean useURLs -
outputFileName
-
moduleURIResolverClass
-
uriResolverClass
-
explain
protected boolean explain -
wrap
protected boolean wrap -
pullMode
protected boolean pullMode -
projection
protected boolean projection -
languageVersion
-
updating
protected boolean updating -
writeback
protected boolean writeback -
backup
protected boolean backup -
explainOutputFileName
-
-
Constructor Details
-
Query
public Query()
-
-
Method Details
-
getConfiguration
Get the configuration in use- Returns:
- the configuration
-
main
Main program, can be used directly from the command line.The format is:
java net.sf.saxon.Query [options] query-file >output-file
followed by any number of parameters in the form {keyword=value}... which can be referenced from within the query.
This program executes the query in query-file.
- Parameters:
args
- List of arguments supplied on operating system command line- Throws:
Exception
- Indicates that a compile-time or run-time error occurred
-
setPermittedOptions
Set the options that are recognized on the command line. This method can be overridden in a subclass to define additional command line options.- Parameters:
options
- the CommandLineOptions in which the recognized options are to be registered.
-
doQuery
Support method for main program. This support method can also be invoked from subclasses that support the same command line interface- Parameters:
args
- the command-line argumentscommand
- name of the class, to be used in error messages
-
parseOptions
protected void parseOptions(CommandLineOptions options, String command, DynamicQueryContext dynamicEnv) throws TransformerException Parse the options supplied on the command line- Parameters:
options
- the command line argumentscommand
- the name of the command that was used (for diagnostics only)dynamicEnv
- the XQuery dynamic context- Throws:
TransformerException
- if failures occur. Note, the method may also invoke System.exit().
-
applyLocalOptions
Customisation hook: apply options defined locally in a subclass- Parameters:
options
- the CommandLineOptionsconfig
- the Saxon Configuration
-
processSourceFile
protected Source processSourceFile(String sourceFileName, boolean useURLs) throws TransformerException - Throws:
TransformerException
-
compileQuery
protected XQueryExpression compileQuery(StaticQueryContext staticEnv, String queryFileName, boolean useURLs) throws XPathException, IOException Compile the query- Parameters:
staticEnv
- the static query contextqueryFileName
- the filename holding the query (or "-" for the standard input)useURLs
- true if the filename is in the form of a URI- Returns:
- the compiled query
- Throws:
XPathException
- if query compilation failsIOException
- if the query cannot be read
-
explain
Explain the results of query compilation- Parameters:
exp
- the compiled expression- Throws:
FileNotFoundException
- if the destination for the explanation doesn't existXPathException
- if other failures occur
-
processSource
protected void processSource(Source sourceInput, XQueryExpression exp, DynamicQueryContext dynamicEnv) throws XPathException Process the supplied source file- Parameters:
sourceInput
- the supplied sourceexp
- the compiled XQuery expressiondynamicEnv
- the dynamic query context- Throws:
XPathException
- if processing fails
-
runQuery
protected void runQuery(XQueryExpression exp, DynamicQueryContext dynamicEnv, OutputStream destination, Properties outputProps) throws XPathException, IOException Run the query- Parameters:
exp
- the compiled query expressiondynamicEnv
- the dynamic query contextdestination
- the destination for serialized resultsoutputProps
- serialization properties defining the output format- Throws:
XPathException
- if the query failsIOException
- if input or output fails
-
quit
Exit with a message- Parameters:
message
- The message to be outputcode
- The result code to be returned to the operating system shell
-
badUsage
Report incorrect usage of the command line, with a list of the options and arguments that are available- Parameters:
message
- The error message
-