qizx — Qizx command line tool
qizx argument...
Qizx is a simple command-line interface meant for administrative and development use.
It provides basic operations on XML libraries, in particular:
Creating XML Libraries and Library Groups, and performing basic administrative tasks.
Storing XML documents into a Library (also called import), by parsing files or URL's.
Executing XQuery expressions from files.
Outputting the results of a XQuery execution to a file, with a number of options.
Exporting a XML document stored in a Library, as well as the hierarchy of documents from a Collection.
The command-line option switches allow all these basic operations. For more complex problems, it is still possible to benefit of the full power of the XQuery language (and of extension functions provided by Qizx) by executing a script.
Option switches always start with a minus sign. They can be followed by an argument. The letter case is generally significant.
An argument not starting with '-' is considered a XQuery source file to be executed.
Attention: the order of options is important, they are interpreted from left to right, except the query files which are always executed after processing other options.
-group path, -g pathSpecifies the location of a group of XML Libraries. The path points to the root directory of the Group. It can also point to the file group.qlg inside the root directory of the group. This is a XML file that describes the structure of the group.
Unless the option -create is used (see below), the group must exist otherwise the tool will stop in error.
The related XML Libraries will be locked for exclusive access.
-library library_name, -l library_nameSpecifies the name of a XML Library inside the selected group. The library must exist, unless the option -create is used (see below), otherwise the tool will stop in error.
This XML Library can then be used for administrative operations, or for executing queries.
-createUsing this option, the group specified with option -group is created if it does not exist, and the library specified with option -library is created if it does not exist. The option has no effect if both exist.
-import collection XML-file-or-directory...XML-file-or-directoryImport one or several XML documents into a collection (the collection is created if it does not yet exist): documents are parsed (they must be valid), stored and automatically indexed.
Several XML file paths or directory paths can follow this option switch. Directories are scanned recursively, plain files encountered are considered XML and tentatively stored (the -include and -exclude options below can be used to filter files). A parsing error does not stop the load process.
The path of the collection can be a document pattern containing a character '*': this character is replaced by an integer incremented on each document stored, providing an automatic naming mechanism for new documents. For example:
qizx -g mygroup -l mylib -import /a/collection/doc*.xml files...would create documents /a/collection/doc1027.xml, /a/collection/doc1028.xml, /a/collection/doc1030.xml, etc. The numbers are of course guaranteed to be unique, and always increasing, but no other assumption can be made about their values.
-include suffixUsed together with -import: restricts the importing operation to files ending with this suffix (case insensitive). Can be used before or after -import, but must precede the XML file list. For example -include .xml would select only the files whose name ends with .xml or .XML or .Xml, etc.
This option can be repeated: -include .xml -include .xsd would select both files ending with .xml and .xsd. By default all plain files are taken, unless a -exclude option is present (see below)
-exclude suffixUsed together with -import: eliminates form a storing operation files ending with this suffix (case insensitive). Can be used before or after -import, but must precede the XML file list. For example -exclude .txt would eliminate the files whose name ends with .txt or .TXT, etc.
This option can be repeated: -exclude .jpg -exclude .png would eliminate files ending with either .jpg or .png.
-indexing pathDefines an Indexing specification for the Library. An Indexing specification is used for customizing the way XML documents are indexed in the Library. For more information, see Chapter 6, Configuring the indexing process.
This switch must precede -import. If older documents were already imported with a different indexing specification, it is strongly recommended to use the option -reindex (see below) to rebuild indexes.
-export member_pathExports a member of the selected library (Collection or Document) using its path.
-reindexRebuilds all the indexes from scratch, without altering documents.
-optimizeForces the compaction of indexes, without altering the contents of the Library.
-delete-libraryUsing this option, a library is specified with -library will be removed from the group and physically deleted.
-delete member_pathDeletes a member of the selected library (Collection or Document) using its path.
-backup backup_group_pathcomplete backup of the specified Library to the location specified: this location must correspond to a directory on a file-system, where a group will be created if necessary, and in which a XML Library with the same name will be created (if it already exists, it is first erased).
Example:
qizx -c mygroup -library mylib -backup /backups/my-group
This creates a backup group at /backups/my-group (if necessary), then copies the Library mylib into the backup group.
-check log_filePerforms a structural check of all the Libraries of the group and report errors to the log file. This is intended for debugging purpose.
This operation is currently not able to repair a damaged XML Library.
-q query-file, query-fileExecutes the XQuery expression contained in that file(s). The -q option switch is optional (it has to be used only if the file path starts with a dash, which is rarely the case). Several query files can be executed in order.
-base-uri URIDefine the base URI for locating parsed XML documents. Unless a query redefines this base-URI, it will be used for resolving relative document locations as in the function doc().
-module-base-uri URIDefine the base URI for locating XQuery modules.
-domain member_pathDefines the ``Implicit Collection'' i.e the search domain used when a XQuery Path Expression has no explicit root.
For example the expression //ELEM has no explicit root, while collection("/mycollec")//ELEM has the explicit root collection("/mycollec"), supposedly a Collection of the current XML Library. If the Implicit Collection is defined through this option, for example -domain /mycollec , the expression //ELEM is equivalent to collection("/mycollec")//ELEM. Alternately it is also possible to write collection(), the collection() function without argument.
This mechanism makes XQuery scripts more concise, and allows using the same XQuery script on different collections or documents.
In fact, the value of the option corresponds with the argument of function fn:collection (for Qizx/open, follow this link). If you want to use a single document as implicit domain, append a comma or semicolon after its path or URL (in fn:collection, this means that the argument is in fact a list of document paths or path patterns).
-Dvariable_name=valueDefines the value of a global variable. For example if the variable is declared like this:
declare variable $output external;
then the option -Doutput=foo initializes $output with the string value "foo".
If the variable is declared with a type, an attempt to cast the string value to the declared type is made.
If the variable is declared with an initial value, this value is overridden.
-- argument ... argumentThe double dash switch is used to pass command-line arguments to a XQuery script. It stores all following command-line tokens into the predefined variable $arguments. For example:
qizx myscript.xq -- arg1 arg2 arg3
runs the script myscript.xq after putting the sequence of 3 string items ("arg1", "arg2", "arg3") into variable $arguments.
Because of this option, the scripts are always executed after interpretation of all other options.
-timezone durationDefines the implicit timezone in the dynamic XQuery context. The value must be in xs:duration form, for example -timezone -PT5H.
-collation uriDefines the default collation for string comparisons.
Collations are supported through Java collators based on a locale name, for example "en" or "fr-CH". There is currently no support for plugging user-defined collators.
Syntax of the URI of a collation:
Leading slash (so that the URI is absolute, otherwise it would be dereferenced relatively to the base-uri property of the static context).
Name of a locale following the Java conventions.
An optional URI fragment (beginning with a '#') whose value is "primary", "secondary" or "tertiary", defining the "strength" of the collator (see the Java documentation for more details). The value "primary" is less specific than "tertiary".
If the strength is absent, it is in general equivalent to "tertiary".
For example, the expression contains("The next café", "CAFE", "en#primary") should return true, because the collation with strength primary ignores case and accents.
The special URIs codepoint and "http://www.w3.org/2003/05/xpath-functions/collation/codepoint" refer to the basic Unicode codepoint matching (or absence of collation). This is the default collation, unless redefined in the static context.
-Xoption=valueDefines a serialization option for result output. For example -Xmethod=html produces results in HTML markup.
For details of serialization options, see the documentation of the x:serialize() XQuery extension function.
-out fileoutput the result of a XQuery expression to a file (defaults to standard output).
-wrapwraps the displayed results in description tags. For example with -wrap the expression 1, "a" would display:
Query ? 1, "a" <?xml version='1.0' encoding='UTF-8'?> <query-results> <item type="xs:integer">1</item> <item type="xs:string">a</item> </query-results>
instead of:
Query ? 1, "a" 1 a -> 2 item(s)
-jttrace use of Java extension functions (for debugging).
-texverbose display of run-time exceptions (for debugging).
In Qizx/open, only the query execution options and output options are available
This section is an How-To for some common operations with the qizx command line tool:
qizx -group D:\xmldb\group1 -library orders -create
This creates a group in the directory D:\xmldb\group1 (which must be non-existent or empty), containing a single XML Library named 'orders'.
qizx -group D:\xmldb\group1 -create
This creates a group in the directory D:\xmldb\group1, without any XML Library inside.
qizx -group D:\xmldb\group1 -library orders -import /2007/june c:\data\orders\june2007\*.xml
This assumes that the group at D:\xmldb\group1 already exists and contains a Library named 'orders'. Then the specified XML documents are stored into the Collection /2007/june. For example the document c:\data\orders\june2007\A.xml will be stored in the library at /2007/june/A.xml.
qizx -group D:\xmldb\group1 -library orders -create -import /2007/june c:\data\orders\june2007\*.xml
This is a combination of the previous commands: the group and library are created and immediately after the documents are stored into the Library 'orders'.
qizx -group D:\xmldb\group1 -library data -import /2007/june -include .xml -include .xsl \
c:\data\orders\june2007Assuming that the group at D:\xmldb\group1 already exists and contains a Library named 'orders', then all XML documents contained within directory c:\data\orders\june2007 (at any depth), and whose name ends with .xml or .xsl are stored into the Collection /2007/june.
qizx -group D:\xmldb\group1 -library data -import /2007/june -exclude .jpg \
c:\data\orders\june2007Assuming that the group at D:\xmldb\group1 already exists and contains a Library named 'orders', then all XML documents contained within directory c:\data\orders\june2007 (at any depth), and whose name does not end with .jpg are stored into the Collection /2007/june.
qizx -group D:\xmldb\group1 -library dataLib -delete-library
Deletes the library 'dataLib' (selected by -library dataLib) and all its contents. Beware, this operation is irreversible.
qizx -group D:\xmldb\group1 -library dataLib -delete /2007/june
Deletes the collection /2007/june in library 'dataLib' and all its contents (documents and sub-collections). Beware, this operation is irreversible.
qizx -group D:\xmldb\group1 -library dataLib -delete /2007/june/order1.xml
Deletes the document /2007/june/order1.xml in library 'dataLib'. Beware, this operation is irreversible.