Package net.sf.saxon

Class Query

  • Direct Known Subclasses:
    JDOM2Query

    public class Query
    extends Object
    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.

    • Field Detail

      • showTime

        protected boolean showTime
      • repeat

        protected int repeat
      • sourceXmlFileName

        protected String sourceXmlFileName
      • sourceJsonFileName

        protected String sourceJsonFileName
      • queryFileName

        protected String queryFileName
      • useURLs

        protected boolean useURLs
      • outputFileName

        protected String outputFileName
      • moduleURIResolverClass

        protected String moduleURIResolverClass
      • explaining

        protected boolean explaining
      • wrap

        protected boolean wrap
      • projection

        protected boolean projection
      • streaming

        protected boolean streaming
      • updating

        protected boolean updating
      • writeback

        protected boolean writeback
      • backup

        protected boolean backup
      • explainOutputFileName

        protected String explainOutputFileName
      • languageVersion

        protected String languageVersion
      • nsOption

        protected String nsOption
    • Constructor Detail

      • Query

        public Query()
    • Method Detail

      • getConfiguration

        protected Configuration getConfiguration()
        Get the configuration in use
        Returns:
        the configuration
      • main

        public static void main​(String[] args)
        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
      • setPermittedOptions

        void setPermittedOptions​(CommandLineOptions options)
        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

        public void doQuery​(String[] args)
        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 arguments
      • doQuery

        public void doQuery​(String[] args,
                            String command)
        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 arguments
        command - not used, retained for backwards compatibility
      • initializeConfiguration

        protected void initializeConfiguration​(Configuration config)
        Customisation hook called immediately after the Configuration object is instantiated. The intended purpose of this hook is to allow a subclass to supply an OEM license key programmatically, but it can also be used for other initialization of the Configuration. This method is called before analyzing the command line options, so configuration settings made at this stage may be overridden when the command line options are processed. However, if a configuration file is used, the settings defined in the configuration file will have been applied.
        Parameters:
        config - the Configuration object
      • applyLocalOptions

        protected void applyLocalOptions​(CommandLineOptions options,
                                         Configuration config)
        Customisation hook: apply options defined locally in a subclass
        Parameters:
        options - the CommandLineOptions
        config - the Saxon Configuration
      • compileQuery

        protected XQueryExecutable compileQuery​(XQueryCompiler compiler,
                                                String queryFileName,
                                                boolean useURLs)
                                         throws SaxonApiException,
                                                IOException
        Compile the query
        Parameters:
        compiler - the XQuery compiler
        queryFileName - the filename holding the query (or "-" for the standard input, or the actual query text enclosed in curly braces
        useURLs - true if the filename is in the form of a URI
        Returns:
        the compiled query
        Throws:
        SaxonApiException - if query compilation fails
        IOException - if the query cannot be read
      • quit

        protected void quit​(String message,
                            int code)
        Exit with a message
        Parameters:
        message - The message to be output
        code - The result code to be returned to the operating system shell
      • badUsage

        protected void badUsage​(String message)
        Report incorrect usage of the command line, with a list of the options and arguments that are available
        Parameters:
        message - The error message
      • createFileIfNecessary

        public static void createFileIfNecessary​(File file)
                                          throws IOException
        Utility method to create a file if it does not already exist, including creation of any necessary directories named in the file path
        Parameters:
        file - the file that is required to exist
        Throws:
        IOException - if file creation fails