public class Query
extends java.lang.Object
The XQuery syntax supported conforms to the W3C XQuery 1.0 drafts.
Modifier and Type | Field and Description |
---|---|
protected boolean |
backup |
protected Configuration |
config |
protected boolean |
explain |
protected java.lang.String |
explainOutputFileName |
protected java.lang.String |
moduleURIResolverClass |
protected java.lang.String |
outputFileName |
protected Processor |
processor |
protected boolean |
projection |
protected boolean |
pullMode |
protected java.lang.String |
queryFileName |
protected int |
repeat |
protected boolean |
showTime |
protected java.lang.String |
sourceFileName |
protected boolean |
streaming |
protected boolean |
updating |
protected java.lang.String |
uriResolverClass |
protected boolean |
useURLs |
protected boolean |
wrap |
protected boolean |
writeback |
Constructor and Description |
---|
Query() |
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
|
protected XQueryExecutable |
compileQuery(XQueryCompiler compiler,
java.lang.String queryFileName,
boolean useURLs)
Compile the query
|
protected void |
doQuery(java.lang.String[] args,
java.lang.String command)
Support method for main program.
|
protected void |
explain(XQueryExpression exp)
Explain the results of query compilation
|
protected Configuration |
getConfiguration()
Get the configuration in use
|
static void |
main(java.lang.String[] args)
Main program, can be used directly from the command line.
|
protected void |
parseOptions(CommandLineOptions options)
Parse the options supplied on the command line
|
protected void |
processSource(javax.xml.transform.Source sourceInput,
XQueryExecutable exp,
XQueryEvaluator evaluator)
Process the supplied source file
|
protected javax.xml.transform.Source |
processSourceFile(java.lang.String sourceFileName,
boolean useURLs) |
protected void |
quit(java.lang.String message,
int code)
Exit with a message
|
static void |
rewriteToDisk(NodeInfo doc,
Serializer serializer,
boolean backup,
java.io.PrintStream log)
Write an updated document back to disk, using the original URI from which it was read
|
protected void |
runQuery(XQueryExecutable exp,
XQueryEvaluator evaluator,
javax.xml.transform.Source input,
Destination destination)
Run the query
|
protected void |
runUpdate(XQueryExecutable exp,
XQueryEvaluator evaluator,
Serializer serializer)
Run an updating query
|
void |
setPermittedOptions(CommandLineOptions options)
Set the options that are recognized on the command line.
|
protected Processor processor
protected Configuration config
protected boolean showTime
protected int repeat
protected java.lang.String sourceFileName
protected java.lang.String queryFileName
protected boolean useURLs
protected java.lang.String outputFileName
protected java.lang.String moduleURIResolverClass
protected java.lang.String uriResolverClass
protected boolean explain
protected boolean wrap
protected boolean pullMode
protected boolean projection
protected boolean streaming
protected boolean updating
protected boolean writeback
protected boolean backup
protected java.lang.String explainOutputFileName
protected Configuration getConfiguration()
public static void main(java.lang.String[] args) throws java.lang.Exception
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.
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.protected void doQuery(java.lang.String[] args, java.lang.String command)
args
- the command-line argumentscommand
- name of the class, to be used in error messagesprotected void parseOptions(CommandLineOptions options) throws javax.xml.transform.TransformerException
options
- the command line argumentsjavax.xml.transform.TransformerException
- if failures occur. Note, the method may also invoke System.exit().protected void applyLocalOptions(CommandLineOptions options, Configuration config)
options
- the CommandLineOptionsconfig
- the Saxon Configurationprotected javax.xml.transform.Source processSourceFile(java.lang.String sourceFileName, boolean useURLs) throws javax.xml.transform.TransformerException
javax.xml.transform.TransformerException
protected XQueryExecutable compileQuery(XQueryCompiler compiler, java.lang.String queryFileName, boolean useURLs) throws SaxonApiException, java.io.IOException
compiler
- the XQuery compilerqueryFileName
- the filename holding the query (or "-" for the standard input)useURLs
- true if the filename is in the form of a URIXPathException
- if query compilation failsjava.io.IOException
- if the query cannot be readSaxonApiException
protected void explain(XQueryExpression exp) throws java.io.FileNotFoundException, XPathException
exp
- the compiled expressionjava.io.FileNotFoundException
- if the destination for the explanation doesn't existXPathException
- if other failures occurprotected void processSource(javax.xml.transform.Source sourceInput, XQueryExecutable exp, XQueryEvaluator evaluator) throws SaxonApiException
sourceInput
- the supplied sourceexp
- the compiled XQuery expressionevaluator
- the dynamic query contextXPathException
- if processing failsSaxonApiException
protected void runQuery(XQueryExecutable exp, XQueryEvaluator evaluator, javax.xml.transform.Source input, Destination destination) throws SaxonApiException
exp
- the compiled query expressionevaluator
- the dynamic query contextdestination
- the destination for serialized resultsSaxonApiException
- if the query failsprotected void runUpdate(XQueryExecutable exp, XQueryEvaluator evaluator, Serializer serializer) throws SaxonApiException
exp
- the compiled query expressionevaluator
- the query evaluatorserializer
- the destination for serialized resultsSaxonApiException
- if the query failspublic static void rewriteToDisk(NodeInfo doc, Serializer serializer, boolean backup, java.io.PrintStream log) throws SaxonApiException
doc
- an updated document. Must be a document node, or a parentless element, or an
element that has a document node as its parent. The document will be written to the URI
found in the systemId property of this node.serializer
- serialization propertiesbackup
- true if the old document at that location is to be copied to a backup filelog
- destination for progress messages; if null, no progress messages are writtenSaxonApiException
- if the document has no known URI, if the URI is not a writable location,
or if a serialization error occurs.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 void badUsage(java.lang.String message)
message
- The error messageCopyright (c) 2004-2018 Saxonica Limited. All rights reserved.