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.
explain
protected boolean explain
explainOutputFileName
protected String explainOutputFileName
moduleURIResolverClass
protected String moduleURIResolverClass
outputFileName
protected String outputFileName
projection
protected boolean projection
pullMode
protected boolean pullMode
queryFileName
protected String queryFileName
repeat
protected int repeat
showTime
protected boolean showTime
sourceFileName
protected String sourceFileName
uriResolverClass
protected String uriResolverClass
useURLs
protected boolean useURLs
wrap
protected boolean wrap
badUsage
protected void badUsage(String name,
String message)
Report incorrect usage of the command line, with a list of the options and arguments that are available
name
- The name of the command being executed (allows subclassing)message
- The error message
compileQuery
protected XQueryExpression compileQuery(StaticQueryContext staticEnv,
String queryFileName,
boolean useURLs)
throws XPathException,
IOException
Compile the query
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
doQuery
protected void doQuery(args[] ,
String command)
Support method for main program. This support method can also be invoked from subclasses
that support the same command line interface
command
- name of the class, to be used in error messages
explain
protected void explain(XQueryExpression exp)
throws FileNotFoundException,
XPathException
Explain the results of query compilation
exp
- the compiled expression
getConfiguration
protected Configuration getConfiguration()
Get the configuration in use
main
public static void main(args[] )
throws Exception
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.
makeConfiguration
protected Configuration makeConfiguration(boolean schemaAware,
String className)
Set the configuration. This is designed to be
overridden in a subclass
schemaAware
- true if a schema-aware configuration is required (in this case Saxon-SA must
be installed and licensed)className
- the name of the class to be loaded, representing the Configuration. This
allows additional control of the loading process under .NET
- the successfully loaded Configuration
parseOptions
protected void parseOptions(String[] args,
String command,
DynamicQueryContext dynamicEnv,
Properties outputProps)
throws TransformerException
Parse the options supplied on the command line
args
- the command line argumentscommand
- the name of the command that was used (for diagnostics only)dynamicEnv
- the XQuery dynamic contextoutputProps
- the serialization properties
processSource
protected void processSource(Source sourceInput,
XQueryExpression exp,
DynamicQueryContext dynamicEnv)
throws XPathException
Process the supplied source file
sourceInput
- the supplied sourceexp
- the compiled XQuery expressiondynamicEnv
- the dynamic query context
processSourceFile
protected Source processSourceFile(String sourceFileName,
boolean useURLs)
throws TransformerException
quit
protected static void quit(String message,
int code)
Exit with a message
message
- The message to be outputcode
- The result code to be returned to the operating
system shell
runQuery
protected void runQuery(XQueryExpression exp,
DynamicQueryContext dynamicEnv,
OutputStream destination,
Properties outputProps)
throws XPathException,
IOException
Run the query
exp
- the compiled query expressiondynamicEnv
- the dynamic query contextdestination
- the destination for serialized resultsoutputProps
- serialization properties defining the output format
testIfSchemaAware
protected boolean testIfSchemaAware(String[] args)
Prescan the command line arguments to see if any of them imply use of a schema-aware processor
args
- the command line arguments
- true if a schema-aware processor is needed