The Gizmo utility

Saxon (from 10.0) provides the Gizmo command line utility, which can be used interactively or in batch mode, to perform simple operations such as examining the content of a document, renaming or deletion of selected elements in the document, or performing simple XSLT transformation and XSD validation.

The utility can be started from the command line using the Java entry-point class net.sf.saxon.Gizmo, and its actions are controlled by sub-commands entered one per line, either on the standard input, or in a file named in the -q option.

Command line syntax

java net.sf.saxon.Gizmo [-s:source.xml] [-q:script.txt]

Each line of input is a sub-command. The various sub-commands are listed in the following sections.

At any point in the processing, there is (or is not) a current document. On entry, the current document is the source document identified in the -s option, if specified. Many of the sub-commands change the current document. The current document may be inspected using the show sub-command, and may be saved to filestore using the save sub-command.

Most of the sub-commands select nodes within the current document using an XPath expression. If unprefixed element names appear within the expression, they match nodes in the source document by local-name alone. (That is, X means *:X). If you only want to select no-namespace names, use the form Q{}X.

Within XPath expressions, content completion is available for (a) recognized XPath keywords such as "following-sibling", and (b) the names of elements and attributes appearing in the current source document when it was first loaded.

Some of the sub-commands also have a second argument which is a query. Generally this will be an XQuery element constructor such as <a>Title: {string(.)}<a/>. It is evaluated with the context item set to each item selected by the first expression, in turn.